Documentation
¶
Overview ¶
Package redfish is a small client for the DMTF Redfish API of a server's BMC, to read what a node consumes: the energy counter of its chassis (EnvironmentMetrics.EnergykWh), else its power (EnvironmentMetrics.PowerWatts or Power.PowerControl[].PowerConsumedWatts).
It is self-contained (the standard library only), safe for concurrent use, and does no scheduling: polling, counters over time and attribution belong to the caller.
What it follows ¶
Each rule below comes from a document opened on 2026-11-05.
- DSP0266 Redfish Specification 1.23.0, the newest found on 2026-11-05 (dmtf.org/sites/default/files/standards/documents/DSP0266_1.23.0.pdf; its table of contents was opened: the section numbers cited in this package are 1.23.0's, and the text of the sections below was read in 1.19.0, whose numbering of 13.3 and 7.2.3 is the same): the service root, by default /redfish/v1/ (section 7.2.3); HTTP Basic authentication (13.3.3: "All requests that use HTTP Basic authentication shall require HTTPS"); login sessions (13.3.4: the Sessions collection is found in the service root's Links.Sessions; a POST of {"UserName", "Password"} "without an authentication header", over HTTPS, answers with an X-Auth-Token header, the token to send on later requests, and a Location header, the Session resource to DELETE to log out; the session ID is not the token).
- Chassis v1.29.0 (redfish.dmtf.org/schemas/v1/Chassis.v1_29_0.json): the EnvironmentMetrics property links the chassis' EnvironmentMetrics resource, "all containing chassis, and devices contained by any of these chassis instances", with the warning that "care should be taken to ensure any reported values do not overlap or result in double-counting": Read therefore returns the first chassis that has a reading rather than adding chassis up. The Power link is deprecated in favour of PowerSubsystem and is only a fallback here.
- EnvironmentMetrics v1.3.1 (EnvironmentMetrics.v1_3_1.json): EnergykWh, "the total energy, in kilowatt-hour units, for this resource"; EnergyJoules, its device-level equivalent; PowerWatts. Each is a Sensor excerpt whose Reading is the value (Sensor v1.6.7, SensorEnergykWhExcerpt). A counter is preferred to a power: the energy between two reads is then exact.
- Power v1.7.3 (Power.v1_7_3.json): PowerControl[].PowerConsumedWatts, "the actual power that the chassis consumes, in watt units" (minimum 0).
Safety ¶
https only, certificates verified (against a CA file when given), TLS 1.2 or later, no redirect followed, every body bounded to MaxBody (MaxExpandedBody for a request with $expand), every request under a timeout, credentials resolved per request through Credentials, and no error carries a credential. A reading that is null, negative, not finite or out of range is dropped by the parsers, which are fuzzed.
Index ¶
- Constants
- Variables
- func CheckDestination(dest string) error
- func CheckImageURI(uri, protocol string, allowed []string) error
- func CheckPayload(req, cur Props) (changes bool, unsupported string)
- func CheckPrivateKey(key Secret, certString string) error
- func CheckVolumeRequest(raid string, drives, supported, own []string) error
- func MultipartFrame(params []byte, filename, customName, customMIME, customContent string) (prefix, suffix []byte, contentType string, err error)
- func ParseActionInfo(data []byte) (map[string][]string, error)
- func ParseCertificateLocations(data []byte) ([]string, error)
- func ParseMetricNumber(s string) (float64, error)
- func ParsePowerConsumed(doc []byte) (float64, error)
- func ParseRedfishDuration(s string) (time.Duration, error)
- func PasswordChangeURI(err error) string
- func RequireCounter(r Reading) (float64, error)
- func ResetTypeOf(command string) (string, bool)
- func ValidateURL(raw string) error
- type AccountSpec
- type BootOverride
- type CSR
- type CSRInfo
- type CSRRequest
- type Certificate
- type CertificateInput
- type CertificateService
- type Client
- func (c *Client) AccountServiceConfig(ctx context.Context) (Props, error)
- func (c *Client) ActionValues(ctx context.Context, action Props) map[string][]string
- func (c *Client) AddUser(ctx context.Context, a AccountSpec) (Outcome, error)
- func (c *Client) BiosAttributes(ctx context.Context, systemURI string) (Props, error)
- func (c *Client) BiosRegistry(ctx context.Context, systemURI string) (registry Props, uri string, err error)
- func (c *Client) BootOrder(ctx context.Context, systemURI string) ([]Props, error)
- func (c *Client) BootOverrideOf(ctx context.Context, systemURI string) (Props, error)
- func (c *Client) CPUInventory(ctx context.Context, systemURI string) ([]Props, error)
- func (c *Client) Certificate(ctx context.Context, idOrURI string) (Certificate, error)
- func (c *Client) CertificateLocations(ctx context.Context) ([]string, error)
- func (c *Client) CertificateService(ctx context.Context) (CertificateService, error)
- func (c *Client) Certificates(ctx context.Context) ([]Certificate, error)
- func (c *Client) CertificatesOf(ctx context.Context, collURI string) ([]Certificate, error)
- func (c *Client) ChassisEnvironmentMetrics(ctx context.Context, chassisURI string) (Props, error)
- func (c *Client) ChassisHealthReport(ctx context.Context, chassisURI string) (Props, error)
- func (c *Client) ChassisHealthReports(ctx context.Context, uris ...string) ([]Props, error)
- func (c *Client) ChassisInventory(ctx context.Context, uris ...string) ([]Props, error)
- func (c *Client) ChassisPower(ctx context.Context, uris ...string) ([]Props, error)
- func (c *Client) ChassisPowerSubsystem(ctx context.Context, chassisURI string) (Props, error)
- func (c *Client) ChassisSensors(ctx context.Context, chassisURI string) ([]Props, error)
- func (c *Client) ChassisThermalSubsystem(ctx context.Context, chassisURI string) (Props, error)
- func (c *Client) ChassisThermals(ctx context.Context, uris ...string) ([]Props, error)
- func (c *Client) ChassisURIs(ctx context.Context) ([]string, error)
- func (c *Client) ClearLogs(ctx context.Context, resURI string) (Outcome, error)
- func (c *Client) ClearSessions(ctx context.Context) (Outcome, error)
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) ComponentIntegrities(ctx context.Context) ([]ComponentIntegrity, error)
- func (c *Client) ComponentIntegrity(ctx context.Context, idOrURI string) (ComponentIntegrity, error)
- func (c *Client) CreateMetricReportDefinition(ctx context.Context, in MetricReportDefinitionInput) (MetricReportDefinition, Outcome, error)
- func (c *Client) CreateVolume(ctx context.Context, systemURI, storageID string, req VolumeRequest) (VolumeResult, error)
- func (c *Client) Delete(ctx context.Context, p, ifMatch string) (*Response, error)
- func (c *Client) DeleteCertificate(ctx context.Context, idOrURI string) (Outcome, error)
- func (c *Client) DeleteMetricReportDefinition(ctx context.Context, idOrURI string) (Outcome, error)
- func (c *Client) DeleteUser(ctx context.Context, a AccountSpec) (Outcome, error)
- func (c *Client) DeleteVolumes(ctx context.Context, systemURI, storageID string, ids []string, ...) (VolumeResult, error)
- func (c *Client) DisableUser(ctx context.Context, a AccountSpec) (Outcome, error)
- func (c *Client) DiskInventory(ctx context.Context, systemURI string) ([]Props, error)
- func (c *Client) Do(ctx context.Context, req Request) (*Response, error)
- func (c *Client) EachManager(ctx context.Context, uris []string, ...) ([]ManagerEntry, error)
- func (c *Client) EnableUser(ctx context.Context, a AccountSpec) (Outcome, error)
- func (c *Client) EventService(ctx context.Context) (EventService, error)
- func (c *Client) Events(ctx context.Context, filter string) (*EventStream, error)
- func (c *Client) EventsWith(ctx context.Context, o EventsOptions) (*EventStream, error)
- func (c *Client) FanInventory(ctx context.Context, uris ...string) ([]Props, error)
- func (c *Client) FirmwareInventory(ctx context.Context) ([]Props, error)
- func (c *Client) FirmwareUpdateCapabilities(ctx context.Context) (UpdateCapabilities, error)
- func (c *Client) GenerateCSR(ctx context.Context, req CSRRequest) (CSR, Outcome, error)
- func (c *Client) Get(ctx context.Context, p string) (*Response, error)
- func (c *Client) GetSessions(ctx context.Context) ([]Props, error)
- func (c *Client) GetSignedMeasurements(ctx context.Context, idOrURI string, req SignedMeasurementsRequest) (SignedMeasurements, error)
- func (c *Client) GetWith(ctx context.Context, p string, q Query) (*Response, error)
- func (c *Client) HPEFanPercentMin(ctx context.Context, uris ...string) (any, error)
- func (c *Client) HPEThermalConfig(ctx context.Context, uris ...string) (any, error)
- func (c *Client) HealthReport(ctx context.Context, category, uri string, subsystems []string) (Props, error)
- func (c *Client) HostInterfaces(ctx context.Context, managerURIs ...string) ([]Props, error)
- func (c *Client) InstallCertificate(ctx context.Context, collection string, in CertificateInput) (Certificate, Outcome, error)
- func (c *Client) KeyService(ctx context.Context) (KeyService, error)
- func (c *Client) LinkedCertificates(ctx context.Context, uris []string) []LinkedCertificate
- func (c *Client) ListUsers(ctx context.Context) ([]Props, error)
- func (c *Client) Login(ctx context.Context) error
- func (c *Client) Logs(ctx context.Context, resURI string, max int) ([]LogEntries, error)
- func (c *Client) ManagePower(ctx context.Context, resURI, actionName, command string) (Outcome, error)
- func (c *Client) ManagerDateTime(ctx context.Context, managerURI string) (Props, error)
- func (c *Client) ManagerHealthReport(ctx context.Context, managerURI string) (Props, error)
- func (c *Client) ManagerInventory(ctx context.Context, managerURI string) (Props, error)
- func (c *Client) ManagerNICInventory(ctx context.Context, managerURI string) ([]Props, error)
- func (c *Client) ManagerPower(ctx context.Context, managerURI, command string) (Outcome, error)
- func (c *Client) ManagerResetToDefaults(ctx context.Context, managerURI, mode string) (Outcome, error)
- func (c *Client) ManagerURIs(ctx context.Context) ([]string, error)
- func (c *Client) MemoryInventory(ctx context.Context, systemURI string) ([]Props, error)
- func (c *Client) MetricDefinition(ctx context.Context, idOrURI string) (MetricDefinition, error)
- func (c *Client) MetricDefinitions(ctx context.Context) ([]MetricDefinition, error)
- func (c *Client) MetricReport(ctx context.Context, idOrURI string) (MetricReport, error)
- func (c *Client) MetricReportDefinition(ctx context.Context, idOrURI string) (MetricReportDefinition, error)
- func (c *Client) MetricReportDefinitions(ctx context.Context) ([]MetricReportDefinition, error)
- func (c *Client) MetricReportEvents(ctx context.Context, o EventsOptions) (*EventStream, error)
- func (c *Client) MetricReports(ctx context.Context) ([]MetricReport, error)
- func (c *Client) MultipartHTTPPushUpdate(ctx context.Context, o PushOptions) (UpdateResult, error)
- func (c *Client) NICInventory(ctx context.Context, resURI string) ([]Props, error)
- func (c *Client) NVMeoFKeyPolicies(ctx context.Context) ([]KeyPolicy, error)
- func (c *Client) NVMeoFSecrets(ctx context.Context) ([]NVMeoFSecret, error)
- func (c *Client) NetworkProtocols(ctx context.Context, managerURI string) (Props, error)
- func (c *Client) PSUInventory(ctx context.Context) ([]Props, error)
- func (c *Client) Patch(ctx context.Context, p string, v any, ifMatch string) (*Response, error)
- func (c *Client) PatchChecked(ctx context.Context, uri string, payload Props) (Outcome, error)
- func (c *Client) PerformRequestedOperations(ctx context.Context, handle string) (Outcome, error)
- func (c *Client) PolicyCertificates(ctx context.Context, sp SecurityPolicy) ([]PolicyCertificates, error)
- func (c *Client) Post(ctx context.Context, p string, v any) (*Response, error)
- func (c *Client) PowerRestorePolicy(ctx context.Context, systemURI string) (any, error)
- func (c *Client) ProtocolFeatures(ctx context.Context) (ProtocolFeatures, error)
- func (c *Client) Read(ctx context.Context) (Reading, error)
- func (c *Client) RekeyCertificate(ctx context.Context, idOrURI string, o RekeyOptions) (CSR, Outcome, error)
- func (c *Client) RenewCertificate(ctx context.Context, idOrURI string, challenge Secret) (CSR, Outcome, error)
- func (c *Client) ReplaceCertificate(ctx context.Context, certURI string, in CertificateInput) (string, Outcome, error)
- func (c *Client) ResetBios(ctx context.Context, systemURI string) (Outcome, error)
- func (c *Client) ResolveChassis(ctx context.Context, id string) (string, error)
- func (c *Client) ResolveManager(ctx context.Context, id string) (string, error)
- func (c *Client) ResolveServiceIdentification(ctx context.Context, id string) (string, error)
- func (c *Client) ResolveSystem(ctx context.Context, id string) (string, error)
- func (c *Client) Roles(ctx context.Context) ([]Props, error)
- func (c *Client) Root(ctx context.Context) (ServiceRoot, error)
- func (c *Client) SecurityPolicy(ctx context.Context, managerID string) (SecurityPolicy, error)
- func (c *Client) ServiceIdentification(ctx context.Context, managerURI string) (string, error)
- func (c *Client) Session() (token, uri string)
- func (c *Client) SessionServiceURI(ctx context.Context) (string, error)
- func (c *Client) SetAssetTag(ctx context.Context, uri, tag string) (Outcome, error)
- func (c *Client) SetBiosAttributes(ctx context.Context, systemURI string, attrs Props, applyTime string) (Outcome, error)
- func (c *Client) SetBootOrder(ctx context.Context, systemURI string, order []string) (Outcome, error)
- func (c *Client) SetBootOverride(ctx context.Context, systemURI string, bo BootOverride) (Outcome, error)
- func (c *Client) SetDefaultBootOrder(ctx context.Context, systemURI string) (Outcome, error)
- func (c *Client) SetHostInterface(ctx context.Context, managerURI, id string, config Props) (Outcome, error)
- func (c *Client) SetIndicatorLED(ctx context.Context, uri, command string) (Outcome, error)
- func (c *Client) SetManagerDateTime(ctx context.Context, managerURI, dateTime, offset string) (Outcome, error)
- func (c *Client) SetManagerNIC(ctx context.Context, managerURI, addr string, config Props) (Outcome, error)
- func (c *Client) SetNTP(ctx context.Context, managerURI string, servers []string, enabled *bool) (Outcome, error)
- func (c *Client) SetNetworkProtocols(ctx context.Context, managerURI string, services Props) (Outcome, error)
- func (c *Client) SetPowerRestorePolicy(ctx context.Context, systemURI, policy string) (Outcome, error)
- func (c *Client) SetSecureBoot(ctx context.Context, systemURI string, enable bool) (Outcome, error)
- func (c *Client) SetServiceIdentification(ctx context.Context, managerURI, serviceID string) (Outcome, error)
- func (c *Client) SetSessionService(ctx context.Context, props Props) (Outcome, error)
- func (c *Client) SimpleUpdate(ctx context.Context, o SimpleUpdateOptions) (UpdateResult, error)
- func (c *Client) SoftwareInventory(ctx context.Context) ([]Props, error)
- func (c *Client) StorageControllerInventory(ctx context.Context, systemURI string) ([]Props, error)
- func (c *Client) SubmitTestEvent(ctx context.Context, t TestEvent) (Outcome, error)
- func (c *Client) SubmitTestMetricReport(ctx context.Context, name string, values []TestMetricValue) (Outcome, error)
- func (c *Client) Subscribe(ctx context.Context, o SubscribeOptions) (Subscription, Outcome, error)
- func (c *Client) Subscription(ctx context.Context, idOrURI string) (Subscription, error)
- func (c *Client) Subscriptions(ctx context.Context) ([]Subscription, error)
- func (c *Client) SystemHealthReport(ctx context.Context, systemURI string) (Props, error)
- func (c *Client) SystemInventory(ctx context.Context, systemURI string) (Props, error)
- func (c *Client) SystemPower(ctx context.Context, systemURI, command string) (Outcome, error)
- func (c *Client) SystemURIs(ctx context.Context) ([]string, error)
- func (c *Client) TelemetryService(ctx context.Context) (TelemetryService, error)
- func (c *Client) Triggers(ctx context.Context) ([]Trigger, error)
- func (c *Client) TrustedComponent(ctx context.Context, idOrURI string, chassis ...string) (TrustedComponent, error)
- func (c *Client) TrustedComponents(ctx context.Context, chassis ...string) ([]TrustedComponent, error)
- func (c *Client) Unsubscribe(ctx context.Context, idOrURI string) (Outcome, error)
- func (c *Client) UpdateAccountServiceProperties(ctx context.Context, props Props) (Outcome, error)
- func (c *Client) UpdateStatus(ctx context.Context, handle string) (UpdateStatus, error)
- func (c *Client) UpdateUserAccountTypes(ctx context.Context, a AccountSpec) (Outcome, error)
- func (c *Client) UpdateUserName(ctx context.Context, a AccountSpec) (Outcome, error)
- func (c *Client) UpdateUserPassword(ctx context.Context, a AccountSpec) (Outcome, error)
- func (c *Client) UpdateUserRole(ctx context.Context, a AccountSpec) (Outcome, error)
- func (c *Client) VerifyBiosAttributes(ctx context.Context, systemURI string, attrs Props) (Outcome, error)
- func (c *Client) VirtualMedia(ctx context.Context, resURI string) ([]Props, error)
- func (c *Client) VirtualMediaEject(ctx context.Context, resURI, imageURL string) (Outcome, error)
- func (c *Client) VirtualMediaInsert(ctx context.Context, resURI string, o VirtualMediaOptions) (Outcome, error)
- func (c *Client) VolumeInventory(ctx context.Context, systemURI string) ([]Props, error)
- func (c *Client) WaitAvailable(ctx context.Context, delay, poll, timeout time.Duration) error
- func (c *Client) WaitTask(ctx context.Context, monitor string, poll time.Duration, onProgress func(Task)) (*Response, error)
- func (c *Client) WaitUpdate(ctx context.Context, handle string, poll time.Duration, onProgress func(Task)) (UpdateStatus, error)
- type ComponentIntegrity
- type Config
- type Credentials
- type DeleteVolumesOptions
- type Digest
- type EnergyUnit
- type Event
- type EventRecord
- type EventService
- type EventStream
- type EventsOptions
- type Expand
- type ExpandKind
- type Identifier
- type Interval
- type KeyPolicy
- type KeyService
- type LinkedCertificate
- type LogEntries
- type ManagerEntry
- type Measurement
- type Message
- type Meter
- type MetricDefinition
- type MetricReport
- type MetricReportDefinition
- type MetricReportDefinitionInput
- type MetricSpec
- type MetricValue
- type Metrics
- type NVMeoFSecret
- type Outcome
- type ParameterSet
- type Point
- type PolicyCertificates
- type Props
- func BuildVolumePayload(details Props, drives []string) (Props, error)
- func NetworkProtocolPayload(services Props) (Props, error)
- func ParseController(data []byte) (Props, error)
- func ParseDrive(data []byte, uri string) (Props, error)
- func ParseLogEntries(data []byte) (description string, members []Props, next string, err error)
- func ParseVolume(data []byte) (Props, error)
- func Pick(data []byte, keys ...string) (Props, error)
- type ProtocolFeatures
- type PushOptions
- type Query
- type Reading
- type RekeyOptions
- type ReportSchedule
- type Request
- type ResetRequest
- type Response
- type SPDMInfo
- type SPDMPolicy
- type SSEMessage
- type SSEReader
- type Secret
- type SecurityPolicy
- type Series
- type ServiceRoot
- type Session
- type SignedMeasurements
- type SignedMeasurementsRequest
- type SimpleUpdateOptions
- type Source
- type Static
- type StatusError
- type SubscribeOptions
- type Subscription
- type TLSPolicy
- type TPMInfo
- type Task
- type TelemetryService
- type TestEvent
- type TestMetricValue
- type Threshold
- type Trigger
- type TrustedComponent
- type UpdateCapabilities
- type UpdateResult
- type UpdateStatus
- type VirtualMediaOptions
- type VolumeRequest
- type VolumeResult
- type Wildcard
- type X509Info
Constants ¶
const ( // MaxCertificateString bounds a CertificateString read or sent (a chain of a // few certificates is a few KiB). MaxCertificateString = 64 << 10 // MaxKeyPEM bounds a private key sent. MaxKeyPEM = 16 << 10 // MaxCSRString bounds a CSRString read. MaxCSRString = 16 << 10 // MaxCertificates bounds the certificates read of a service. MaxCertificates = 256 )
const ( // ReasonBaseline: the first usable sample; nothing to difference yet. ReasonBaseline = "baseline" // ReasonReset: the energy counter went down (the BMC rebooted or its counter // wrapped): the energy of the interval is unknown, and a negative delta is // never reported as consumption. ReasonReset = "counter reset" // ReasonGap: two power samples are further apart than MaxGap; the power // between them is not interpolated. ReasonGap = "gap" // ReasonSource: the BMC changed what it reports between the two reads (a // counter, then only a power, or the reverse). ReasonSource = "source changed" // ReasonClock: the second read is not after the first. ReasonClock = "clock" // ReasonNoReading: the read carries no energy and no power. ReasonNoReading = "no reading" )
Why an Interval holds no energy.
const ( // MaxBody bounds every answer a BMC gives. MaxBody = 1 << 20 // MaxMembers bounds the members read of a collection. MaxMembers = 64 // DefaultTimeout bounds a request when none is set. DefaultTimeout = 10 * time.Second // DefaultTaskTimeout bounds WaitTask when the context has no deadline; it is // the CLI's --watch-timeout default. DefaultTaskTimeout = time.Hour )
Limits.
const ( // MaxSecurityMembers bounds the members read of a security collection. MaxSecurityMembers = 256 // MaxMeasurements bounds the measurements kept of one measurement set. MaxMeasurements = 1024 // MaxDigestText bounds the Base64 text of one measurement or summary (a // digest is at most 64 bytes; this leaves room for a longer algorithm). MaxDigestText = 4096 // MaxSignedBlobText bounds the Base64 text of SignedMeasurements. MaxSignedBlobText = 256 << 10 // MaxSignedMeasurementsBytes bounds the answer of SPDMGetSignedMeasurements. MaxSignedMeasurementsBytes = 2 * MaxSignedBlobText )
Bounds of the security reads.
const ( // MaxEventBytes bounds the data of one event (DSP0266 12.1.2: 1 MiB). MaxEventBytes = 1 << 20 // MaxSSELine bounds one line of the stream. MaxSSELine = 1 << 20 )
Limits of a stream.
const ( // MaxTelemetryMembers bounds the members read of a telemetry collection. MaxTelemetryMembers = 256 // MaxMetricValues bounds the MetricValues of one metric report, and the // values of a test report. MaxMetricValues = 4096 // MaxMetricReportBytes bounds a metric report document. MaxMetricReportBytes = MaxEventBytes )
Bounds of the telemetry reads.
const ( // DefaultMaxImage is the largest image a push sends unless PushOptions.MaxSize // says otherwise (4 GiB). DefaultMaxImage int64 = 4 << 30 // DefaultUploadTimeout bounds the upload of an image (a request's own timeout // is meant for a small JSON document). DefaultUploadTimeout = 30 * time.Minute )
Limits of the Update area.
const DefaultMaxGap = 5 * time.Minute
DefaultMaxGap is the MaxGap of a zero Meter.
const KWhPerJoule = 1.0 / 3_600_000
KWhPerJoule converts joules to kilowatt-hours (1 kWh = 3.6 MJ).
const MaxDestination = 2048
MaxDestination bounds the length of a Destination.
const MaxEventRecords = 256
MaxEventRecords bounds the records of one Event.
const ( // MaxExpandedBody bounds the answer to a request that carries $expand. An // expanded answer holds many resources (DSP0266 7.3.2: "the payload may // increase beyond what can be sent in a single response"), so it may exceed // MaxBody, but it is bounded all the same: a larger one is ErrTooLarge, and a // converted read then falls back to one request per member. MaxExpandedBody = 8 << 20 )
Limits of a query.
const MaxFilter = 1024
MaxFilter bounds a $filter expression.
const MaxLogEntries = 1024
MaxLogEntries bounds the entries read of a log.
const MaxSubscriptions = MaxMembers
MaxSubscriptions bounds the subscriptions read of a service.
const NoProtocolList = "Key TransferProtocol@Redfish.AllowableValues not found"
NoProtocolList is what the oracle reports for an action that lists no TransferProtocol allowable values.
Variables ¶
var ( // ErrAuth: the BMC refused the credentials (401 or 403). ErrAuth = errors.New("redfish: authentication refused") // ErrNotFound: the resource does not exist (404), or the service does not // link it. ErrNotFound = errors.New("redfish: resource not found") // ErrTooLarge: an answer is larger than MaxBody. ErrTooLarge = errors.New("redfish: the answer is larger than the limit") // ErrMalformed: an answer is not the JSON that was expected. ErrMalformed = errors.New("redfish: malformed answer") // ErrNoReading: the resource carries no energy and no power reading. ErrNoReading = errors.New("redfish: no energy or power reading") // ErrInsecure: the URL is not an https URL, or carries credentials. ErrInsecure = errors.New("redfish: the URL is not acceptable") )
Typed errors, for errors.Is and errors.As.
var ( // ErrUnsupported: the resource does not have the property or action asked for. ErrUnsupported = errors.New("redfish: not supported by the resource") // ErrAmbiguous: several resources match and none was named. ErrAmbiguous = errors.New("redfish: several resources match: name one") // ErrMismatch: values differ from the ones expected. ErrMismatch = errors.New("redfish: the values do not match") )
var CertificateTypes = []string{"PEM", "PEMchain", "PKCS7", "PKCS12"}
CertificateTypes are the formats of Certificate.CertificateType (Certificate 1.11.0, CertificateType).
var ErrBadDigest = errors.New("redfish: not a Base64 string with padding")
ErrBadDigest: a measurement or blob is not a Base64 string with padding.
var ErrCertificateTooLarge = errors.New("redfish: the certificate data is larger than the limit")
ErrCertificateTooLarge: a certificate, key or CSR string is over its limit.
var ErrEventTooLarge = errors.New("redfish: an event is larger than the limit")
ErrEventTooLarge: a line or an event of the stream is larger than the limit.
var ErrImageTooLarge = errors.New("redfish: the image is larger than the limit")
ErrImageTooLarge: the image is larger than the limit.
var ErrNoAccount = errors.New("redfish: no account with the given id or username")
ErrNoAccount: no account has the Id or the UserName asked for (the oracle's no_match).
var ErrNoCounter = errors.New("redfish: the BMC reports no energy counter")
ErrNoCounter is returned by RequireCounter when a read has no energy counter.
var ErrNotNumeric = errors.New("redfish: the metric value is not a number")
ErrNotNumeric: a metric value is null, or its string is not a number.
var ErrQuery = errors.New("redfish: invalid query parameter")
ErrQuery: a query parameter has a value, or a combination, the grammar of DSP0266 7.3 refuses. Nothing was sent.
var KeyUsageValues = []string{"DigitalSignature", "NonRepudiation", "KeyEncipherment", "DataEncipherment", "KeyAgreement", "KeyCertSign", "CRLSigning",
"EncipherOnly", "DecipherOnly", "ServerAuthentication", "ClientAuthentication", "CodeSigning", "EmailProtection", "Timestamping", "OCSPSigning"}
KeyUsageValues are the values of KeyUsage (Certificate 1.11.0, KeyUsage).
var ProtocolServices = []string{"SNMP", "VirtualMedia", "Telnet", "SSDP", "IPMI", "SSH", "KVMIP", "NTP", "HTTP", "HTTPS", "DHCP", "DHCPv6", "RDP", "RFB"}
ProtocolServices are the services of the ManagerNetworkProtocol resource the oracle reads and sets.
var ResetToDefaultsModes = []string{"ResetAll", "PreserveNetworkAndUsers", "PreserveNetwork"}
ResetToDefaultsModes are the ResetType values of Manager.ResetToDefaults the module accepts.
Functions ¶
func CheckDestination ¶ added in v0.10.0
CheckDestination applies the rules a subscription Destination must meet before it is sent: an https URL with a host, no credentials in it (userinfo), no query and no fragment (a token in a URL ends up in logs: a receiver that needs authorization takes it from HttpHeaders), and no control character. DSP0266 13.1 requires TLS 1.2 or later of the interface, and 13.7 has the service verify the destination's identity: a plain http destination would send the events in clear, which this client refuses. redfish-sse:// destinations are made by the service for an SSE connection (EventDestination.Destination) and are not created by a client.
func CheckImageURI ¶ added in v0.8.0
CheckImageURI validates the ImageURI of a SimpleUpdate against the transfer protocols the service allows: bounded, no control character or space, no credentials in it, and a scheme that is one of the allowed protocols and matches protocol when it is given. The error never repeats the URI.
func CheckPayload ¶ added in v0.4.0
CheckPayload compares the properties to apply with the ones the resource holds (_check_request_payload): changes is true when one differs; unsupported names the first property the resource does not have (nested objects are compared member by member; arrays and scalars by value).
func CheckPrivateKey ¶ added in v0.11.0
CheckPrivateKey verifies a PEM private key against the certificate it is for: one block, of an accepted type (PKCS#8, PKCS#1 RSA or SEC 1 EC; not encrypted), within MaxKeyPEM, whose public key is the certificate's. The error never holds any of the key.
func CheckVolumeRequest ¶ added in v0.9.0
CheckVolumeRequest checks a volume against what its Storage subsystem says: the RAID type must be one of the controller's SupportedRAIDTypes (when it lists them) and each drive one of the subsystem's Drives (when it lists any). The service has the last word; this refuses what it would refuse, before anything is deleted. The drives are compared as paths.
func MultipartFrame ¶ added in v0.8.0
func MultipartFrame(params []byte, filename, customName, customMIME, customContent string) (prefix, suffix []byte, contentType string, err error)
MultipartFrame builds the multipart/form-data body of a push but for the file's bytes: prefix (every part up to the UpdateFile part's headers), suffix (the closing boundary) and the Content-Type; the body is prefix, the file, suffix, so its length is known and the file can be streamed (_prepare_multipart). params is the JSON of the UpdateParameters part.
func ParseActionInfo ¶ added in v0.4.0
ParseActionInfo decodes an ActionInfo resource (DSP0266 9.9.6) into the allowable values of each named parameter (nil when it lists none).
func ParseCertificateLocations ¶ added in v0.11.0
ParseCertificateLocations decodes a CertificateLocations resource into the paths of the certificates it lists (Links.Certificates, CertificateLocations 1.0.4): at most MaxCertificates, each a path of the service, without duplicates. It never panics.
func ParseMetricNumber ¶ added in v0.14.0
ParseMetricNumber reads a metric value string as a number, strictly: the grammar of a JSON number (RFC 8259 6: an optional minus, an integer part without a leading zero, an optional fraction, an optional exponent), at most 64 bytes, and a finite float64. A space, a plus sign, a hexadecimal, "NaN" or "Inf", an empty string, or a number out of range is an error wrapping ErrNotNumeric: nothing is guessed and nothing becomes 0.
func ParsePowerConsumed ¶
ParsePowerConsumed sums the PowerConsumedWatts of the PowerControl entries of a Power resource (the older way a BMC reports power). ErrNoReading when none is usable.
func ParseRedfishDuration ¶ added in v0.14.0
ParseRedfishDuration reads a Redfish duration, the ISO 8601 form the schemas pattern as ^P(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d+)?S)?)?$ (MinCollectionInterval, RecurrenceInterval, SensingInterval...). At least one component is required (the pattern also matches "P" and "PT", which name no duration), each is of at most 9 digits, the seconds may have up to 9 fraction digits, and the total is at most 100 years.
func PasswordChangeURI ¶ added in v0.7.0
PasswordChangeURI is check_password_change_required: when a service answered that the password of the authenticated user must be changed (an extended message Base.1.x.PasswordChangeRequired, in the error object or at the top level), the account it names (its first argument; a path of the service), else "".
func RequireCounter ¶ added in v0.2.0
RequireCounter returns the counter of a read, ErrNoCounter when it has none: for a caller that bills only a measured counter.
func ResetTypeOf ¶ added in v0.4.0
ResetTypeOf maps a power command (PowerOn, PowerForceOff, PowerReboot, PowerCycle...) to its ResetType, ok false for an unknown command.
func ValidateURL ¶
ValidateURL applies the rules every BMC URL must meet: https, a host, no credentials, no query or fragment.
Types ¶
type AccountSpec ¶ added in v0.7.0
type AccountSpec struct {
ID, Username string // the account: its Id, or its UserName
Password Secret // AddUser, UpdateUserPassword
RoleID string
AccountTypes []string
// OEMAccountTypes is the OEMAccountTypes property.
OEMAccountTypes []string
// NewUsername is the name UpdateUserName gives (account_updatename).
NewUsername string
}
AccountSpec says which account a command acts on and what to set (the module's account_id, account_username, account_password, account_roleid, account_accounttypes, account_oemaccounttypes and account_updatename).
func (AccountSpec) String ¶ added in v0.7.0
func (a AccountSpec) String() string
String lists the spec without its password.
type BootOverride ¶ added in v0.4.0
type BootOverride struct {
// Device is the BootSourceOverrideTarget (Pxe, Cd, Hdd, UefiTarget, UefiBootNext...).
Device string
// UefiTarget (UefiTarget device) and BootNext (UefiBootNext device).
UefiTarget, BootNext string
// Enabled is Once (SetOneTimeBoot), Continuous (EnableContinuousBootOverride)
// or Disabled (DisableBootOverride).
Enabled string
// Mode is Legacy or UEFI, "" to leave it.
Mode string
}
BootOverride is a boot source override (ComputerSystem Boot).
type CSR ¶ added in v0.11.0
type CSR struct {
// PEM is the CSRString.
PEM string `json:"pem"`
// CollectionURI is where the signed certificate is installed (GenerateCSR).
CollectionURI string `json:"collection_uri,omitempty"`
// CertificateURI is the certificate the signed request replaces (Rekey, Renew).
CertificateURI string `json:"certificate_uri,omitempty"`
// Info is the request decoded by this library; InfoError says why it is absent.
Info *CSRInfo `json:"info,omitempty"`
InfoError string `json:"info_error,omitempty"`
}
CSR is the answer of a GenerateCSR, Rekey or Renew action: the PEM PKCS#10 request a CA signs. The private key stays in the service ("should not be part of the response"); an answer that carries one is refused.
func ParseCSRResponse ¶ added in v0.11.0
ParseCSRResponse decodes the body of the answer to GenerateCSR, Rekey or Renew (GenerateCSRResponse, RekeyResponse, RenewResponse): CSRString is required, as PEM and within MaxCSRString, and carries no private key. It never panics.
type CSRInfo ¶ added in v0.11.0
type CSRInfo struct {
Subject string `json:"subject"`
SignatureAlgorithm string `json:"signature_algorithm"`
PublicKeyAlgorithm string `json:"public_key_algorithm"`
KeyBits int `json:"key_bits,omitempty"`
KeyCurve string `json:"key_curve,omitempty"`
DNSNames []string `json:"dns_names,omitempty"`
IPAddresses []string `json:"ip_addresses,omitempty"`
EmailAddresses []string `json:"email_addresses,omitempty"`
// SignatureValid is the result of CheckSignature: the request proves possession of the key.
SignatureValid bool `json:"signature_valid"`
}
CSRInfo is what crypto/x509 reads in a PKCS#10 request (RFC 2986).
type CSRRequest ¶ added in v0.11.0
type CSRRequest struct {
// CertificateCollection is the collection the signed certificate will be
// installed in (required).
CertificateCollection string
CommonName string
AlternativeNames []string
Organization string
OrganizationalUnit string
City, State string
// Country is the two-letter ISO code.
Country string
Email string
// GivenName, Surname, Initials, ContactPerson and UnstructuredName are the
// other subject attributes of the schema.
GivenName, Surname, Initials, ContactPerson, UnstructuredName string
// KeyPairAlgorithm is a name of the TCG algorithm registry (TPM_ALG_RSA,
// TPM_ALG_ECDSA), KeyBitLength and KeyCurveID (TPM_ECC_NIST_P256...) go with it.
KeyPairAlgorithm string
KeyBitLength int
KeyCurveID string
// KeyUsage names are the values of the Certificate schema's KeyUsage.
KeyUsage []string
// ChallengePassword is the RFC 2985 challengePassword attribute: a secret, never
// printed, redacted from errors.
ChallengePassword Secret
}
CSRRequest is the parameters of CertificateService.GenerateCSR (1.2.2). Only CertificateCollection is required by the schema; a service lists the ones it needs in its ActionInfo.
type Certificate ¶ added in v0.11.0
type Certificate struct {
URI string `json:"uri"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
UsageTypes []string `json:"usage_types,omitempty"`
Subject *Identifier `json:"subject,omitempty"`
Issuer *Identifier `json:"issuer,omitempty"`
ValidNotBefore string `json:"valid_not_before,omitempty"`
ValidNotAfter string `json:"valid_not_after,omitempty"`
KeyUsage []string `json:"key_usage,omitempty"`
SerialNumber string `json:"serial_number,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
FingerprintHashAlgorithm string `json:"fingerprint_hash_algorithm,omitempty"`
SignatureAlgorithm string `json:"signature_algorithm,omitempty"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
// Rekey and Renew are true when the certificate has the action.
Rekey bool `json:"rekey"`
Renew bool `json:"renew"`
// PEM is the certificate string (certificates only), kept for `certs show --pem`.
PEM string `json:"-"`
// X509 is the certificate decoded by this library from the CertificateString:
// what the certificate really says, which a client can compare with what the
// service states above. X509Error says why it is absent.
X509 *X509Info `json:"x509,omitempty"`
X509Error string `json:"x509_error,omitempty"`
}
Certificate is a Certificate resource (Certificate 1.11.0). The private key and the Password are never part of it: a CertificateString that carries a private key (the schema has the service remove it) is reduced to its certificates.
func ParseCertificateResource ¶ added in v0.11.0
func ParseCertificateResource(uri string, data []byte) (Certificate, error)
ParseCertificateResource decodes a Certificate resource. It never panics, and reads what the CertificateString holds with the bounds of ParseX509.
type CertificateInput ¶ added in v0.11.0
type CertificateInput struct {
// CertificateString is the certificate: PEM, a PEM chain, a PEM PKCS7 or a
// Base64 PKCS12, as CertificateType says. It must not carry a private key (give
// PrivateKey), so that the key can be kept out of errors.
CertificateString string
// CertificateType is one of CertificateTypes; empty: PEM.
CertificateType string
// PrivateKey is the PEM private key of the certificate, for a service that does
// not know it (a certificate that was not made from a CSR of this service). It
// is appended to the CertificateString (the schema's rule), is checked to match the
// certificate, is never printed and is redacted from errors. An encrypted key is
// refused: the schema has no parameter for its passphrase. Not for PKCS12, which
// carries its key.
PrivateKey Secret
// Password is the password of a PKCS12 bundle (Password of ReplaceCertificate, 1.1.0).
Password Secret
}
CertificateInput is a certificate to install or to put in place of another.
type CertificateService ¶ added in v0.11.0
type CertificateService struct {
URI string `json:"uri"`
// LocationsURI is the CertificateLocations resource ("" when the service has none).
LocationsURI string `json:"locations_uri,omitempty"`
// EnrollmentCACertificatesURI is the collection of the server certificates of the
// automatic enrollment servers (1.2.0).
EnrollmentCACertificatesURI string `json:"enrollment_ca_certificates_uri,omitempty"`
// GenerateCSR and ReplaceCertificate are true when the service has the action.
GenerateCSR bool `json:"generate_csr"`
ReplaceCertificate bool `json:"replace_certificate"`
// AutomaticEnrollmentEnabled is nil when the service does not say (1.2.0).
AutomaticEnrollmentEnabled *bool `json:"automatic_enrollment_enabled,omitempty"`
EnrollmentTypes []string `json:"enrollment_types,omitempty"`
}
CertificateService is the CertificateService resource (CertificateService 1.2.2).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client reads one BMC. It is safe for concurrent use.
func (*Client) AccountServiceConfig ¶ added in v0.7.0
AccountServiceConfig is the AccountService resource (get_accountservice_properties).
func (*Client) ActionValues ¶ added in v0.4.0
ActionValues is the allowable values of an action's parameters: from its ActionInfo resource when it names one, else from the annotations (_get_all_action_info_values).
func (*Client) AddUser ¶ added in v0.7.0
AddUser creates an account (add_user): nothing is done when the UserName exists. The account is created with a POST to the Accounts collection; when the service does not allow POST (no POST in its Allow header, or a 405 answer), an empty slot, or the account whose Id is given, is changed by a PATCH.
func (*Client) BiosAttributes ¶ added in v0.4.0
BiosAttributes are the current BIOS attributes of a system (get_bios_attributes).
func (*Client) BiosRegistry ¶ added in v0.4.0
func (c *Client) BiosRegistry(ctx context.Context, systemURI string) (registry Props, uri string, err error)
BiosRegistry is the attribute registry of the system's BIOS: the document named by Bios.AttributeRegistry, found under Registries and read from its English Location (get_bios_registries). uri is where the document was read.
func (*Client) BootOrder ¶ added in v0.4.0
BootOrder is the boot order of a system as devices: each BootOption's DisplayName and BootOptionReference when the system has BootOptions, else the reference alone (get_boot_order).
func (*Client) BootOverrideOf ¶ added in v0.4.0
BootOverrideOf is what GetBootOverride reports: the Boot override properties the system has and that are not null; an error when the override is not enabled-able at all (no BootSourceOverrideEnabled).
func (*Client) CPUInventory ¶ added in v0.4.0
CPUInventory lists the processors of a system (get_cpu_inventory).
func (*Client) Certificate ¶ added in v0.11.0
Certificate reads one certificate, named by its Id (one of the CertificateLocations) or its path, and decodes its CertificateString with ParseX509.
func (*Client) CertificateLocations ¶ added in v0.11.0
CertificateLocations lists the certificates the service holds, as the CertificateLocations resource of the service gives them (every certificate installed on the service, whatever collection holds it).
func (*Client) CertificateService ¶ added in v0.11.0
func (c *Client) CertificateService(ctx context.Context) (CertificateService, error)
CertificateService reads the CertificateService (ErrUnsupported when the service root links none).
func (*Client) Certificates ¶ added in v0.11.0
func (c *Client) Certificates(ctx context.Context) ([]Certificate, error)
Certificates reads every certificate the service locates (at most MaxCertificates; more is an error, read them one by one then). One that disappeared since the listing is skipped.
func (*Client) CertificatesOf ¶ added in v0.15.0
CertificatesOf reads the certificates of a collection (a TrustedComponent's Certificates, or one of a SecurityPolicy), each decoded with ParseX509: at most MaxSecurityMembers, $expand where advertised. An empty uri gives none.
func (*Client) ChassisEnvironmentMetrics ¶ added in v0.5.0
ChassisEnvironmentMetrics is the EnvironmentMetrics of a chassis: its power, energy, temperature, humidity and fan speeds, as the service reports them; ErrUnsupported when the chassis has none.
func (*Client) ChassisHealthReport ¶ added in v0.5.0
ChassisHealthReport is the health of a chassis and of its power supplies, fans and PCIe devices (get_chassis_health_report).
func (*Client) ChassisHealthReports ¶ added in v0.5.0
ChassisHealthReports is ChassisHealthReport of each chassis, each entry naming its chassis_uri (get_multi_chassis_health_report).
func (*Client) ChassisInventory ¶ added in v0.5.0
ChassisInventory lists the identity properties of the chassis (get_chassis_inventory).
func (*Client) ChassisPower ¶ added in v0.5.0
ChassisPower is the first PowerControl entry of each chassis' Power resource (get_chassis_power); an error when no chassis has a Power resource.
func (*Client) ChassisPowerSubsystem ¶ added in v0.5.0
ChassisPowerSubsystem is the PowerSubsystem of a chassis (the capacity, the allocation, the Status) and its power supplies; ErrUnsupported when the chassis has none.
func (*Client) ChassisSensors ¶ added in v0.5.0
ChassisSensors lists the Sensor resources of a chassis (its Sensors collection): what each reads, in which unit and range, and its Status.
func (*Client) ChassisThermalSubsystem ¶ added in v0.5.0
ChassisThermalSubsystem is the ThermalSubsystem of a chassis (its Status and fan redundancy), its fans and its ThermalMetrics; ErrUnsupported when the chassis has none.
func (*Client) ChassisThermals ¶ added in v0.5.0
ChassisThermals lists the Temperatures of the Thermal resources (get_chassis_thermals); a property that is null is left out.
func (*Client) ChassisURIs ¶
ChassisURIs lists the chassis of the service (at most MaxMembers).
func (*Client) ClearLogs ¶ added in v0.6.0
ClearLogs runs the ClearLog action of every log service of a manager that has it (clear_logs), or of a system or a chassis (redfishtool "clearLog").
func (*Client) ClearSessions ¶ added in v0.7.0
ClearSessions ends every active session (clear_sessions). When the client's own session is among them it is ended last (the oracle authenticates by password on each request; a client that holds a token would be refused for the rest).
func (*Client) ComponentIntegrities ¶ added in v0.15.0
func (c *Client) ComponentIntegrities(ctx context.Context) ([]ComponentIntegrity, error)
ComponentIntegrities lists the ComponentIntegrity resources of the service (at most MaxSecurityMembers, $expand where the service advertises it). ErrUnsupported when the service root links none.
func (*Client) ComponentIntegrity ¶ added in v0.15.0
func (c *Client) ComponentIntegrity(ctx context.Context, idOrURI string) (ComponentIntegrity, error)
ComponentIntegrity reads one resource, named by its Id or its path.
func (*Client) CreateMetricReportDefinition ¶ added in v0.14.0
func (c *Client) CreateMetricReportDefinition(ctx context.Context, in MetricReportDefinitionInput) (MetricReportDefinition, Outcome, error)
CreateMetricReportDefinition creates a metric report definition: a POST to the MetricReportDefinitions collection (the schema says it is insertable). The input is checked first against the schema, and against the service: it must be enabled; a Periodic recurrence must not be shorter than MinCollectionInterval; a CollectionFunction must be in SupportedCollectionFunctions; a MetricId must be the Id of a MetricDefinition; and a definition that records its reports in the collection is refused when the service already holds MaxReports of them. Nothing is sent when a check fails. The service answers 201 with the Location of the new definition.
func (*Client) CreateVolume ¶ added in v0.9.0
func (c *Client) CreateVolume(ctx context.Context, systemURI, storageID string, req VolumeRequest) (VolumeResult, error)
CreateVolume creates a volume in a Storage subsystem of a system (create_volume). The subsystem is named by the last segment of its path (the oracle's storage_subsystem_id; with none, the only one). The answer is 201 with the new volume, or 202 with a task monitor in Outcome.Monitor.
func (*Client) DeleteCertificate ¶ added in v0.11.0
DeleteCertificate deletes a certificate, named by its Id or path (Certificate: deletable). It is read first, so that only a Certificate resource is deleted. A certificate that is already gone (404) is not a change.
func (*Client) DeleteMetricReportDefinition ¶ added in v0.14.0
DeleteMetricReportDefinition deletes a metric report definition, named by its Id or its path: the resource is read first so that only a MetricReportDefinition is deleted, then removed with a DELETE. A definition that is already gone (404) is not an error: nothing changed.
func (*Client) DeleteUser ¶ added in v0.7.0
DeleteUser removes the account (delete_user); nothing is done when it does not exist. A service that does not allow DELETE (no DELETE in the Allow header of the account, or a 405) gets the account emptied by a PATCH instead: UserName "" and, when it is enabled, Enabled false (delete_user_via_patch).
func (*Client) DeleteVolumes ¶ added in v0.9.0
func (c *Client) DeleteVolumes(ctx context.Context, systemURI, storageID string, ids []string, o DeleteVolumesOptions) (VolumeResult, error)
DeleteVolumes deletes the volumes of a Storage subsystem named by their Ids (delete_volumes). The Ids are required and each must be a volume of the subsystem: unlike the oracle, which skips an Id it does not find and says the volumes "were deleted", nothing is deleted when one is unknown.
func (*Client) DisableUser ¶ added in v0.7.0
DisableUser disables the account (disable_user).
func (*Client) DiskInventory ¶ added in v0.9.0
DiskInventory lists the drives of a system by controller (get_disk_inventory): one entry per Storage subsystem with its Controller name, StorageId and Drives; when the system has no Storage but a SimpleStorage, one entry per SimpleStorage with the properties of its Devices. (The oracle's code tests the SimpleStorage link after the Storage branch has overwritten its variable, so a system that has both is read through Storage only: the same here.)
func (*Client) Do ¶ added in v0.3.0
Do sends a request and returns the answer. A non-2xx answer is an error: ErrAuth (401, 403), ErrNotFound (404) or a *StatusError carrying what the service said (412 when If-Match no longer matches, 400 with its ExtendedInfo...).
func (*Client) EachManager ¶ added in v0.6.0
func (c *Client) EachManager(ctx context.Context, uris []string, fn func(ctx context.Context, managerURI string) (any, error)) ([]ManagerEntry, error)
EachManager runs a read on the managers uris (every manager of the service when none is given) and collects the answers; the first error stops it.
func (*Client) EnableUser ¶ added in v0.7.0
EnableUser enables the account (enable_user).
func (*Client) EventService ¶ added in v0.10.0
func (c *Client) EventService(ctx context.Context) (EventService, error)
EventService reads the EventService of the service (ErrUnsupported when the service root links none).
func (*Client) Events ¶ added in v0.10.0
Events opens the SSE stream of the service with a filter ("" for none), and reconnects up to 3 times after a broken connection (EventsWith for the options). The stream runs until ctx is cancelled, the service ends it, or an event is larger than the limit.
func (*Client) EventsWith ¶ added in v0.10.0
func (c *Client) EventsWith(ctx context.Context, o EventsOptions) (*EventStream, error)
EventsWith is Events with options. The first connection is opened before it returns: a refusal (401, 403, 400 for a filter the service does not know, anything but 200 text/event-stream) is its error; ErrUnsupported when the EventService has no ServerSentEventUri or is disabled.
func (*Client) FanInventory ¶ added in v0.5.0
FanInventory lists the fans of the Thermal resources (get_fan_inventory); a Thermal resource without Fans is an error ("No Fans present").
func (*Client) FirmwareInventory ¶ added in v0.8.0
FirmwareInventory lists the members of the UpdateService's FirmwareInventory (GetFirmwareInventory); ErrNotFound when the service has none.
func (*Client) FirmwareUpdateCapabilities ¶ added in v0.8.0
func (c *Client) FirmwareUpdateCapabilities(ctx context.Context) (UpdateCapabilities, error)
FirmwareUpdateCapabilities reads what the UpdateService can do (GetFirmwareUpdateCapabilities).
func (*Client) GenerateCSR ¶ added in v0.11.0
GenerateCSR runs CertificateService.GenerateCSR: the service makes a key pair, keeps the private key for the installation of the signed certificate, and returns the request. Each parameter is checked against the service's ActionInfo (or AllowableValues) and the collection must be a CertificateCollection of the service.
func (*Client) GetSessions ¶ added in v0.7.0
GetSessions lists the active sessions (get_sessions). The Sessions collection is the service root's Links.Sessions, else the default path (the oracle fails when the root has no Links.Sessions).
func (*Client) GetSignedMeasurements ¶ added in v0.15.0
func (c *Client) GetSignedMeasurements(ctx context.Context, idOrURI string, req SignedMeasurementsRequest) (SignedMeasurements, error)
GetSignedMeasurements runs the SPDMGetSignedMeasurements action of a ComponentIntegrity (named by Id or path) and returns the signed statement of the service. The action does not change the service; it makes the BMC run SPDM GET_MEASUREMENTS exchanges with the device. The parameters are checked first (indices, nonce, slot) and against the ActionInfo or AllowableValues of the service. The signature is not verified (SignedMeasurements.Verified). ErrUnsupported when the resource has no such action (the schema has it only for type SPDM).
func (*Client) GetWith ¶ added in v0.12.0
GetWith reads a resource with query parameters. p is a path of the service without a query string. The ProtocolFeaturesSupported of the service root is read first (once per Client); a parameter it does not advertise is refused with ErrUnsupported, a value the grammar forbids with ErrQuery, and nothing is sent. The answer is bounded by MaxBody, or by MaxExpandedBody when the query has $expand.
func (*Client) HPEFanPercentMin ¶ added in v0.5.0
HPEFanPercentMin is Oem.Hpe.FanPercentMinimum of the first chassis that has it (get_hpe_fan_percent_min); ErrUnsupported when none does.
func (*Client) HPEThermalConfig ¶ added in v0.5.0
HPEThermalConfig is Oem.Hpe.ThermalConfiguration of the first chassis that has it (get_hpe_thermal_config); ErrUnsupported when none does.
func (*Client) HealthReport ¶ added in v0.4.0
func (c *Client) HealthReport(ctx context.Context, category, uri string, subsystems []string) (Props, error)
HealthReport is the Status of a resource and of its subsystems (get_health_report): a subsystem is a property ("Memory"), "Links.X" or "Prop.X" (the resource Prop links, then its X). Each entry names the uri of the member and its Status ("Status not available" when it has none).
func (*Client) HostInterfaces ¶ added in v0.6.0
HostInterfaces lists the host interfaces of the managers (every manager when none is given) with the NICs they use (get_hostinterfaces); an error when the service has none.
func (*Client) InstallCertificate ¶ added in v0.11.0
func (c *Client) InstallCertificate(ctx context.Context, collection string, in CertificateInput) (Certificate, Outcome, error)
InstallCertificate adds a certificate to a certificate collection: a POST to the collection with CertificateString and CertificateType (requiredOnCreate of Certificate 1.11.0; DSP0266 9.9.13: the formats the collection supports are checked first). The service shall answer 201 with the Location of the new resource, which is read; a 202 is returned as the Outcome's Monitor.
func (*Client) KeyService ¶ added in v0.15.0
func (c *Client) KeyService(ctx context.Context) (KeyService, error)
KeyService reads the KeyService of the service (ErrUnsupported when the service root links none).
func (*Client) LinkedCertificates ¶ added in v0.15.0
func (c *Client) LinkedCertificates(ctx context.Context, uris []string) []LinkedCertificate
LinkedCertificates reads the certificates at uris (a path of the service each; at most MaxSecurityMembers). A read that fails is reported in its entry, not as an error of the call: the others are still read.
func (*Client) ListUsers ¶ added in v0.7.0
ListUsers lists the accounts (list_users), without the empty slots of a service that has a fixed number of accounts (an empty UserName on a disabled account).
func (*Client) Login ¶ added in v0.3.0
Login opens the session now (Config.Session); a client does it on first use.
func (*Client) Logs ¶ added in v0.6.0
Logs reads the entries of the log services of a manager (get_logs), or of a system or a chassis (redfishtool "Logs"), at most max entries per log (0: 64). The oracle keeps the entries as the collection expands them; an entry the collection lists only by link is read.
func (*Client) ManagePower ¶ added in v0.4.0
func (c *Client) ManagePower(ctx context.Context, resURI, actionName, command string) (Outcome, error)
ManagePower runs a power command (PowerOn, PowerForceOff, PowerGracefulShutdown, PowerGracefulRestart, PowerForceRestart, PowerReboot, PowerCycle, PowerFullPowerCycle) through the Reset action actionName of a resource, with the ResetType the service allows (ActionInfo or AllowableValues); nothing is sent when the resource is already in the state asked.
func (*Client) ManagerDateTime ¶ added in v0.6.0
ManagerDateTime is the DateTime and DateTimeLocalOffset of a manager (redfishtool "Managers": no Ansible row).
func (*Client) ManagerHealthReport ¶ added in v0.6.0
ManagerHealthReport is the health of a manager (get_manager_health_report: a manager has no subsystem).
func (*Client) ManagerInventory ¶ added in v0.6.0
ManagerInventory is the inventory properties of a manager (get_manager_inventory).
func (*Client) ManagerNICInventory ¶ added in v0.6.0
ManagerNICInventory lists the EthernetInterfaces of a manager (get_nic_inventory on a manager: GetManagerNicInventory).
func (*Client) ManagerPower ¶ added in v0.6.0
ManagerPower runs a power command on a manager (manage_manager_power): PowerOn, PowerForceOff, PowerForceRestart, PowerGracefulRestart, PowerGracefulShutdown, PowerReboot..., and GracefulRestart, which the module maps to PowerGracefulRestart. The ResetType is the one the service allows (ActionInfo or AllowableValues).
func (*Client) ManagerResetToDefaults ¶ added in v0.6.0
func (c *Client) ManagerResetToDefaults(ctx context.Context, managerURI, mode string) (Outcome, error)
ManagerResetToDefaults runs the ResetToDefaults action of a manager (manager_reset_to_defaults) with the mode given (ResetAll, PreserveNetworkAndUsers or PreserveNetwork); a mode the service does not allow is refused before anything is sent.
func (*Client) ManagerURIs ¶ added in v0.6.0
ManagerURIs lists the Manager resources (_find_managers_resource).
func (*Client) MemoryInventory ¶ added in v0.4.0
MemoryInventory lists the memory modules of a system that are present: one whose Status is missing or Absent is left out (get_memory_inventory).
func (*Client) MetricDefinition ¶ added in v0.14.0
MetricDefinition reads one metric definition, named by its Id or its path.
func (*Client) MetricDefinitions ¶ added in v0.14.0
func (c *Client) MetricDefinitions(ctx context.Context) ([]MetricDefinition, error)
MetricDefinitions lists the MetricDefinitions of the service (at most MaxTelemetryMembers).
func (*Client) MetricReport ¶ added in v0.14.0
MetricReport reads one metric report, named by its Id or its path. For a definition of type OnRequest this GET is what generates the report (MetricReportDefinitionType OnRequest); no other call is needed.
func (*Client) MetricReportDefinition ¶ added in v0.14.0
func (c *Client) MetricReportDefinition(ctx context.Context, idOrURI string) (MetricReportDefinition, error)
MetricReportDefinition reads one metric report definition, named by its Id or its path.
func (*Client) MetricReportDefinitions ¶ added in v0.14.0
func (c *Client) MetricReportDefinitions(ctx context.Context) ([]MetricReportDefinition, error)
MetricReportDefinitions lists the MetricReportDefinitions of the service (at most MaxTelemetryMembers).
func (*Client) MetricReportEvents ¶ added in v0.14.0
func (c *Client) MetricReportEvents(ctx context.Context, o EventsOptions) (*EventStream, error)
MetricReportEvents opens the SSE stream of the service for metric reports: EventsWith with the filter `EventFormatType eq 'MetricReport'` (DSP0266 12.5.2: "The service sends events of the matching EventFormatType"), joined by `and` with o.Filter when there is one. It is the EventStream of Events, not another reader: each event arrives with Event.Report set to the decoded MetricReport. ErrUnsupported when the EventService lists its EventFormatTypes without MetricReport.
func (*Client) MetricReports ¶ added in v0.14.0
func (c *Client) MetricReports(ctx context.Context) ([]MetricReport, error)
MetricReports lists the MetricReports of the service with their values (at most MaxTelemetryMembers reports, each of at most MaxMetricValues values; $expand where the service advertises it). A report that does not decode is an error.
func (*Client) MultipartHTTPPushUpdate ¶ added in v0.8.0
func (c *Client) MultipartHTTPPushUpdate(ctx context.Context, o PushOptions) (UpdateResult, error)
MultipartHTTPPushUpdate sends an image to the MultipartHttpPushUri of the UpdateService (multipath_http_push_update): a multipart/form-data upload of an UpdateParameters part (Targets, apply time, Oem) and the UpdateFile part. The file is opened first and must be a regular file within MaxSize; it is streamed with a known Content-Length, never read whole. The answer is usually a task, as for SimpleUpdate.
func (*Client) NICInventory ¶ added in v0.4.0
NICInventory lists the EthernetInterfaces of a system or a manager that can be read (get_nic_inventory).
func (*Client) NVMeoFKeyPolicies ¶ added in v0.15.0
NVMeoFKeyPolicies lists the NVMe-oF key policies of the KeyService (at most MaxSecurityMembers).
func (*Client) NVMeoFSecrets ¶ added in v0.15.0
func (c *Client) NVMeoFSecrets(ctx context.Context) ([]NVMeoFSecret, error)
NVMeoFSecrets lists the NVMe-oF secrets of the KeyService (at most MaxSecurityMembers). Their key material is not returned: see NVMeoFSecret.
func (*Client) NetworkProtocols ¶ added in v0.6.0
NetworkProtocols is the services of a manager's NetworkProtocol resource that it has (get_network_protocols).
func (*Client) PSUInventory ¶ added in v0.4.0
PSUInventory lists the power supplies of the chassis that are present, from each chassis' Power resource (get_psu_inventory); an error when there is none.
func (*Client) Patch ¶ added in v0.3.0
Patch changes properties of a resource. ifMatch, when not empty, is the ETag the resource must still have.
func (*Client) PatchChecked ¶ added in v0.4.0
PatchChecked changes properties the way the modules do (patch_request with check_pyld): the resource is read, the ETag it gave goes back in If-Match, a property it does not have is ErrUnsupported, and nothing is sent when it already holds every value.
func (*Client) PerformRequestedOperations ¶ added in v0.8.0
PerformRequestedOperations does what the update asks to continue (perform_requested_update_operations): the resets its task requests. Changed is false when it asks for none. When a reset fails, the Outcome says whether the earlier ones were done.
func (*Client) PolicyCertificates ¶ added in v0.15.0
func (c *Client) PolicyCertificates(ctx context.Context, sp SecurityPolicy) ([]PolicyCertificates, error)
PolicyCertificates reads the trusted and revoked certificates the policy lists (SPDM, TLS client, TLS server), each decoded with ParseX509. A collection the policy does not link is left out.
func (*Client) Post ¶ added in v0.3.0
Post creates a member of a collection or invokes an action (v is its parameters).
func (*Client) PowerRestorePolicy ¶ added in v0.4.0
PowerRestorePolicy is the policy of a system (get_power_restore_policy).
func (*Client) ProtocolFeatures ¶ added in v0.12.0
func (c *Client) ProtocolFeatures(ctx context.Context) (ProtocolFeatures, error)
ProtocolFeatures reads the ProtocolFeaturesSupported of the service root, once: the answer is kept for the life of the Client.
func (*Client) Read ¶
Read reads the node's consumption: the EnergykWh counter of the chassis' EnvironmentMetrics, else (no counter) its PowerWatts, else the Power resource's PowerControl PowerConsumedWatts. With Config.MetricsPath only that resource is read; otherwise the service is discovered once and the links are remembered.
func (*Client) RekeyCertificate ¶ added in v0.11.0
func (c *Client) RekeyCertificate(ctx context.Context, idOrURI string, o RekeyOptions) (CSR, Outcome, error)
RekeyCertificate runs Certificate.Rekey: the service makes a new key pair for the certificate and returns a CSR for it (the private key stays in the service). ErrUnsupported when the certificate has no such action.
func (*Client) RenewCertificate ¶ added in v0.11.0
func (c *Client) RenewCertificate(ctx context.Context, idOrURI string, challenge Secret) (CSR, Outcome, error)
RenewCertificate runs Certificate.Renew: the service returns a CSR made from the existing information and key pair of the certificate. ErrUnsupported when the certificate has no such action.
func (*Client) ReplaceCertificate ¶ added in v0.11.0
func (c *Client) ReplaceCertificate(ctx context.Context, certURI string, in CertificateInput) (string, Outcome, error)
ReplaceCertificate runs the CertificateService.ReplaceCertificate action: the certificate at certURI (an Id or a path) is replaced by the one given. The service shall answer with the Location of the new certificate resource, which is returned (the old URI when the service names none). CertificateType is checked against the ActionInfo or AllowableValues. A certificate made from the CSR of this service needs no PrivateKey: the service kept the key.
func (*Client) ResetBios ¶ added in v0.4.0
ResetBios runs the Bios.ResetBios action: the BIOS goes back to its default settings (set_bios_default_settings).
func (*Client) ResolveChassis ¶ added in v0.4.0
ResolveChassis is ResolveSystem for the chassis.
func (*Client) ResolveManager ¶ added in v0.6.0
ResolveManager is the manager named id, the only one when id is empty, else ErrAmbiguous.
func (*Client) ResolveServiceIdentification ¶ added in v0.6.0
ResolveServiceIdentification picks the manager get_service_identification reads: the one named id; else the only manager; else, among several, the one manager that has a ServiceIdentification (ErrAmbiguous when none or several).
func (*Client) ResolveSystem ¶ added in v0.4.0
ResolveSystem is the system named id, the only one when id is empty, else ErrAmbiguous.
func (*Client) Roles ¶ added in v0.7.0
Roles lists the Roles of the AccountService (the redfishtool AccountService Roles operation; the oracle only names a RoleId). The collection is the AccountService's Roles link, else the one under Links.
func (*Client) Root ¶
func (c *Client) Root(ctx context.Context) (ServiceRoot, error)
Root reads the service root.
func (*Client) SecurityPolicy ¶ added in v0.15.0
SecurityPolicy reads the SecurityPolicy of a manager (the one named by id, the only one when id is empty). ErrUnsupported when the manager links none.
func (*Client) ServiceIdentification ¶ added in v0.6.0
ServiceIdentification is the ServiceIdentification of a manager (get_service_identification); ErrUnsupported when it has none.
func (*Client) Session ¶ added in v0.3.0
Session is the token and the Session resource of the open session, to resume it later (Config.Token and SessionURI), or empty. The token is a credential: keep it as one.
func (*Client) SessionServiceURI ¶ added in v0.7.0
SessionServiceURI is the SessionService resource.
func (*Client) SetAssetTag ¶ added in v0.4.0
SetAssetTag sets the AssetTag of a system or a chassis (redfishtool "setAssetTag"; community.general has no row for it).
func (*Client) SetBiosAttributes ¶ added in v0.4.0
func (c *Client) SetBiosAttributes(ctx context.Context, systemURI string, attrs Props, applyTime string) (Outcome, error)
SetBiosAttributes sets BIOS attributes through the Settings object of the Bios resource (@Redfish.Settings, DSP0266 9.10; set_bios_attributes). Attributes the BIOS does not have are left out and named in Outcome.Warning; the ones it already holds are not sent. applyTime, when not empty, is sent as @Redfish.SettingsApplyTime (DSP0266 7.12: Immediate, OnReset, AtMaintenanceWindowStart...); a Dell service gets OnReset when it is empty, as in the oracle. The change takes effect as the service applies it (usually a reset).
func (*Client) SetBootOrder ¶ added in v0.4.0
func (c *Client) SetBootOrder(ctx context.Context, systemURI string, order []string) (Outcome, error)
SetBootOrder sets the boot order of a system; each reference must be one of the system's BootOptions when it has them (set_boot_order).
func (*Client) SetBootOverride ¶ added in v0.4.0
func (c *Client) SetBootOverride(ctx context.Context, systemURI string, bo BootOverride) (Outcome, error)
SetBootOverride sets the boot source override of a system (set_boot_override: SetOneTimeBoot, EnableContinuousBootOverride, DisableBootOverride). The device must be in BootSourceOverrideTarget@Redfish.AllowableValues when the system lists them. Dell services get the oracle's two workarounds: the Settings object when the system cannot be patched, and no Enabled with UefiTarget.
func (*Client) SetDefaultBootOrder ¶ added in v0.4.0
SetDefaultBootOrder runs the system's SetDefaultBootOrder action.
func (*Client) SetHostInterface ¶ added in v0.6.0
func (c *Client) SetHostInterface(ctx context.Context, managerURI, id string, config Props) (Outcome, error)
SetHostInterface changes the HostInterface of a manager: the one whose Id is id, else the only one (set_hostinterface_attributes; the module matches id as a substring of the Id, here it is the whole Id).
func (*Client) SetIndicatorLED ¶ added in v0.4.0
SetIndicatorLED sets the IndicatorLED of a system or a chassis (command IndicatorLedOn, IndicatorLedOff or IndicatorLedBlink; manage_indicator_led).
func (*Client) SetManagerDateTime ¶ added in v0.6.0
func (c *Client) SetManagerDateTime(ctx context.Context, managerURI, dateTime, offset string) (Outcome, error)
SetManagerDateTime sets the DateTime (an RFC 3339 date-time) and/or the DateTimeLocalOffset (+hh:mm or -hh:mm) of a manager; an empty value is left.
func (*Client) SetManagerNIC ¶ added in v0.6.0
func (c *Client) SetManagerNIC(ctx context.Context, managerURI, addr string, config Props) (Outcome, error)
SetManagerNIC changes the EthernetInterface of a manager whose properties contain addr (case-insensitive; empty: the host of the client's URL, as the module does with its root URI); config is a flat view: a property that is an array in the interface and an object in config becomes an array of that one object (set_manager_nic, get_manager_ethernet_uri).
func (*Client) SetNTP ¶ added in v0.6.0
func (c *Client) SetNTP(ctx context.Context, managerURI string, servers []string, enabled *bool) (Outcome, error)
SetNTP sets the NTP servers and, when enabled is not nil, whether the manager uses NTP (the NTP service of SetNetworkProtocols; the redfishtool date and time commands have no Ansible row).
func (*Client) SetNetworkProtocols ¶ added in v0.6.0
func (c *Client) SetNetworkProtocols(ctx context.Context, managerURI string, services Props) (Outcome, error)
SetNetworkProtocols changes the services of a manager's NetworkProtocol resource (set_network_protocols; PatchChecked: a service the resource does not have is ErrUnsupported).
func (*Client) SetPowerRestorePolicy ¶ added in v0.4.0
func (c *Client) SetPowerRestorePolicy(ctx context.Context, systemURI, policy string) (Outcome, error)
SetPowerRestorePolicy sets it (AlwaysOn, AlwaysOff, LastState).
func (*Client) SetSecureBoot ¶ added in v0.4.0
SetSecureBoot enables or disables UEFI Secure Boot (SecureBootEnable of the system's SecureBoot resource; EnableSecureBoot is SetSecureBoot(true)).
func (*Client) SetServiceIdentification ¶ added in v0.6.0
func (c *Client) SetServiceIdentification(ctx context.Context, managerURI, serviceID string) (Outcome, error)
SetServiceIdentification sets the ServiceIdentification of a manager (set_service_identification).
func (*Client) SetSessionService ¶ added in v0.7.0
SetSessionService changes properties of the SessionService, SessionTimeout for one (set_session_service; PatchChecked).
func (*Client) SimpleUpdate ¶ added in v0.8.0
func (c *Client) SimpleUpdate(ctx context.Context, o SimpleUpdateOptions) (UpdateResult, error)
SimpleUpdate asks the service to fetch an image and update with it (simple_update): the UpdateService.SimpleUpdate action, its transfer protocol and targets checked against the allowable values (an ActionInfo resource, else the annotations). The answer is usually a task: Outcome.Monitor and Status.Handle name its monitor (WaitUpdate follows it).
func (*Client) SoftwareInventory ¶ added in v0.8.0
SoftwareInventory is FirmwareInventory for the SoftwareInventory collection (GetSoftwareInventory).
func (*Client) StorageControllerInventory ¶ added in v0.9.0
StorageControllerInventory lists the controllers of a system's Storage subsystems: the members of each Controllers collection, else the deprecated StorageControllers array (get_storage_controller_inventory). An error when the system has no Storage or the Storage collection is empty.
func (*Client) SubmitTestEvent ¶ added in v0.10.0
SubmitTestEvent runs the SubmitTestEvent action. ErrUnsupported when the service has no such action (an EventService 1.0 has SendTestEvent, another action with other semantics, which is not used). Each parameter is checked against the ActionInfo (or AllowableValues annotations) the service gives, and refused before the POST when the service does not list it.
func (*Client) SubmitTestMetricReport ¶ added in v0.14.0
func (c *Client) SubmitTestMetricReport(ctx context.Context, name string, values []TestMetricValue) (Outcome, error)
SubmitTestMetricReport runs the TelemetryService.SubmitTestMetricReport action: the service generates a metric report named name from the values and sends it to the appropriate event destinations ("immediately generate the metric report as an alert event"). Both parameters are required by the schema; the values are at most MaxMetricValues, their timestamps RFC 3339 date-times. Each parameter is checked against the ActionInfo (or AllowableValues) the service gives. ErrUnsupported when the service has no such action.
func (*Client) Subscribe ¶ added in v0.10.0
func (c *Client) Subscribe(ctx context.Context, o SubscribeOptions) (Subscription, Outcome, error)
Subscribe creates a subscription: a POST to the Subscriptions collection (DSP0266 12.1.2). The service shall answer 201 Created with the Location of the new subscription, and should return its representation; when it does not the Location is read. The Outcome says what was created.
func (*Client) Subscription ¶ added in v0.10.0
Subscription reads one subscription, named by its Id or its path.
func (*Client) Subscriptions ¶ added in v0.10.0
func (c *Client) Subscriptions(ctx context.Context) ([]Subscription, error)
Subscriptions lists the subscriptions of the service (DSP0266 12.1.2: the EventDestination resources of the Subscriptions collection; at most MaxSubscriptions). Among them are the ones the service made for the SSE connections that are open (12.5.2).
func (*Client) SystemHealthReport ¶ added in v0.4.0
SystemHealthReport is the health of a system and of its processors, memory, storage and network interfaces (get_system_health_report).
func (*Client) SystemInventory ¶ added in v0.4.0
SystemInventory is the inventory properties of a system (get_system_inventory).
func (*Client) SystemPower ¶ added in v0.4.0
SystemPower runs a power command on a system (manage_system_power).
func (*Client) SystemURIs ¶ added in v0.4.0
SystemURIs lists the ComputerSystem resources (_find_systems_resource).
func (*Client) TelemetryService ¶ added in v0.14.0
func (c *Client) TelemetryService(ctx context.Context) (TelemetryService, error)
TelemetryService reads the TelemetryService of the service (ErrUnsupported when the service root links none).
func (*Client) Triggers ¶ added in v0.14.0
Triggers lists the Triggers of the service (at most MaxTelemetryMembers); ErrUnsupported when the TelemetryService links no Triggers collection (the collection is optional).
func (*Client) TrustedComponent ¶ added in v0.15.0
func (c *Client) TrustedComponent(ctx context.Context, idOrURI string, chassis ...string) (TrustedComponent, error)
TrustedComponent reads one trusted component, named by its Id (the only one of that Id among the chassis given or all) or its path.
func (*Client) TrustedComponents ¶ added in v0.15.0
func (c *Client) TrustedComponents(ctx context.Context, chassis ...string) ([]TrustedComponent, error)
TrustedComponents lists the TrustedComponents of the chassis given by uris (of every chassis when none is given): at most MaxSecurityMembers per chassis. A chassis without a TrustedComponents collection has none. ErrUnsupported when no chassis has the collection.
func (*Client) Unsubscribe ¶ added in v0.10.0
Unsubscribe deletes a subscription, named by its Id or its path (DSP0266 12.1.2: an HTTP DELETE of the subscription's URI). A subscription that is already gone (404) is not an error: nothing changed.
func (*Client) UpdateAccountServiceProperties ¶ added in v0.7.0
UpdateAccountServiceProperties changes properties of the AccountService (update_accountservice_properties; PatchChecked: a property the resource does not have is ErrUnsupported). props must not be nil.
func (*Client) UpdateStatus ¶ added in v0.8.0
UpdateStatus reads the task or job that tracks an update (GetUpdateStatus).
func (*Client) UpdateUserAccountTypes ¶ added in v0.7.0
UpdateUserAccountTypes sets AccountTypes and/or OEMAccountTypes (update_user_accounttypes); one of them at least is required (a nil list is "not given").
func (*Client) UpdateUserName ¶ added in v0.7.0
UpdateUserName renames the account to NewUsername (update_user_name).
func (*Client) UpdateUserPassword ¶ added in v0.7.0
UpdateUserPassword sets the password of the account (update_user_password). When the service refuses to answer because the password of the user the client authenticates as must be changed (the Base.1.x.PasswordChangeRequired message, whose first argument is the account: PasswordChangeURI), the account is that one, as the module does, and the password can be changed with it.
func (*Client) UpdateUserRole ¶ added in v0.7.0
UpdateUserRole changes the RoleId of the account (update_user_role).
func (*Client) VerifyBiosAttributes ¶ added in v0.4.0
func (c *Client) VerifyBiosAttributes(ctx context.Context, systemURI string, attrs Props) (Outcome, error)
VerifyBiosAttributes checks that the BIOS holds the attributes given: an attribute it does not have, or holds with another value, is an error wrapping ErrUnsupported or ErrMismatch (verify_bios_attributes).
func (*Client) VirtualMedia ¶ added in v0.6.0
VirtualMedia lists the VirtualMedia resources of a system or a manager (get_virtualmedia); ErrUnsupported when it has none.
func (*Client) VirtualMediaEject ¶ added in v0.6.0
VirtualMediaEject ejects the image from the slot of a system or a manager that holds it (virtual_media_eject): the EjectMedia action when the slot has it, else a PATCH of Inserted and Image; an image already ejected is not an error, an image no slot holds is ErrNotFound.
func (*Client) VirtualMediaInsert ¶ added in v0.6.0
func (c *Client) VirtualMediaInsert(ctx context.Context, resURI string, o VirtualMediaOptions) (Outcome, error)
VirtualMediaInsert inserts an image in a free slot of the VirtualMedia of a system or a manager (virtual_media_insert): nothing is done when the image is already inserted; the slot is the first free one that supports one of the media types (else the first free one); the InsertMedia action is used when the slot has it, else a PATCH of Image and Inserted. Older HPE and Supermicro services that refuse Inserted and WriteProtected are asked again without them.
func (*Client) VolumeInventory ¶ added in v0.9.0
VolumeInventory lists the volumes of a system by controller (get_volume_inventory): one entry per Storage subsystem with its Controller name and its Volumes. A system without Storage is an error (a SimpleStorage has no volumes).
func (*Client) WaitAvailable ¶ added in v0.6.0
WaitAvailable blocks until the service answers (check_service_availability: the service root is read), as manage_power does with wait: it sleeps delay first (a service may answer while it shuts down), then asks every poll until timeout. The oracle's values are 30s, 5s and 120s.
func (*Client) WaitTask ¶ added in v0.3.0
func (c *Client) WaitTask(ctx context.Context, monitor string, poll time.Duration, onProgress func(Task)) (*Response, error)
WaitTask follows a task monitor until the task ends: it polls the monitor (Retry-After, else every poll, never faster than 100 ms) while it answers 202, calls onProgress with the Task each time, and returns the final response. The context bounds the wait; when the context has no deadline, Config.TaskTimeout (default DefaultTaskTimeout, one hour; negative = unbounded) does, and the error then wraps context.DeadlineExceeded. A context that has a deadline, or is cancelled, keeps its own error.
type ComponentIntegrity ¶ added in v0.15.0
type ComponentIntegrity struct {
URI string `json:"uri"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
// Type is SPDM, TPM, TCM, TPCM or OEM; TypeVersion the version of the technology.
Type string `json:"type,omitempty"`
TypeVersion string `json:"type_version,omitempty"`
// Enabled is nil when the service does not say.
Enabled *bool `json:"enabled,omitempty"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
// LastUpdated is as the service wrote it.
LastUpdated string `json:"last_updated,omitempty"`
// TargetComponentURI is the component whose integrity this reports (a
// TrustedComponent, in the DMTF mockup).
TargetComponentURI string `json:"target_component_uri,omitempty"`
ComponentsProtected []string `json:"components_protected,omitempty"`
SPDM *SPDMInfo `json:"spdm,omitempty"`
TPM *TPMInfo `json:"tpm,omitempty"`
// SPDMGetSignedMeasurements and TPMGetSignedMeasurements are true when the
// resource has the action.
SPDMGetSignedMeasurements bool `json:"spdm_get_signed_measurements"`
TPMGetSignedMeasurements bool `json:"tpm_get_signed_measurements"`
}
ComponentIntegrity is a ComponentIntegrity resource (1.5.0).
func ParseComponentIntegrity ¶ added in v0.15.0
func ParseComponentIntegrity(uri string, data []byte) (ComponentIntegrity, error)
ParseComponentIntegrity decodes a ComponentIntegrity resource read at uri. It never panics; a measurement that is not Base64 is kept with its DecodeError.
func (ComponentIntegrity) CertificateURIs ¶ added in v0.15.0
func (ci ComponentIntegrity) CertificateURIs() []string
CertificateURIs are the certificates a ComponentIntegrity links, in the order responder, requester, TPM.
type Config ¶
type Config struct {
// BaseURL is the BMC's address, https://host[:port]; a path, if any, is
// the service root (default /redfish/v1).
BaseURL string
// MetricsPath, when set, is the path of the EnvironmentMetrics resource to
// read, skipping discovery (/redfish/v1/Chassis/1/EnvironmentMetrics).
MetricsPath string
// Chassis names the chassis to read when the service has several (its Id,
// the last element of its path); empty: the first that has a reading.
Chassis string
// Credentials authenticate every request.
Credentials Credentials
// Token resumes a session opened earlier (the X-Auth-Token it returned);
// SessionURI is its Session resource, for Close. With a Token, Credentials
// may be nil: nothing but the token is sent.
Token, SessionURI string
// Session, when true, logs in once (POST to the SessionService) and sends
// X-Auth-Token; otherwise HTTP basic authentication.
Session bool
// CAFile is a PEM file of the certificate authorities that sign the BMC's
// certificate; empty: the system roots.
CAFile string
// Timeout bounds each request.
Timeout time.Duration
// TaskTimeout bounds WaitTask (and WaitUpdate) when the caller's context has
// no deadline of its own: 0 means DefaultTaskTimeout, a negative value means
// no bound but the context's cancellation.
TaskTimeout time.Duration
// HTTP overrides the transport (tests); its redirects are still refused.
HTTP *http.Client
// NoExpand forces the inventory and listing functions that read the members
// of a collection (CPUInventory, SoftwareInventory, ListUsers...) to read them
// one by one. By default they send $expand=. (DSP0266 7.3.2) when the service
// root advertises it in ProtocolFeaturesSupported, and fall back to the
// per-member reads when it does not or when the expanded answer fails.
NoExpand bool
}
Config configures a Client.
type Credentials ¶
Credentials gives the user and password to authenticate with, when they are needed: the caller resolves its secret reference there, so a password lives as long as a request.
type DeleteVolumesOptions ¶ added in v0.9.0
type DeleteVolumesOptions struct {
// DryRun resolves the volumes and deletes nothing.
DryRun bool
// OnPlan is called with the paths of the volumes to delete, before the first
// DELETE (and in a dry run).
OnPlan func(uris []string)
}
DeleteVolumesOptions tune DeleteVolumes.
type Digest ¶ added in v0.15.0
type Digest struct {
Base64 string `json:"base64"`
// Hex is the decoded value, lower-case hex (for a signed statement, the
// first 64 bytes only: see Size).
Hex string `json:"hex"`
// Size is the decoded length in bytes.
Size int `json:"size"`
}
Digest is a binary value the schemas send as Base64 (a measurement, a summary, a signed statement): kept as sent, decoded, and given as hex.
func DecodeDigest ¶ added in v0.15.0
DecodeDigest decodes a Base64 string with padding (the pattern ^[A-Za-z0-9+/]+={0,2}$ of ComponentIntegrity 1.5.0), strictly: the length is a multiple of 4 and the padding bits are zero. It is bounded by max encoded bytes.
type EnergyUnit ¶ added in v0.14.0
type EnergyUnit string
EnergyUnit is the unit of an energy series.
const ( UnitKWh EnergyUnit = "kWh" UnitWh EnergyUnit = "Wh" UnitJ EnergyUnit = "J" )
The units ReadingsFromSeries converts to kWh.
type Event ¶ added in v0.10.0
type Event struct {
// ID is the SSE id field of the event (DSP0266 12.5.2: unique in the stream).
ID string `json:"id"`
// ODataType is the @odata.type of the payload (#Event.v1_6_0.Event).
ODataType string `json:"odata_type,omitempty"`
// EventID is the Id of the payload.
EventID string `json:"event_id,omitempty"`
Name string `json:"name,omitempty"`
// Context is the context of the subscription: for an SSE stream, a string the
// service generated.
Context string `json:"context,omitempty"`
Records []EventRecord `json:"records,omitempty"`
// Report is the decoded MetricReport when the payload is one (IsMetricReport,
// DSP0266 12.5.2.2): the same type the MetricReports collection is read into
// (ParseMetricReport), so a stream of metric reports needs no second parser.
Report *MetricReport `json:"report,omitempty"`
// Data is the payload as the service sent it (JSON).
Data []byte `json:"-"`
// Err is set, with the other fields empty but ID and Data, when the payload
// could not be decoded: one bad event does not end the stream.
Err error `json:"-"`
}
Event is the payload of an event: the Event resource of the schema, or a MetricReport (DSP0266 12.5.2.2) whose records are not decoded.
func ParseEvent ¶ added in v0.10.0
ParseEvent decodes the data of an event of an SSE stream (DSP0266 12.5.2.1: the JSON representation of the Event object; 12.5.2.2: of a MetricReport). It never panics and refuses what is larger than MaxEventBytes or holds more than MaxEventRecords records.
func (Event) IsMetricReport ¶ added in v0.10.0
IsMetricReport reports whether the payload is a MetricReport and not an Event.
type EventRecord ¶ added in v0.10.0
type EventRecord struct {
MemberID string `json:"member_id,omitempty"`
EventType string `json:"event_type,omitempty"`
EventID string `json:"event_id,omitempty"`
EventGroupID *int64 `json:"event_group_id,omitempty"`
EventTimestamp string `json:"event_timestamp,omitempty"`
Severity string `json:"severity,omitempty"`
MessageSeverity string `json:"message_severity,omitempty"`
Message string `json:"message,omitempty"`
MessageID string `json:"message_id,omitempty"`
MessageArgs []string `json:"message_args,omitempty"`
// OriginOfCondition is the @odata.id of the origin, when the service sends one.
OriginOfCondition string `json:"origin_of_condition,omitempty"`
Context string `json:"context,omitempty"`
}
EventRecord is one entry of the Events array of an Event (Event 1.14.0 EventRecord).
type EventService ¶ added in v0.10.0
type EventService struct {
URI string `json:"uri"`
// ServiceEnabled is nil when the service does not say. When false, events are no
// longer published and an SSE connection cannot be opened.
ServiceEnabled *bool `json:"service_enabled,omitempty"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
// SubscriptionsURI is the EventDestinationCollection.
SubscriptionsURI string `json:"subscriptions_uri,omitempty"`
// ServerSentEventURI is the SSE endpoint (ServerSentEventUri, DSP0266 12.1.3);
// empty when the service has none.
ServerSentEventURI string `json:"server_sent_event_uri,omitempty"`
// EventFormatTypes are the formats a subscription may ask for (Event,
// MetricReport); empty: Event only (the schema's default).
EventFormatTypes []string `json:"event_format_types,omitempty"`
// RegistryPrefixes, ResourceTypes and Severities are the values a subscription
// may use; empty means the service does not support that kind of filter.
RegistryPrefixes []string `json:"registry_prefixes,omitempty"`
ResourceTypes []string `json:"resource_types,omitempty"`
Severities []string `json:"severities,omitempty"`
// SSEFilterProperties are the properties of SSEFilterPropertiesSupported: which
// $filter criteria the SSE URI accepts (EventFormatType, MessageId,
// OriginResource, RegistryPrefix, ResourceType, SubordinateResources...).
SSEFilterProperties map[string]bool `json:"sse_filter_properties,omitempty"`
// Capability flags; nil when the service does not say.
SSEIncludeOriginOfCondition *bool `json:"sse_include_origin_of_condition,omitempty"`
IncludeOriginOfConditionSupported *bool `json:"include_origin_of_condition_supported,omitempty"`
SubordinateResourcesSupported *bool `json:"subordinate_resources_supported,omitempty"`
OriginResourcesSupported *bool `json:"origin_resources_supported,omitempty"`
ExcludeMessageID *bool `json:"exclude_message_id,omitempty"`
ExcludeRegistryPrefix *bool `json:"exclude_registry_prefix,omitempty"`
DeliveryRetryAttempts *int64 `json:"delivery_retry_attempts,omitempty"`
DeliveryRetryIntervalSeconds *int64 `json:"delivery_retry_interval_seconds,omitempty"`
// SubmitTestEvent is true when the service has the action.
SubmitTestEvent bool `json:"submit_test_event"`
}
EventService is the EventService resource (EventService 1.12.0), what a client reads to know the control properties a subscription may use (DSP0266 12.1.5: "Clients can read the EventService resource of a service in order to determine what control properties ... are supported").
type EventStream ¶ added in v0.10.0
type EventStream struct {
// C delivers the events; it is closed when the stream ends. Then Err says why.
C <-chan Event
// contains filtered or unexported fields
}
EventStream is an open stream of events.
func (*EventStream) Close ¶ added in v0.10.0
func (s *EventStream) Close()
Close ends the stream and waits for it.
func (*EventStream) Err ¶ added in v0.10.0
func (s *EventStream) Err() error
Err is why the stream ended: nil for a cancelled context, a Close or a clean end by the service. Valid once C is closed.
type EventsOptions ¶ added in v0.10.0
type EventsOptions struct {
// Filter is the $filter expression of the SSE URI (DSP0266 12.5.2), for
// instance `MessageId eq 'Contoso.1.0.TempAssert'` or
// `(RegistryPrefix eq 'Resource') or (RegistryPrefix eq 'Task')`. The service
// applies it; the client only checks that it is a reasonable text and that
// the properties it names are ones the service says it supports.
Filter string
// MaxLine and MaxEvent bound a line and an event (default MaxSSELine and
// MaxEventBytes): a larger one ends the stream with ErrEventTooLarge.
MaxLine, MaxEvent int
// MaxReconnects is how many times a broken connection is reopened with
// Last-Event-ID (default 0: never).
MaxReconnects int
// Buffer is the capacity of the channel (default 16): a reader that does not
// keep up holds the connection, nothing grows.
Buffer int
}
EventsOptions tune an event stream.
type Expand ¶ added in v0.12.0
type Expand struct {
// Kind is which hyperlinks to expand; the zero value is the period.
Kind ExpandKind
// Levels is $levels; 0 and 1 are the default, one level, and send no $levels.
Levels int
}
Expand is the $expand parameter (DSP0266 7.3.2).
type ExpandKind ¶ added in v0.12.0
type ExpandKind int
ExpandKind is the option of $expand that says which hyperlinks are expanded (DSP0266 7.3.2 Table 8). The zero value is the period.
const ( // ExpandNoLinks is the period: the hyperlinks that are not in a Links property. ExpandNoLinks ExpandKind = iota // ExpandLinks is the tilde: the hyperlinks of the Links properties. ExpandLinks // ExpandAll is the asterisk: every hyperlink. ExpandAll )
The options of $expand.
func (ExpandKind) String ¶ added in v0.12.0
func (k ExpandKind) String() string
type Identifier ¶ added in v0.11.0
type Identifier struct {
CommonName string `json:"common_name,omitempty"`
Organization string `json:"organization,omitempty"`
OrganizationalUnit string `json:"organizational_unit,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Country string `json:"country,omitempty"`
Email string `json:"email,omitempty"`
DisplayString string `json:"display_string,omitempty"`
AlternativeNames []string `json:"alternative_names,omitempty"`
}
Identifier is the Issuer or the Subject of a Certificate (Certificate 1.11.0, Identifier), as the service states it.
type Interval ¶ added in v0.2.0
type Interval struct {
Start, End time.Time
// Valid is true when KWh is the energy of the interval. When false, the
// energy is unknown, KWh is 0 and Reason says why: the caller should fall
// back (a calibrated factor, say), never bill 0 as a measurement.
Valid bool
Reason string
KWh float64
Source Source
}
Interval is the energy a node used between two successive reads.
type KeyPolicy ¶ added in v0.15.0
type KeyPolicy struct {
URI string `json:"uri"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
IsDefault *bool `json:"is_default,omitempty"`
// The allow lists of the NVMeoF object, as the service wrote them.
CipherSuites []string `json:"cipher_suite_allow_list,omitempty"`
DHGroups []string `json:"dh_group_allow_list,omitempty"`
SecureHashes []string `json:"secure_hash_allow_list,omitempty"`
SecurityProtocols []string `json:"security_protocol_allow_list,omitempty"`
OEMProtocols []string `json:"oem_security_protocol_allow_list,omitempty"`
SecurityTransports []string `json:"security_transport_allow_list,omitempty"`
}
KeyPolicy is a KeyPolicy resource (1.0.1), NVMe-oF type.
type KeyService ¶ added in v0.15.0
type KeyService struct {
URI string `json:"uri"`
// NVMeoFSecretsURI and NVMeoFKeyPoliciesURI are its two collections.
NVMeoFSecretsURI string `json:"nvmeof_secrets_uri,omitempty"`
NVMeoFKeyPoliciesURI string `json:"nvmeof_key_policies_uri,omitempty"`
}
KeyService is the KeyService resource (1.0.1).
type LinkedCertificate ¶ added in v0.15.0
type LinkedCertificate struct {
URI string `json:"uri"`
Certificate *Certificate `json:"certificate,omitempty"`
Error string `json:"error,omitempty"`
}
LinkedCertificate is a certificate a resource links: the Certificate resource as certs.go reads it (decoded with ParseX509), or why it could not be read.
type LogEntries ¶ added in v0.6.0
type LogEntries struct {
// Service is the LogService resource.
Service string
// Description is the one of the Entries collection ("Collection of log
// entries" when it has none).
Description string
Entries []Props
}
LogEntries is the entries of one LogService.
type ManagerEntry ¶ added in v0.6.0
ManagerEntry is what a read returned for one manager (the oracle's aggregate_managers: a manager_uri and its entries).
type Measurement ¶ added in v0.15.0
type Measurement struct {
// Index is the SPDM measurement index; PCR the TPM register: one is set.
Index *int64 `json:"index,omitempty"`
PCR *int64 `json:"pcr,omitempty"`
// Type is the SPDM DMTFmeasurementTypes value as sent (ImmutableROM,
// MutableFirmware...), empty for a TPM measurement.
Type string `json:"type,omitempty"`
HashAlgorithm string `json:"hash_algorithm,omitempty"`
// Measurement is the value; nil, with DecodeError, when it is not a valid
// Base64 string.
Measurement *Digest `json:"measurement,omitempty"`
DecodeError string `json:"decode_error,omitempty"`
// SizeMatches is whether the value has the length of HashAlgorithm; nil when
// the algorithm is not one this client knows.
SizeMatches *bool `json:"size_matches_algorithm,omitempty"`
// PartOfSummary is PartofSummaryHash (SPDM).
PartOfSummary *bool `json:"part_of_summary,omitempty"`
// SecurityVersionNumber is an 8-byte hex string, only for a
// MutableFirmwareSecurityVersionNumber measurement (SPDM).
SecurityVersionNumber string `json:"security_version_number,omitempty"`
LastUpdated string `json:"last_updated,omitempty"`
}
Measurement is one measurement of a set, SPDM (Index, Type...) or TPM (PCR).
type Message ¶ added in v0.3.0
type Message struct {
MessageID string `json:"MessageId"`
Message string `json:"Message"`
Severity string `json:"Severity"`
Resolution string `json:"Resolution"`
MessageArgs []string `json:"MessageArgs"`
RelatedProperties []string `json:"RelatedProperties"`
}
Message is one Message object (Message.v1_x, DSP8010): an entry of @Message.ExtendedInfo.
func ParseError ¶ added in v0.3.0
ParseError decodes the error object of an answer (and the top-level @Message.ExtendedInfo of a success): the code, the message and the extended information, bounded. A body that is not that JSON gives empty values.
type Meter ¶ added in v0.2.0
type Meter struct {
// MaxGap is the longest time between two power samples that is integrated;
// 0 means 5 minutes. It does not apply to a counter.
MaxGap time.Duration
// contains filtered or unexported fields
}
Meter turns the successive Readings of one BMC into intervals. It is not safe for concurrent use.
With an energy counter the interval is the counter's difference: a counter is cumulative, so a missed read loses nothing. With only a power, the energy is the trapezoid (P0 + P1) / 2 × dt between two samples; samples further apart than MaxGap are not joined, since the power in between is unknown.
func (*Meter) Observe ¶ added in v0.2.0
Observe records a read and returns the interval since the previous one. ok is false for the first read (the baseline). A read that cannot be used returns an invalid Interval, and becomes the new baseline when it carries a sample, so the next interval starts there.
type MetricDefinition ¶ added in v0.14.0
type MetricDefinition struct {
URI string `json:"uri"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
// MetricType is Numeric, Discrete, Gauge, Counter, Countdown or String;
// MetricDataType Boolean, DateTime, Decimal, Integer, String or Enumeration;
// Implementation PhysicalSensor, Calculated, Synthesized or DigitalMeter.
MetricType string `json:"metric_type,omitempty"`
MetricDataType string `json:"metric_data_type,omitempty"`
Implementation string `json:"implementation,omitempty"`
// Units follow the Unified Code for Units of Measure (MetricDefinition.Units).
Units string `json:"units,omitempty"`
PhysicalContext string `json:"physical_context,omitempty"`
MetricProperties []string `json:"metric_properties,omitempty"`
Wildcards []Wildcard `json:"wildcards,omitempty"`
SensingInterval string `json:"sensing_interval,omitempty"`
DiscreteValues []string `json:"discrete_values,omitempty"`
MinReadingRange *float64 `json:"min_reading_range,omitempty"`
MaxReadingRange *float64 `json:"max_reading_range,omitempty"`
// CalculationAlgorithm is set for a Calculated or Synthesized metric.
CalculationAlgorithm string `json:"calculation_algorithm,omitempty"`
}
MetricDefinition is a MetricDefinition resource (MetricDefinition 1.3.6): the metadata of a metric.
func ParseMetricDefinition ¶ added in v0.14.0
func ParseMetricDefinition(uri string, data []byte) (MetricDefinition, error)
ParseMetricDefinition decodes a MetricDefinition resource read at uri.
type MetricReport ¶ added in v0.14.0
type MetricReport struct {
// URI is the @odata.id of the report; ID, Name and ODataType are its Id, Name
// and @odata.type.
URI string `json:"uri,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ODataType string `json:"odata_type,omitempty"`
// Timestamp is when the report was generated (MetricReport.Timestamp, 1.1),
// nil when absent or not a date-time; TimestampRaw is the text as sent.
Timestamp *time.Time `json:"timestamp,omitempty"`
TimestampRaw string `json:"timestamp_raw,omitempty"`
// DefinitionURI is the MetricReportDefinition of the report.
DefinitionURI string `json:"definition_uri,omitempty"`
// Context is the context the subscriber gave (present in an event, 1.4).
Context string `json:"context,omitempty"`
Values []MetricValue `json:"values,omitempty"`
}
MetricReport is a MetricReport (MetricReport 1.5.2): a set of collected metrics, read from the MetricReports collection or received over SSE (DSP0266 12.5.2.2).
func ParseMetricReport ¶ added in v0.14.0
func ParseMetricReport(data []byte) (MetricReport, error)
ParseMetricReport decodes a MetricReport document: a resource of the collection, or the data field of a metric report SSE event. It never panics, and refuses a document larger than MaxMetricReportBytes, one with more than MaxMetricValues values, and a value that is not an object. A value that is a string, a number, a boolean or null is read as MetricValue says; a timestamp that is not an RFC 3339 date-time is kept as text and has no Timestamp.
func (MetricReport) TimeSeries ¶ added in v0.14.0
func (r MetricReport) TimeSeries() (series []Series, skipped []MetricValue)
TimeSeries turns the values of a report into time series, one per (MetricID, MetricProperty) in the order they first appear, each sorted by timestamp (the way MetricValue.Timestamp says a time series is established; equal timestamps keep the report's order). A value with no timestamp or no number is not in a series: it is returned in skipped, never made into a 0 or given the report's time.
type MetricReportDefinition ¶ added in v0.14.0
type MetricReportDefinition struct {
URI string `json:"uri"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
// Type is Periodic, OnChange or OnRequest (MetricReportDefinitionType); a
// Periodic definition has a Schedule.
Type string `json:"type,omitempty"`
// Enabled is nil when the service does not say (MetricReportDefinition 1.2).
Enabled *bool `json:"enabled,omitempty"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
Schedule *ReportSchedule `json:"schedule,omitempty"`
// Interval is the Schedule's RecurrenceInterval as a duration, nil when there
// is none or it is not a duration.
Interval *time.Duration `json:"-"`
Metrics []MetricSpec `json:"metrics,omitempty"`
// MetricProperties and Wildcards are the definition-level properties of the
// schema, alongside Metrics.
MetricProperties []string `json:"metric_properties,omitempty"`
Wildcards []Wildcard `json:"wildcards,omitempty"`
// ReportActions are LogToMetricReportsCollection and RedfishEvent: what is done
// with a report when it is generated.
ReportActions []string `json:"report_actions,omitempty"`
// ReportUpdates is Overwrite, AppendWrapsWhenFull, AppendStopsWhenFull or
// NewReport; AppendLimit is the entries an appended report holds.
ReportUpdates string `json:"report_updates,omitempty"`
AppendLimit *int64 `json:"append_limit,omitempty"`
ReportTimespan string `json:"report_timespan,omitempty"`
SuppressRepeatedMetricValue *bool `json:"suppress_repeated_metric_value,omitempty"`
HeartbeatInterval string `json:"heartbeat_interval,omitempty"`
// MetricReportURI is the most recent report the definition produced.
MetricReportURI string `json:"metric_report_uri,omitempty"`
// TriggerURIs are Links.Triggers.
TriggerURIs []string `json:"trigger_uris,omitempty"`
}
MetricReportDefinition is a MetricReportDefinition resource (MetricReportDefinition 1.4.7): which metrics are collected into a report, and when.
func ParseMetricReportDefinition ¶ added in v0.14.0
func ParseMetricReportDefinition(uri string, data []byte) (MetricReportDefinition, error)
ParseMetricReportDefinition decodes a MetricReportDefinition resource read at uri.
type MetricReportDefinitionInput ¶ added in v0.14.0
type MetricReportDefinitionInput struct {
// ID is the Id the definition asks for (the service may assign another); Name
// defaults to the ID.
ID, Name string
// Type is Periodic, OnChange or OnRequest (required). A Periodic definition
// needs Schedule.RecurrenceInterval ("If the value is Periodic, the Schedule
// property shall be present").
Type string
Schedule *ReportSchedule
// Metrics is what the report holds (required); each entry names a MetricID that
// a MetricDefinition of the service has, or MetricProperties, and may apply a
// CollectionFunction the service supports.
Metrics []MetricSpec
// ReportActions are LogToMetricReportsCollection and RedfishEvent.
ReportActions []string
// ReportUpdates is Overwrite, AppendWrapsWhenFull, AppendStopsWhenFull or
// NewReport; AppendLimit is required for the two Append values.
ReportUpdates string
AppendLimit *int64
ReportTimespan string
SuppressRepeatedMetricValue *bool
// Enabled is MetricReportDefinitionEnabled; nil: not sent.
Enabled *bool
}
MetricReportDefinitionInput describes a metric report definition to create (MetricReportDefinition 1.4.7). CreateMetricReportDefinition checks it against the schema's enumerations and against the TelemetryService before anything is sent.
type MetricSpec ¶ added in v0.14.0
type MetricSpec struct {
MetricID string `json:"metric_id,omitempty"`
MetricProperties []string `json:"metric_properties,omitempty"`
// CollectionFunction is Average, Maximum, Minimum or Summation; empty: no
// calculation. CollectionTimeScope is Point, Interval or StartupInterval and
// CollectionDuration the duration the function covers.
CollectionFunction string `json:"collection_function,omitempty"`
CollectionTimeScope string `json:"collection_time_scope,omitempty"`
CollectionDuration string `json:"collection_duration,omitempty"`
}
MetricSpec is one entry of the Metrics of a metric report definition (MetricReportDefinition 1.4.7 Metric): the metrics of a MetricDefinition (MetricID) or properties named by URI (MetricProperties), the one or the other ("should not be present" with the other), and the calculation applied.
type MetricValue ¶ added in v0.14.0
type MetricValue struct {
// MetricID is the Id of the MetricDefinition that describes the metric;
// MetricProperty the URI, in JSON pointer notation, of the property it comes
// from (MetricReport 1.5.2 MetricProperty: "may contain additional
// calculations performed on the property").
MetricID string `json:"metric_id,omitempty"`
MetricProperty string `json:"metric_property,omitempty"`
// Raw is the value as the service sent it: the schema has a string (a number
// converted to its string, a boolean as true or false, an array as a JSON
// string); a JSON number or boolean where a string was expected is kept as its
// text. Empty when Null.
Raw string `json:"raw"`
// Null: the service sent null, or no value.
Null bool `json:"null,omitempty"`
// Number is set only when Raw is a number (ParseMetricNumber); nil otherwise:
// a value that is not a number is not 0.
Number *float64 `json:"number,omitempty"`
// Timestamp is when the metric was obtained, nil when the service sent none or
// not an RFC 3339 date-time; TimestampRaw is the text as sent.
Timestamp *time.Time `json:"timestamp,omitempty"`
TimestampRaw string `json:"timestamp_raw,omitempty"`
}
MetricValue is one entry of MetricValues (MetricReport 1.5.2 MetricValue).
func (MetricValue) Float ¶ added in v0.14.0
func (v MetricValue) Float() (float64, error)
Float is the value as a number; an error wrapping ErrNotNumeric when it is null or not a number.
type Metrics ¶
Metrics is what a document says of a node's consumption.
func ParseEnvironmentMetrics ¶
ParseEnvironmentMetrics reads an EnvironmentMetrics document (also the shape of a Chassis that embeds the same properties): EnergykWh.Reading, else EnergyJoules.Reading converted to kWh, and PowerWatts.Reading. A reading that is null, negative, not finite or out of range is dropped; a document that is not a JSON object is ErrMalformed. Nothing is invented: a document without any usable reading yields an empty Metrics and no error.
type NVMeoFSecret ¶ added in v0.15.0
type NVMeoFSecret struct {
URI string `json:"uri"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
KeyType string `json:"key_type,omitempty"`
UserDescription string `json:"user_description,omitempty"`
// KeyPresent is true when the service returned KeyString (the schema has no
// way to withhold it; the key is not kept).
KeyPresent bool `json:"key_present"`
// NQN is the NVMe Qualified Name of the host or target subsystem.
NQN string `json:"nqn,omitempty"`
HostKeyID string `json:"host_key_id,omitempty"`
SecurityProtocolType string `json:"security_protocol_type,omitempty"`
OEMSecurityProtocol string `json:"oem_security_protocol_type,omitempty"`
SecureHashAllowList []string `json:"secure_hash_allow_list,omitempty"`
}
NVMeoFSecret is a Key (1.4.1) of KeyService.NVMeoFSecrets, WITHOUT its key: KeyString is the key material. It is read from the answer to know it is there (KeyPresent) and then dropped: it is not a field, is never printed and is not in any error.
func ParseNVMeoFSecret ¶ added in v0.15.0
func ParseNVMeoFSecret(uri string, data []byte) (NVMeoFSecret, error)
ParseNVMeoFSecret decodes a Key resource read at uri.
type Outcome ¶ added in v0.4.0
type Outcome struct {
// Changed is false when the resource already had the requested state.
Changed bool
Message string
// Warning is a non-fatal remark (attributes the BIOS does not have).
Warning string
// Monitor is the task monitor when the service answered 202 (see WaitTask).
Monitor string
}
Outcome is what a command that changes something did.
type ParameterSet ¶ added in v0.15.0
type ParameterSet struct {
Versions []string `json:"versions,omitempty"`
AEAD []string `json:"aead,omitempty"`
BaseAsym []string `json:"base_asym,omitempty"`
BaseHash []string `json:"base_hash,omitempty"`
CipherSuites []string `json:"cipher_suites,omitempty"`
SignatureAlgorithms []string `json:"signature_algorithms,omitempty"`
}
ParameterSet is an allowed or denied set of an SPDM or TLS policy: versions and algorithms, as the service wrote them (SPDM: AEAD, BaseAsym, BaseHash; TLS: CipherSuites, SignatureAlgorithms).
type PolicyCertificates ¶ added in v0.15.0
type PolicyCertificates struct {
// Collection names it: spdm.trusted, spdm.revoked, tls_client.trusted...
Collection string `json:"collection"`
URI string `json:"uri"`
Certificates []Certificate `json:"certificates"`
}
PolicyCertificates are the certificates a SecurityPolicy lists, by collection.
type Props ¶ added in v0.4.0
Props is the properties of a resource.
func BuildVolumePayload ¶ added in v0.9.0
BuildVolumePayload is the POST body of a volume: the details with Drives moved to Links.Drives as @odata.id objects (create_volume). RAIDType and at least one drive are required; a drive must be a path of the service.
func NetworkProtocolPayload ¶ added in v0.6.0
NetworkProtocolPayload checks the services to set and builds the payload (set_network_protocols): a service must be one of ProtocolServices; ProtocolEnabled (or protocolenabled) takes true/false, "true"/"false", "True"/"False", "on"/"off" or 1/0; Port (or port) an integer or a string of digits (the module also lets a boolean through as an integer: refused here); any other property goes as it is.
func ParseController ¶ added in v0.9.0
ParseController keeps the inventory properties of a storage controller (a StorageController resource or an element of Storage.StorageControllers).
func ParseDrive ¶ added in v0.9.0
ParseDrive decodes a Drive: its inventory properties, RedfishURI (its @odata.id, else uri) and, from Links.Volumes, the Volumes it belongs to (get_disk_inventory).
func ParseLogEntries ¶ added in v0.6.0
ParseLogEntries decodes one page of a LogEntry collection: its Description, its members (as they are) and the link to the next page.
func ParseVolume ¶ added in v0.9.0
ParseVolume decodes a Volume: its inventory properties and, from Links.Drives, Linked_drives, the Ids of the drives it uses (get_volume_inventory).
type ProtocolFeatures ¶ added in v0.12.0
type ProtocolFeatures struct {
// Advertised: the root has a ProtocolFeaturesSupported object.
Advertised bool
// ExpandQuery: ExpandAll is the asterisk, ExpandLinks the tilde, ExpandNoLinks
// the period, ExpandLevels $levels (to MaxLevels, 0 when the root gives none).
ExpandAll, ExpandLevels, ExpandLinks, ExpandNoLinks bool
MaxLevels int
// ExcerptQuery, FilterQuery, OnlyMemberQuery, SelectQuery and TopSkipQuery
// (both $top and $skip) are the booleans of the same names.
Excerpt, Filter, Only, Select, TopSkip bool
// FilterComparison and FilterCompound are FilterQueryComparisonOperations and
// FilterQueryCompoundOperations; nil when the root does not say (a service
// older than ServiceRoot 1.17.0), in which case FilterQuery alone decides.
FilterComparison, FilterCompound *bool
}
ProtocolFeatures is what the service root says it implements (the ProtocolFeaturesSupported object, DSP0266 7.3.1; ServiceRoot 1.22.0). The zero value is a service that advertises nothing: no parameter is then sent.
func ParseProtocolFeatures ¶ added in v0.12.0
func ParseProtocolFeatures(root []byte) (ProtocolFeatures, error)
ParseProtocolFeatures reads ProtocolFeaturesSupported out of a service root. A root without one is not an error: nothing is advertised. A property of another type than the schema's is taken as not advertised.
type PushOptions ¶ added in v0.8.0
type PushOptions struct {
// ImageFile is the image to send (required): a regular file, streamed, never
// held whole in memory.
ImageFile string
Targets []string
ApplyTime string
// OEMParams is the Oem object of UpdateParameters.
OEMParams Props
// CustomHeader names an extra part of the upload (a form-data name of letters,
// digits, dot, underscore and hyphen, not UpdateParameters or UpdateFile) that
// holds CustomParams, of media type CustomMIMEType (default text/plain).
CustomHeader, CustomMIMEType, CustomParams string
// MaxSize is the largest image accepted, in bytes (default DefaultMaxImage);
// a larger file is ErrImageTooLarge, and nothing is sent.
MaxSize int64
// Timeout bounds the whole upload (default DefaultUploadTimeout).
Timeout time.Duration
}
PushOptions are the options of MultipartHTTPPushUpdate (the module's update_image_file, update_targets, update_apply_time, update_oem_params and update_custom_oem_*).
type Query ¶ added in v0.12.0
type Query struct {
// Expand is $expand.
Expand *Expand
// Select is $select: property names, or paths joined by a slash.
Select []string
// Top and Skip are $top and $skip, on a resource collection; both are one
// feature, TopSkipQuery.
Top, Skip *int
// Only is only: a collection of exactly one member answers with that member.
// It cannot be combined with another parameter (DSP0266 7.3.1 Table 7).
Only bool
// Excerpt is excerpt: the properties the schema's Excerpt annotation names.
Excerpt bool
// Filter is $filter, on a resource collection; the grammar of 7.3.4 is
// checked before anything is sent.
Filter string
}
Query is the set of query parameters of a read (DSP0266 7.3). Each is sent only when the service advertises it in ProtocolFeaturesSupported; otherwise the read is refused with ErrUnsupported and nothing is sent. The zero value sends none.
func (Query) Encode ¶ added in v0.12.0
func (q Query) Encode(f ProtocolFeatures) (string, error)
Encode validates the query against what the service advertises and returns the query string (without the question mark), "" for the zero Query. The parameters come in the order the service processes them (DSP0266 7.3.1: $filter, $skip, $top, $expand, excerpt, $select). The names keep their dollar sign and the values are percent-encoded so that nothing but the intended parameters can appear (a value cannot hold an ampersand, a hash or a space); url.Values would send %24expand and a plus for each space, which services are not required to decode.
type Reading ¶
type Reading struct {
Chassis string
At time.Time
// EnergyKWh is the chassis' energy counter (EnvironmentMetrics.EnergykWh,
// or EnergyJoules converted), nil when the BMC has none.
EnergyKWh *float64
// PowerWatts is the power consumed, nil when the BMC reports none; read
// only when there is no energy counter.
PowerWatts *float64
}
Reading is one read of a node's consumption: the energy counter when the BMC has one, else a power. Chassis is the resource it came from.
func ReadingsFromSeries ¶ added in v0.14.0
func ReadingsFromSeries(chassis string, energy *Series, unit EnergyUnit, power *Series) ([]Reading, error)
ReadingsFromSeries turns series of a MetricReport into the Readings a Meter observes, for a caller that wants to feed one: it is opt-in, and changes neither Read nor the Meter. The caller says which series is an energy counter (and its unit: the metric definition's Units says which) and which is a power in watts; either may be nil. Points of the two series at the same instant make one Reading; the result is sorted by time. The Meter decides what a Reading is worth (a reset, a gap, a counter that went down): this only converts and orders, and refuses a value that is negative, not finite or a unit it does not know.
type RekeyOptions ¶ added in v0.11.0
type RekeyOptions struct {
KeyPairAlgorithm string
KeyBitLength int
KeyCurveID string
ChallengePassword Secret
}
RekeyOptions are the parameters of Certificate.Rekey (1.11.0).
type ReportSchedule ¶ added in v0.14.0
type ReportSchedule struct {
// RecurrenceInterval is the duration between two reports (PT10S).
RecurrenceInterval string `json:"recurrence_interval,omitempty"`
InitialStartTime string `json:"initial_start_time,omitempty"`
MaxOccurrences *int64 `json:"max_occurrences,omitempty"`
Lifetime string `json:"lifetime,omitempty"`
Name string `json:"name,omitempty"`
}
ReportSchedule is the Schedule of a metric report definition (Schedule 1.2.5).
type Request ¶ added in v0.3.0
type Request struct {
Method string // GET, PATCH, PUT, POST, DELETE, HEAD
// Path is a path of the service, /redfish/... (a next link or a Location
// header's path); never a URL.
Path string
Body []byte // a JSON document, sent as is
// IfMatch is the ETag the resource must still have (PATCH, PUT, DELETE).
IfMatch string
// Header adds headers. Authorization, X-Auth-Token, Host and
// Content-Length are refused: the client alone authenticates.
Header map[string]string
}
Request is one operation.
type ResetRequest ¶ added in v0.8.0
ResetRequest is a reset a Base.ResetRequired message asks for.
type Response ¶ added in v0.3.0
Response is an answer with a 2xx status.
func (*Response) ETag ¶ added in v0.3.0
ETag is the entity tag of the resource the answer describes ("" if none).
func (*Response) IsTask ¶ added in v0.3.0
IsTask reports whether the operation continues as a task (202).
func (*Response) Location ¶ added in v0.3.0
Location is the Location header: the new resource of a 201, or the task monitor of a 202 (a path of the service, "" if it is anything else).
func (*Response) RetryAfter ¶ added in v0.3.0
RetryAfter is the delay the service asked for (seconds or an HTTP date), 0 when it asked for none; bounded to an hour.
type SPDMInfo ¶ added in v0.15.0
type SPDMInfo struct {
// RequesterURI is the component that reports the integrity.
RequesterURI string `json:"requester_uri,omitempty"`
MeasurementSpecification string `json:"measurement_specification,omitempty"`
// Summary is the measurement summary; SummaryType TCB or All.
Summary *Digest `json:"measurement_summary,omitempty"`
SummaryError string `json:"measurement_summary_error,omitempty"`
SummaryHashAlgorithm string `json:"measurement_summary_hash_algorithm,omitempty"`
SummaryType string `json:"measurement_summary_type,omitempty"`
Measurements []Measurement `json:"measurements,omitempty"`
// The certificate links of the identity authentication, and the status of
// the verification of the responder's identity (Success or Failed).
ResponderCertificateURI string `json:"responder_certificate_uri,omitempty"`
ResponderVerification string `json:"responder_verification_status,omitempty"`
RequesterCertificateURI string `json:"requester_certificate_uri,omitempty"`
Sessions []Session `json:"sessions,omitempty"`
}
SPDMInfo is the SPDM object of a ComponentIntegrity: what the SPDM Requester reports of the SPDM Responder.
type SPDMPolicy ¶ added in v0.15.0
type SPDMPolicy struct {
Enabled *bool `json:"enabled,omitempty"`
SecureSessionEnabled *bool `json:"secure_session_enabled,omitempty"`
VerifyCertificate *bool `json:"verify_certificate,omitempty"`
AllowExtendedAlgorithms *bool `json:"allow_extended_algorithms,omitempty"`
Allowed *ParameterSet `json:"allowed,omitempty"`
Denied *ParameterSet `json:"denied,omitempty"`
TrustedCertificatesURI string `json:"trusted_certificates_uri,omitempty"`
RevokedCertificatesURI string `json:"revoked_certificates_uri,omitempty"`
}
SPDMPolicy is the SPDM object of a SecurityPolicy.
type SSEMessage ¶ added in v0.10.0
type SSEMessage struct {
// ID is the last event ID of the stream when the event was dispatched (the
// id field: HTML 9.2.6 keeps it from an event to the next).
ID string
// Type is the event field, "message" when the event has none.
Type string
// Data is the data field, its lines joined by LF.
Data []byte
}
SSEMessage is one dispatched event of a stream.
type SSEReader ¶ added in v0.10.0
type SSEReader struct {
// contains filtered or unexported fields
}
SSEReader parses an event stream.
func NewSSEReader ¶ added in v0.10.0
NewSSEReader reads the events of r. A limit that is not above 0 is the default (MaxSSELine, MaxEventBytes).
func (*SSEReader) LastID ¶ added in v0.10.0
LastID is the last event ID seen: what a reconnection sends in Last-Event-ID.
func (*SSEReader) Next ¶ added in v0.10.0
func (s *SSEReader) Next() (SSEMessage, error)
Next returns the next event. At the end of the stream it returns io.EOF (an event that a blank line did not complete is dropped); a read error is returned as it is.
type Secret ¶ added in v0.7.0
type Secret string
Secret is a password: it never shows itself.
func (Secret) MarshalJSON ¶ added in v0.7.0
MarshalJSON is "[redacted]": the payload sent to a service is built from Reveal.
func (Secret) MarshalText ¶ added in v0.7.0
MarshalText is "[redacted]" (encoding.TextMarshaler, used by log encoders).
type SecurityPolicy ¶ added in v0.15.0
type SecurityPolicy struct {
URI string `json:"uri"`
ManagerURI string `json:"manager_uri,omitempty"`
Name string `json:"name,omitempty"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
OverrideParentManager *bool `json:"override_parent_manager,omitempty"`
// SPDM is nil when the policy has no SPDM object; TLSClient and TLSServer
// are the manager acting as a TLS client or server.
SPDM *SPDMPolicy `json:"spdm,omitempty"`
TLSClient *TLSPolicy `json:"tls_client,omitempty"`
TLSServer *TLSPolicy `json:"tls_server,omitempty"`
}
SecurityPolicy is the SecurityPolicy resource of a manager (1.1.0).
func ParseSecurityPolicy ¶ added in v0.15.0
func ParseSecurityPolicy(uri string, data []byte) (SecurityPolicy, error)
ParseSecurityPolicy decodes a SecurityPolicy resource read at uri.
type Series ¶ added in v0.14.0
type Series struct {
MetricID string `json:"metric_id,omitempty"`
MetricProperty string `json:"metric_property,omitempty"`
Points []Point `json:"points"`
}
Series is the samples of one metric property of a report, sorted by time.
type ServiceRoot ¶
ServiceRoot is what discovery reads of /redfish/v1/.
type Session ¶ added in v0.15.0
type Session struct {
ID *int64 `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
}
Session is a SingleSessionInfo.
type SignedMeasurements ¶ added in v0.15.0
type SignedMeasurements struct {
ComponentIntegrityURI string `json:"component_integrity_uri"`
// Nonce is the nonce sent (given or generated).
Nonce string `json:"nonce"`
// Version is the SPDM version used; SigningAlgorithm, HashingAlgorithm and
// AdditionalSigningAlgorithms are the names the service gives.
Version string `json:"version,omitempty"`
SigningAlgorithm string `json:"signing_algorithm,omitempty"`
HashingAlgorithm string `json:"hashing_algorithm,omitempty"`
AdditionalSigningAlgorithms []string `json:"additional_signing_algorithms,omitempty"`
// CertificateURI is the certificate of the slot that can validate the
// signature; PublicKeyPEM the public key, when the service gives it instead
// (slot 15).
CertificateURI string `json:"certificate_uri,omitempty"`
PublicKeyPEM string `json:"public_key_pem,omitempty"`
// Blob is SignedMeasurements: the transcript of the SPDM exchange whose last
// response carries the signature; Hex shows its first 64 bytes.
Blob Digest `json:"signed_measurements"`
// NonceInBlob is whether the nonce bytes occur in the blob (the schema has
// the Requester send it in the last GET_MEASUREMENTS request): a substring
// test, not an SPDM parse.
NonceInBlob bool `json:"nonce_in_blob"`
// Verified is always false: this client does not verify the signature.
Verified bool `json:"signature_verified"`
Verification string `json:"verification"`
}
SignedMeasurements is the answer of SPDMGetSignedMeasurements. The signature is NOT verified: Verified is false, and Verification says so.
func ParseSignedMeasurements ¶ added in v0.15.0
func ParseSignedMeasurements(data []byte) (SignedMeasurements, error)
ParseSignedMeasurements decodes the answer of SPDMGetSignedMeasurements (SPDMGetSignedMeasurementsResponse). The blob must be Base64 with padding and is bounded by MaxSignedBlobText. The signature is not verified.
type SignedMeasurementsRequest ¶ added in v0.15.0
type SignedMeasurementsRequest struct {
// Indices are the measurement blocks to sign: one or more unique values
// 0..254, or the single value 255 (all); empty: the service assumes [255].
Indices []int
// Nonce is 32 bytes as 64 hex digits; empty: this client generates one
// (crypto/rand), so the answer is fresh whatever the service does.
Nonce string
// SlotID is the SPDM slot of the certificate that signs; nil: the service
// assumes 0.
SlotID *int
// RawBitstream asks for raw bitstreams (SPDM 1.2 and later; ignored by
// older versions).
RawBitstream bool
}
SignedMeasurementsRequest are the parameters of SPDMGetSignedMeasurements (ComponentIntegrity 1.5.0).
type SimpleUpdateOptions ¶ added in v0.8.0
type SimpleUpdateOptions struct {
// ImageURI is where the service fetches the image from (required): an absolute
// URI whose scheme is one of the transfer protocols the service allows, and
// that holds no credentials (Username and Password carry them).
ImageURI string
// Protocol is the TransferProtocol; empty: not sent.
Protocol string
// Targets are the resources to update; empty: the service decides.
Targets []string
// Username and Password give access to the image server. The password is a
// Secret: it is sent, and never printed, returned in an error or kept in a
// message of the result.
Username string
Password Secret
ApplyTime string
}
SimpleUpdateOptions are the options of SimpleUpdate (the module's update_image_uri, update_protocol, update_targets, update_creds and update_apply_time).
type Source ¶ added in v0.2.0
type Source string
Source says where an Interval's energy comes from.
const ( // SourceCounter: the difference of two reads of an energy counter // (EnergykWh): exact. SourceCounter Source = "counter" // SourcePower: the integral of the polled power (PowerWatts or // PowerConsumedWatts) by the trapezoid rule: an estimate between samples, // exact for a constant power. SourcePower Source = "power" )
type StatusError ¶
type StatusError struct {
Method, Path string
Code int
// ErrorCode and Message are the error object's "code" and "message".
ErrorCode, Message string
// Info is the @Message.ExtendedInfo of the error, in order.
Info []Message
}
StatusError is an answer with another status than 200, 201, 202 or 204. It carries what the service said: the error object's code and message and its @Message.ExtendedInfo (DSP0266 9.5), decoded.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type SubscribeOptions ¶ added in v0.10.0
type SubscribeOptions struct {
// Destination is where the service posts the events (required; CheckDestination).
Destination string
// Context is a client-supplied string the service stores and returns in every
// event for this subscription. It is not a secret: it is echoed.
Context string
// EventFormatType is Event or MetricReport; empty: omitted, the service
// assumes Event.
EventFormatType string
// The filters of Table 37. Each is checked against what the EventService
// supports before anything is sent.
RegistryPrefixes []string
ResourceTypes []string
MessageIDs []string
ExcludeMessageIDs []string
ExcludeRegistryPrefixes []string
OriginResources []string
SubordinateResources *bool
// HTTPHeaders are the headers the service sends with every event (an
// Authorization for the receiver, for instance): credentials, so Secrets. They
// are sent, never printed and never returned: an error that carries one is
// redacted.
HTTPHeaders map[string]Secret
}
SubscribeOptions describe a subscription (EventDestination, DSP0266 12.1.2 and Table 37 in 12.1.5). Only the Redfish protocol and the RedfishEvent subscription type are created.
type Subscription ¶ added in v0.10.0
type Subscription struct {
URI string `json:"uri"`
ID string `json:"id"`
Destination string `json:"destination"`
Protocol string `json:"protocol,omitempty"`
SubscriptionType string `json:"subscription_type,omitempty"`
EventFormatType string `json:"event_format_type,omitempty"`
Context string `json:"context"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
RegistryPrefixes []string `json:"registry_prefixes,omitempty"`
ResourceTypes []string `json:"resource_types,omitempty"`
MessageIDs []string `json:"message_ids,omitempty"`
ExcludeMessageIDs []string `json:"exclude_message_ids,omitempty"`
ExcludeRegistryPrefixes []string `json:"exclude_registry_prefixes,omitempty"`
Severities []string `json:"severities,omitempty"`
OriginResources []string `json:"origin_resources,omitempty"`
SubordinateResources *bool `json:"subordinate_resources,omitempty"`
}
Subscription is an EventDestination resource (EventDestination 1.17.1). The HttpHeaders of a subscription are never read back: the schema has the service answer null or an empty array, as they hold credentials.
type TLSPolicy ¶ added in v0.15.0
type TLSPolicy struct {
VerifyCertificate *bool `json:"verify_certificate,omitempty"`
Allowed *ParameterSet `json:"allowed,omitempty"`
Denied *ParameterSet `json:"denied,omitempty"`
TrustedCertificatesURI string `json:"trusted_certificates_uri,omitempty"`
RevokedCertificatesURI string `json:"revoked_certificates_uri,omitempty"`
}
TLSPolicy is one side (Client or Server) of the TLS policy.
type TPMInfo ¶ added in v0.15.0
type TPMInfo struct {
// NonceSizeBytesMaximum is the longest Nonce of TPMGetSignedMeasurements.
NonceSizeBytesMaximum *int64 `json:"nonce_size_bytes_maximum,omitempty"`
Measurements []Measurement `json:"measurements,omitempty"`
CertificateURI string `json:"certificate_uri,omitempty"`
VerificationStatus string `json:"verification_status,omitempty"`
Sessions []Session `json:"sessions,omitempty"`
}
TPMInfo is the TPM object of a ComponentIntegrity.
type Task ¶ added in v0.3.0
type Task struct {
ID, Name string
State, Status string // TaskState, TaskStatus
PercentComplete *float64
StartTime string
EndTime string
Messages []Message
}
Task is what a Task resource says (Task.v1_x, DSP8010).
type TelemetryService ¶ added in v0.14.0
type TelemetryService struct {
URI string `json:"uri"`
// ServiceEnabled is nil when the service does not say (TelemetryService 1.2).
ServiceEnabled *bool `json:"service_enabled,omitempty"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
// SupportedCollectionFunctions are the functions a metric of a report
// definition may apply (Average, Maximum, Minimum, Summation).
SupportedCollectionFunctions []string `json:"supported_collection_functions,omitempty"`
// MinCollectionInterval is the shortest interval between two gatherings the
// service allows, as the service wrote it; MinInterval is it as a duration, nil
// when absent or not a duration.
MinCollectionInterval string `json:"min_collection_interval,omitempty"`
MinInterval *time.Duration `json:"-"`
// MaxReports is the number of metric reports the service supports.
MaxReports *int64 `json:"max_reports,omitempty"`
// The collections and the log service the resource links; empty when absent.
MetricDefinitionsURI string `json:"metric_definitions_uri,omitempty"`
MetricReportDefinitionsURI string `json:"metric_report_definitions_uri,omitempty"`
MetricReportsURI string `json:"metric_reports_uri,omitempty"`
TriggersURI string `json:"triggers_uri,omitempty"`
LogServiceURI string `json:"log_service_uri,omitempty"`
// SubmitTestMetricReport is true when the service has the action.
SubmitTestMetricReport bool `json:"submit_test_metric_report"`
}
TelemetryService is the TelemetryService resource (TelemetryService 1.4.1).
func ParseTelemetryService ¶ added in v0.14.0
func ParseTelemetryService(uri string, data []byte) (TelemetryService, error)
ParseTelemetryService decodes a TelemetryService resource read at uri.
type TestEvent ¶ added in v0.10.0
type TestEvent struct {
// MessageID is required, of the form Registry.Major.Minor.Key
// (^\w+\.\d+\.\d+\.\w+$).
MessageID string
Message string
MessageArgs []string
MessageSeverity string
Severity string
OriginOfCondition string
EventID string
EventGroupID *int64
EventTimestamp string
// EventType is deprecated since EventService 1.3 (subscriptions are based on
// RegistryPrefix and ResourceType); sent only when set.
EventType string
}
TestEvent is the parameters of the EventService.SubmitTestEvent action (EventService 1.12.0). Only MessageId is required; what is not set is not sent and the service omits it from the event.
type TestMetricValue ¶ added in v0.14.0
type TestMetricValue struct {
MetricID string
MetricProperty string
MetricValue string
// Timestamp is an RFC 3339 date-time; empty: not sent.
Timestamp string
}
TestMetricValue is one entry of GeneratedMetricReportValues of the SubmitTestMetricReport action (TelemetryService 1.4.1 MetricValue): the value is a string, as in a report.
type Threshold ¶ added in v0.14.0
type Threshold struct {
// Activation is Increasing, Decreasing, Either or Disabled.
Activation string `json:"activation,omitempty"`
DwellTime string `json:"dwell_time,omitempty"`
Reading *float64 `json:"reading,omitempty"`
}
Threshold is a numeric threshold of a trigger (Triggers 1.4.0 Threshold).
type Trigger ¶ added in v0.14.0
type Trigger struct {
URI string `json:"uri"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
MetricType string `json:"metric_type,omitempty"`
MetricIDs []string `json:"metric_ids,omitempty"`
MetricProperties []string `json:"metric_properties,omitempty"`
// NumericThresholds by name: LowerCritical, LowerWarning, UpperCritical,
// UpperWarning.
NumericThresholds map[string]Threshold `json:"numeric_thresholds,omitempty"`
// DiscreteTriggerCondition and the number of DiscreteTriggers.
DiscreteTriggerCondition string `json:"discrete_trigger_condition,omitempty"`
DiscreteTriggers int `json:"discrete_triggers,omitempty"`
EventTriggers []string `json:"event_triggers,omitempty"`
// TriggerActions are LogToLogService, RedfishEvent and RedfishMetricReport.
TriggerActions []string `json:"trigger_actions,omitempty"`
TriggerEnabled *bool `json:"trigger_enabled,omitempty"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
}
Trigger is a Triggers resource (Triggers 1.4.0): a condition that applies to metrics. It is read, not written.
type TrustedComponent ¶ added in v0.15.0
type TrustedComponent struct {
URI string `json:"uri"`
ID string `json:"id"`
ChassisURI string `json:"chassis_uri,omitempty"`
Name string `json:"name,omitempty"`
// Type is Discrete or Integrated.
Type string `json:"type,omitempty"`
FirmwareVersion string `json:"firmware_version,omitempty"`
Manufacturer string `json:"manufacturer,omitempty"`
Model string `json:"model,omitempty"`
PartNumber string `json:"part_number,omitempty"`
SKU string `json:"sku,omitempty"`
SerialNumber string `json:"serial_number,omitempty"`
UUID string `json:"uuid,omitempty"`
State string `json:"state,omitempty"`
Health string `json:"health,omitempty"`
// TPM vendor identifiers, when the component is a TPM.
TPMCapabilitiesVendorID string `json:"tpm_capabilities_vendor_id,omitempty"`
TPMHardwareInterfaceVendorID string `json:"tpm_hardware_interface_vendor_id,omitempty"`
CertificatesURI string `json:"certificates_uri,omitempty"`
// Links: the ComponentIntegrity resources it is responsible for, the
// components it protects, its active image, owner and host.
ComponentIntegrity []string `json:"component_integrity,omitempty"`
ComponentsProtected []string `json:"components_protected,omitempty"`
ActiveSoftwareImage string `json:"active_software_image,omitempty"`
IntegratedInto string `json:"integrated_into,omitempty"`
Owner string `json:"owner,omitempty"`
// TPMClear and TPMGetEventLog are true when the component has the action
// (neither is run by this client).
TPMClear bool `json:"tpm_clear"`
TPMGetEventLog bool `json:"tpm_get_event_log"`
}
TrustedComponent is a TrustedComponent resource (1.5.0) of a chassis.
func ParseTrustedComponent ¶ added in v0.15.0
func ParseTrustedComponent(uri string, data []byte) (TrustedComponent, error)
ParseTrustedComponent decodes a TrustedComponent resource read at uri.
type UpdateCapabilities ¶ added in v0.8.0
type UpdateCapabilities struct {
// MultipartSupported: the UpdateService has MultipartHttpPushUri.
MultipartSupported bool `json:"multipart_supported"`
// Entries maps each action (its title, else its key) to the transfer protocols
// it allows.
Entries map[string][]string `json:"entries"`
}
UpdateCapabilities is what GetFirmwareUpdateCapabilities reports.
func ParseUpdateCapabilities ¶ added in v0.8.0
func ParseUpdateCapabilities(data []byte) (UpdateCapabilities, error)
ParseUpdateCapabilities decodes an UpdateService resource (get_firmware_update_capabilities): ErrUnsupported when it has no Actions or an empty one.
type UpdateResult ¶ added in v0.8.0
type UpdateResult struct {
Outcome
Status UpdateStatus
}
UpdateResult is an update that was requested: what was done, and the status of the operation.
type UpdateStatus ¶ added in v0.8.0
type UpdateStatus struct {
// Status is the TaskState (or JobState) of the task, or the one the status
// code implies: Completed, New, Exception.
Status string `json:"status"`
Messages []Message `json:"messages"`
// Handle is the task monitor to follow; empty once the operation is complete.
Handle string `json:"handle,omitempty"`
// ResetsRequested are the resets the update needs to continue.
ResetsRequested []ResetRequest `json:"resets_requested"`
}
UpdateStatus is the status of an update operation (_operation_results).
func ParseUpdateStatus ¶ added in v0.8.0
func ParseUpdateStatus(code int, location string, body []byte, handle string) UpdateStatus
ParseUpdateStatus builds the status of an operation from the answer to it: its status code, its Location header, its body, and the handle the caller last used (_operation_results). The task monitor, the status and the messages come from the body when it is a Task or a Job, else from the error object's extended information; an OperationTransitionedToJob message moves the handle to the job, and a ResetRequired message adds a reset to ResetsRequested (only when it names a resource of the service).
type VirtualMediaOptions ¶ added in v0.6.0
type VirtualMediaOptions struct {
// ImageURL is the image to insert (required).
ImageURL string
// MediaTypes selects a slot that supports one of them (CD, DVD, Floppy,
// USBStick...); empty: any slot.
MediaTypes []string
// Inserted and WriteProtected are sent when not nil (the module's defaults
// are both true).
Inserted, WriteProtected *bool
// Username and Password give access to the image; TransferProtocolType and
// TransferMethod say how to fetch it.
Username, Password, TransferProtocolType, TransferMethod string
}
VirtualMediaOptions are the options of VirtualMediaInsert (the module's virtual_media dict).
type VolumeRequest ¶ added in v0.9.0
type VolumeRequest struct {
// Details are the properties of the new Volume: RAIDType is required; Name,
// CapacityBytes and others are sent as given.
Details Props
// Drives are the paths of the drives it uses (Links.Drives): required.
Drives []string
// DeleteNoneVolumes first deletes the volumes of RAIDType None of the
// subsystem (storage_none_volume_deletion). It destroys data.
DeleteNoneVolumes bool
// OnDelete, when set, is called with the paths about to be deleted by
// DeleteNoneVolumes, before the first DELETE.
OnDelete func(uris []string)
}
VolumeRequest is a volume to create (create_volume's volume_details).
type VolumeResult ¶ added in v0.9.0
VolumeResult is what CreateVolume and DeleteVolumes did: Monitors are the task monitors of every request that answered 202 (Monitor is the first of them).
type Wildcard ¶ added in v0.14.0
Wildcard is a wildcard of a MetricProperties URI and the values that replace it (`*` stands for all the possible values).
type X509Info ¶ added in v0.11.0
type X509Info struct {
Version int `json:"version"`
SerialNumber string `json:"serial_number"`
Subject string `json:"subject"`
Issuer string `json:"issuer"`
NotBefore time.Time `json:"not_before"`
NotAfter time.Time `json:"not_after"`
SignatureAlgorithm string `json:"signature_algorithm"`
PublicKeyAlgorithm string `json:"public_key_algorithm"`
KeyBits int `json:"key_bits,omitempty"`
KeyCurve string `json:"key_curve,omitempty"`
// KeyUsage names the usages as the Certificate schema's KeyUsage enumeration does:
// the Key Usage bits and the Extended Key Usage values of RFC 5280 4.2.1.3, 4.2.1.12.
KeyUsage []string `json:"key_usage,omitempty"`
DNSNames []string `json:"dns_names,omitempty"`
IPAddresses []string `json:"ip_addresses,omitempty"`
EmailAddresses []string `json:"email_addresses,omitempty"`
IsCA bool `json:"is_ca"`
SelfSigned bool `json:"self_signed"`
// SHA256Fingerprint is the SHA-256 of the DER, colon-separated hex.
SHA256Fingerprint string `json:"sha256_fingerprint"`
// ChainLength is the number of certificates in the string.
ChainLength int `json:"chain_length"`
// PrivateKeyPresent is true when the string carries a private key block, which
// the schema has a service remove from its responses; the key is not read.
PrivateKeyPresent bool `json:"private_key_present,omitempty"`
}
X509Info is what crypto/x509 reads in a certificate (RFC 5280): the first certificate of the string is the leaf, the others make the chain.
func ParseX509 ¶ added in v0.11.0
ParseX509 decodes the PEM string of a Certificate (type PEM or PEMchain, RFC 5280 structures) with crypto/x509. It is read-only and bounded: a string over MaxCertificateString or with more than 16 certificates is refused, and private key blocks are skipped without being parsed. It never panics.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
redfish
command
redfish is a command-line client for the DMTF Redfish API of a BMC, built on github.com/go-redfish/redfish, and a mock BMC to try it against.
|
redfish is a command-line client for the DMTF Redfish API of a BMC, built on github.com/go-redfish/redfish, and a mock BMC to try it against. |
|
internal
|
|
|
fuzzmatrix
command
Command fuzzmatrix prints the GitHub Actions matrix of every fuzz target in the module, found by parsing the *_test.go files, so a new Fuzz function is scheduled by fuzz-long.yml without anyone listing it by hand.
|
Command fuzzmatrix prints the GitHub Actions matrix of every fuzz target in the module, found by parsing the *_test.go files, so a new Fuzz function is scheduled by fuzz-long.yml without anyone listing it by hand. |
|
Package mockbmc is a Redfish service for tests and for `redfish mock serve`: the DMTF "public-rackmount1" mockup (DSP2043, BSD-3-Clause, vendored under testdata with its licence) served by an http.Handler that is stateful enough to be driven the way a real BMC is.
|
Package mockbmc is a Redfish service for tests and for `redfish mock serve`: the DMTF "public-rackmount1" mockup (DSP2043, BSD-3-Clause, vendored under testdata with its licence) served by an http.Handler that is stateful enough to be driven the way a real BMC is. |