bmc

package
v0.0.0-...-b0a73f8 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Features implemented by the AMT provider.

Functions

This section is empty.

Types

type Algorithm

type Algorithm string

Algorithm is the type for HMAC algorithms.

const (
	// ProviderName for the Webook implementation.
	ProviderName = "Webhook"
	// ProviderProtocol for the Webhook implementation.
	ProviderProtocol = "https"
	// SHA256 is the SHA256 algorithm.
	SHA256 Algorithm = "sha256"
	// SHA256Short is the short version of the SHA256 algorithm.
	SHA256Short Algorithm = "256"
	// SHA512 is the SHA512 algorithm.
	SHA512 Algorithm = "sha512"
	// SHA512Short is the short version of the SHA512 algorithm.
	SHA512Short Algorithm = "512"
)

type BootDevice

type BootDevice struct {
	Device     string `json:"device"`
	Persistent bool   `json:"persistent"`
	EFIBoot    bool   `json:"efiBoot"`
}

type Config

type Config struct {
	// Host is the BMC ip address or hostname.
	Host string
	// ConsumerURL is the URL where a webhook consumer/listener is running and to which we will send notifications.
	ConsumerURL string
	// BaseSignatureHeader is the header name that should contain the signature(s). Example: X-Rufio-Signature
	BaseSignatureHeader string
	// IncludeAlgoHeader determines whether to append the algorithm to the signature header or not.
	// Example: X-Rufio-Signature becomes X-Rufio-Signature-256
	// When set to false, a header will be added for each algorithm. Example: X-Rufio-Signature-256 and X-Rufio-Signature-512
	IncludeAlgoHeader bool
	// IncludedPayloadHeaders are headers whose values will be included in the signature payload. Example: X-Rufio-Timestamp
	IncludedPayloadHeaders []string
	// IncludeAlgoPrefix will prepend the algorithm and an equal sign to the signature. Example: sha256=abc123
	IncludeAlgoPrefix bool
	// Logger is the logger to use for logging.
	Logger logr.Logger
	// LogNotifications will log the notifications sent to the webhook consumer/listener.
	LogNotifications bool
	// HTTPContentType is the content type to use for the webhook request notification.
	HTTPContentType string
	// HTTPMethod is the HTTP method to use for the webhook request notification.
	HTTPMethod string
	// contains filtered or unexported fields
}

Config defines the configuration for sending webhook notifications.

func New

func New(consumerURL string, host string) *Config

New returns a new Config for this webhook provider.

Defaults:

BaseSignatureHeader: X-Rufio-Signature
IncludeAlgoHeader: true
IncludedPayloadHeaders: []string{"X-Rufio-Timestamp"}
IncludeAlgoPrefix: true
Logger: logr.Discard()
LogNotifications: true
httpClient: http.DefaultClient

func (*Config) AddSecrets

func (c *Config) AddSecrets(smap map[Algorithm][]string)

AddSecrets adds secrets to the Config.

func (*Config) BootDeviceSet

func (c *Config) BootDeviceSet(ctx context.Context, bootDevice string, setPersistent, efiBoot bool) (ok bool, err error)

BootDeviceSet sends a next boot device webhook notification.

func (*Config) Close

func (c *Config) Close(_ context.Context) (err error)

Close a connection to the webhook consumer.

func (*Config) Name

func (c *Config) Name() string

Name returns the name of this webhook provider.

func (*Config) Open

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

Open a connection to the webhook consumer. For the webhook provider, Open means validating the Config and that communication with the webhook consumer can be established.

func (*Config) PowerSet

func (c *Config) PowerSet(ctx context.Context, state string) (ok bool, err error)

PowerSet sets the power state of a BMC machine.

func (*Config) PowerStateGet

func (c *Config) PowerStateGet(_ context.Context) (state string, err error)

PowerStateGet gets the power state of a BMC machine.

func (*Config) SetTLSCert

func (c *Config) SetTLSCert(cert []byte)

type Payload

type Payload struct {
	Host string `json:"host"`
	Task Task   `json:"task"`
}

type Task

type Task struct {
	Power string `json:"power,omitempty"`
	// Pointers are use so that we can more easily omit the field if it is not set.
	// This matters because the signature payload is generated from the JSON representation of the struct.
	BootDevice   *BootDevice   `json:"bootDevice,omitempty"`
	VirtualMedia *VirtualMedia `json:"virtualMedia,omitempty"`
}

type VirtualMedia

type VirtualMedia struct {
	MediaURL string `json:"mediaUrl"`
	Kind     string `json:"kind"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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