redfishwrapper

package
v2.2.6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrManagerID = errors.New("error identifying Manager Odata ID")
	ErrBIOSID    = errors.New("error identifying System BIOS Odata ID")
)
View Source
var (
	// Supported Chassis Odata IDs
	KnownChassisOdataIDs = []string{

		"/redfish/v1/Chassis/Enclosure.Internal.0-1",
		"/redfish/v1/Chassis/System.Embedded.1",
		"/redfish/v1/Chassis/Enclosure.Internal.0-1:NonRAID.Integrated.1-1",

		"/redfish/v1/Chassis/1",

		"/redfish/v1/Chassis/Self",

		"/redfish/v1/Chassis/ASRock_ROMED8HM3",
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a redfishwrapper client which wraps the gofish client.

func NewClient

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

NewClient returns a redfishwrapper client

func (*Client) AccountService

func (c *Client) AccountService() (*redfish.AccountService, error)

AccountService gets the Redfish AccountService.d

func (*Client) BMCReset

func (c *Client) BMCReset(ctx context.Context, resetType string) (ok bool, err error)

BMCReset powercycles the BMC.

func (*Client) Chassis

func (c *Client) Chassis(ctx context.Context) ([]*redfish.Chassis, error)

Chassis gets the chassis instances managed by this service.

func (*Client) ClearSystemEventLog

func (c *Client) ClearSystemEventLog(ctx context.Context) (err error)

ClearSystemEventLog clears all of the LogServices logs

func (*Client) Close

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

Close closes the redfish session.

func (*Client) ConvertTaskState added in v2.2.0

func (c *Client) ConvertTaskState(state string) constants.TaskState

func (*Client) Delete

func (c *Client) Delete(url string) (*http.Response, error)

func (*Client) DeviceVendorModel added in v2.2.0

func (c *Client) DeviceVendorModel(ctx context.Context) (vendor, model string, err error)

DeviceVendorModel returns the device manufacturer and model attributes

func (*Client) FirmwareUpload added in v2.2.0

func (c *Client) FirmwareUpload(ctx context.Context, updateFile *os.File, params *RedfishUpdateServiceParameters) (taskID string, err error)

FirmwareUpload uploads and initiates the firmware install process

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

func (*Client) GetBiosConfiguration added in v2.2.0

func (c *Client) GetBiosConfiguration(ctx context.Context) (biosConfig map[string]string, err error)

func (*Client) GetBootDeviceOverride added in v2.2.0

func (c *Client) GetBootDeviceOverride(_ context.Context) (override bmc.BootDeviceOverride, err error)

GetBootDeviceOverride returns the current boot override settings

func (*Client) GetSystemEventLog added in v2.2.0

func (c *Client) GetSystemEventLog(ctx context.Context) (entries [][]string, err error)

GetSystemEventLog returns the SystemEventLogEntries

func (*Client) GetSystemEventLogRaw added in v2.2.0

func (c *Client) GetSystemEventLogRaw(ctx context.Context) (eventlog string, err error)

GetSystemEventLogRaw returns the raw SEL

func (*Client) HttpClientTimeout

func (c *Client) HttpClientTimeout() time.Duration

retrieve the current HTTP client timeout

func (*Client) InsertedVirtualMedia added in v2.2.0

func (c *Client) InsertedVirtualMedia(ctx context.Context) ([]string, error)

func (*Client) Inventory added in v2.2.0

func (c *Client) Inventory(ctx context.Context, failOnError bool) (device *common.Device, err error)

func (*Client) ManagerOdataID added in v2.2.0

func (c *Client) ManagerOdataID(ctx context.Context) (string, error)

func (*Client) Managers

func (c *Client) Managers(ctx context.Context) ([]*redfish.Manager, error)

Managers gets the manager instances of this service.

func (*Client) Open

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

Open sets up a new redfish session.

func (*Client) PatchWithHeaders

func (c *Client) PatchWithHeaders(ctx context.Context, url string, payload interface{}, headers map[string]string) (*http.Response, error)

func (*Client) PostWithHeaders

func (c *Client) PostWithHeaders(ctx context.Context, url string, payload interface{}, headers map[string]string) (*http.Response, error)

func (*Client) PowerSet added in v2.2.0

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

PowerSet sets the power state of a server

func (*Client) ResetBiosConfiguration added in v2.2.4

func (c *Client) ResetBiosConfiguration(ctx context.Context) (err error)

func (*Client) RunRawRequestWithHeaders

func (c *Client) RunRawRequestWithHeaders(method, url string, payloadBuffer io.ReadSeeker, contentType string, customHeaders map[string]string) (*http.Response, error)

RunRawRequestWithHeaders wraps the gofish client method RunRawRequestWithHeaders

func (*Client) SendNMI added in v2.2.3

func (c *Client) SendNMI(_ context.Context) error

SendNMI tells the BMC to issue an NMI to the device

func (*Client) SessionActive

func (c *Client) SessionActive() error

SessionActive returns an error if a redfish session is not active.

func (*Client) SetBiosConfiguration added in v2.2.4

func (c *Client) SetBiosConfiguration(ctx context.Context, biosConfig map[string]string) (err error)

func (*Client) SetHttpClientTimeout

func (c *Client) SetHttpClientTimeout(t time.Duration)

Overrides the HTTP client timeout

func (*Client) SetVirtualMedia

func (c *Client) SetVirtualMedia(ctx context.Context, kind string, mediaURL string) (ok bool, err error)

Set the virtual media attached to the system, or just eject everything if mediaURL is empty.

func (*Client) StartUpdateForUploadedFirmware added in v2.2.0

func (c *Client) StartUpdateForUploadedFirmware(ctx context.Context) (taskID string, err error)

StartUpdateForUploadedFirmware starts an update for a firmware file previously uploaded and returns the taskID

func (*Client) SystemBootDeviceSet

func (c *Client) SystemBootDeviceSet(_ context.Context, bootDevice string, setPersistent, efiBoot bool) (ok bool, err error)

SystemBootDeviceSet set the boot device for the system.

func (*Client) SystemForceOff

func (c *Client) SystemForceOff(ctx context.Context) (ok bool, err error)

SystemForceOff powers off the system, without waiting for the OS to shutdown.

func (*Client) SystemPowerCycle

func (c *Client) SystemPowerCycle(ctx context.Context) (ok bool, err error)

SystemPowerCycle power cycles the system.

func (*Client) SystemPowerOff

func (c *Client) SystemPowerOff(ctx context.Context) (ok bool, err error)

SystemPowerOff powers off the system.

func (*Client) SystemPowerOn

func (c *Client) SystemPowerOn(ctx context.Context) (ok bool, err error)

SystemPowerOn powers on the system.

func (*Client) SystemPowerStatus

func (c *Client) SystemPowerStatus(ctx context.Context) (result string, err error)

SystemPowerStatus returns the system power state.

func (*Client) SystemReset

func (c *Client) SystemReset(ctx context.Context) (ok bool, err error)

SystemReset power cycles the system.

func (*Client) Systems

func (c *Client) Systems() ([]*redfish.ComputerSystem, error)

Systems get the system instances from the service.

func (*Client) SystemsBIOSOdataID added in v2.2.0

func (c *Client) SystemsBIOSOdataID(ctx context.Context) (string, error)

func (*Client) Task added in v2.2.0

func (c *Client) Task(ctx context.Context, taskID string) (*redfish.Task, error)

func (*Client) TaskStateActive added in v2.2.0

func (c *Client) TaskStateActive(state constants.TaskState) (bool, error)

func (*Client) TaskStatus added in v2.2.0

func (c *Client) TaskStatus(ctx context.Context, taskID string) (constants.TaskState, string, error)

func (*Client) Tasks

func (c *Client) Tasks(ctx context.Context) ([]*redfish.Task, error)

func (*Client) UpdateService

func (c *Client) UpdateService() (*redfish.UpdateService, error)

UpdateService gets the update service instance.

func (*Client) VersionCompatible

func (c *Client) VersionCompatible() bool

VersionCompatible compares the redfish version reported by the BMC with the blacklist if specified.

type Option

type Option func(*Client)

Option is a function applied to a *Conn

func WithBasicAuthEnabled

func WithBasicAuthEnabled(e bool) Option

WithBasicAuthEnabled sets Basic Auth on the Gofish driver.

func WithEtagMatchDisabled

func WithEtagMatchDisabled(d bool) Option

WithEtagMatchDisabled disables the If-Match Etag header from being included by the Gofish driver.

As of the current implementation this disables the header for POST/PATCH requests to the System entity endpoints.

func WithHTTPClient

func WithHTTPClient(cli *http.Client) Option

WithHTTPClient returns an option that sets an HTTP client for the connecion

func WithLogger added in v2.2.0

func WithLogger(l *logr.Logger) Option

WithLogger sets the logger on the redfish wrapper client

func WithSecureTLS

func WithSecureTLS(rootCAs *x509.CertPool) Option

WithSecureTLS returns an option that enables secure TLS with an optional cert pool.

func WithVersionsNotCompatible

func WithVersionsNotCompatible(versions []string) Option

WithVersionsNotCompatible returns an option that sets the redfish versions to ignore as incompatible.

The version string value must match the value returned by curl -k "https://10.247.133.39/redfish/v1" | jq .RedfishVersion

type RedfishUpdateServiceParameters added in v2.2.0

type RedfishUpdateServiceParameters struct {
	Targets            []string                     `json:"Targets"`
	OperationApplyTime constants.OperationApplyTime `json:"@Redfish.OperationApplyTime"`
	Oem                json.RawMessage              `json:"Oem"`
}

type TaskAccepted added in v2.2.0

type TaskAccepted struct {
	Accepted struct {
		Code                string `json:"code"`
		Message             string `json:"Message"`
		MessageExtendedInfo []struct {
			MessageID         string   `json:"MessageId"`
			Severity          string   `json:"Severity"`
			Resolution        string   `json:"Resolution"`
			Message           string   `json:"Message"`
			MessageArgs       []string `json:"MessageArgs"`
			RelatedProperties []string `json:"RelatedProperties"`
		} `json:"@Message.ExtendedInfo"`
	} `json:"Accepted"`
}

Jump to

Keyboard shortcuts

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