iamt

package module
v0.0.0-...-d7cdbe6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2023 License: MIT Imports: 6 Imported by: 3

README

amt

Go client library to interact with the Intel AMT api (via wsman)

Fork of github.com/ammmze/go-amt

Usage

package main

import (
    "context"
    "fmt"
    "log"
    "os"
    "time"

    "github.com/go-logr/logr"
    "github.com/go-logr/stdr"
    "github.com/jacobweinstock/iamt"
)

func main() {
    ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
    defer cancel()

    client := iamt.NewClient("127.0.0.1", "admin", "admin", iamt.WithLogger(defaultLogger(0)))
    if err := client.Open(ctx); err != nil {
        panic(err)
    }
    defer client.Close(ctx)
    on, err := client.IsPoweredOn(ctx)
    if err != nil {
        panic(err)
    }
    fmt.Println("Is powered on?", on)
}

func defaultLogger(level string) logr.Logger {
    stdr.SetVerbosity(0)

    return stdr.NewWithOptions(log.New(os.Stderr, "", log.LstdFlags), stdr.Options{LogCaller: stdr.All})
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Host   string
	Logger logr.Logger
	Pass   string
	Path   string
	Port   uint32
	Scheme string
	User   string
	// contains filtered or unexported fields
}

Client used to perform actions on the machine.

func NewClient

func NewClient(host, user, passwd string, opts ...Option) *Client

NewClient creates an amt client to use.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close the client.

func (*Client) IsPoweredOn

func (c *Client) IsPoweredOn(ctx context.Context) (bool, error)

IsPoweredOn checks current power state.

func (*Client) Open

func (c *Client) Open(ctx context.Context) error

Open the client.

func (*Client) PowerCycle

func (c *Client) PowerCycle(ctx context.Context) error

PowerCycle will power cycle a given machine.

func (*Client) PowerOff

func (c *Client) PowerOff(ctx context.Context) error

PowerOff will power off a given machine.

func (*Client) PowerOn

func (c *Client) PowerOn(ctx context.Context) error

PowerOn will power on a given machine.

func (*Client) SetPXE

func (c *Client) SetPXE(ctx context.Context) error

SetPXE makes sure the node will pxe boot next time.

type Option

type Option func(*Client)

Option for setting optional Client values.

func WithLogger

func WithLogger(logger logr.Logger) Option

func WithPath

func WithPath(path string) Option

func WithPort

func WithPort(port uint32) Option

func WithScheme

func WithScheme(scheme string) Option

Directories

Path Synopsis
wsman
Package wsman implements a simple WSMAN client interface.
Package wsman implements a simple WSMAN client interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL