carbideapi

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddExpectedMachineRequest

type AddExpectedMachineRequest struct {
	BMCMACAddress            string   `json:"bmc_mac_address"`
	BMCUsername              string   `json:"bmc_username"`
	BMCPassword              string   `json:"bmc_password"`
	ChassisSerialNumber      string   `json:"chassis_serial_number,omitempty"`
	FallbackDPUSerialNumbers []string `json:"fallback_dpu_serial_numbers,omitempty"`
	RackID                   string   `json:"rack_id,omitempty"`
	PauseIngestionAndPowerOn *bool    `json:"default_pause_ingestion_and_poweron,omitempty"`
}

AddExpectedMachineRequest contains the parameters for registering an expected machine with Carbide.

type AddExpectedPowerShelfRequest added in v1.2.0

type AddExpectedPowerShelfRequest struct {
	BMCMACAddress     string `json:"bmc_mac_address"`
	BMCUsername       string `json:"bmc_username"`
	BMCPassword       string `json:"bmc_password"`
	ShelfSerialNumber string `json:"shelf_serial_number,omitempty"`
	IPAddress         string `json:"ip_address,omitempty"`
	RackID            string `json:"rack_id,omitempty"`
}

AddExpectedPowerShelfRequest contains the parameters for registering an expected power shelf with Carbide.

type AddExpectedSwitchRequest

type AddExpectedSwitchRequest struct {
	BMCMACAddress      string `json:"bmc_mac_address"`
	BMCUsername        string `json:"bmc_username"`
	BMCPassword        string `json:"bmc_password"`
	SwitchSerialNumber string `json:"switch_serial_number,omitempty"`
	RackID             string `json:"rack_id,omitempty"`
	NVOSUsername       string `json:"nvos_username,omitempty"`
	NVOSPassword       string `json:"nvos_password,omitempty"`
}

AddExpectedSwitchRequest contains the parameters for registering an expected switch with Carbide.

type BringUpState

type BringUpState int

BringUpState represents the bring-up state of a machine in relation to Carbide's power-on gate.

const (
	BringUpStateNotDiscovered BringUpState = iota
	BringUpStateWaitingForIngestion
	BringUpStateMachineNotCreated
	BringUpStateMachineCreated
)

func (BringUpState) String

func (s BringUpState) String() string

type Client

type Client interface {
	Version(ctx context.Context) (string, error)
	GetMachines(ctx context.Context) ([]MachineDetail, error)
	GetLeakingMachineIds(ctx context.Context) ([]string, error)
	GetPowerStates(ctx context.Context, machineIds []string) (ret []MachinePowerState, err error)
	SetFirmwareUpdateTimeWindow(ctx context.Context, machineIds []string, startTime, endTime time.Time) error
	// FindInterfaces returns all machine interfaces known by carbide-api, keyed by MAC address
	FindInterfaces(ctx context.Context) (map[string]MachineInterface, error)

	// AdminPowerControl performs power control operations on a machine
	AdminPowerControl(ctx context.Context, machineID string, action SystemPowerControl) error

	// UpdatePowerOption sets the desired power state for a machine in Carbide's power manager.
	// This controls Carbide's power-on gate: setting desired state to On allows
	// the machine to power on, while Off or Disabled prevents it.
	UpdatePowerOption(ctx context.Context, machineID string, desiredState PowerState) error

	// FindMachinesByIds returns detailed machine information for the given machine IDs
	FindMachinesByIds(ctx context.Context, machineIds []string) ([]MachineDetail, error)

	// GetMachinePositionInfo returns position information for the given machine IDs
	GetMachinePositionInfo(ctx context.Context, machineIds []string) ([]MachinePosition, error)

	// AllowIngestionAndPowerOn opens Carbide's power-on gate for a BMC endpoint,
	// allowing the machine to be ingested and powered on.
	AllowIngestionAndPowerOn(ctx context.Context, bmcIP string, bmcMAC string) error

	// DetermineMachineIngestionState returns the bring-up state of a machine
	// relative to Carbide's power-on gate.
	DetermineMachineIngestionState(ctx context.Context, bmcIP string, bmcMAC string) (BringUpState, error) //nolint

	// AddExpectedMachine registers an expected machine with Carbide for ingestion.
	AddExpectedMachine(ctx context.Context, req AddExpectedMachineRequest) error

	// GetAllExpectedSwitches returns all expected switches registered with Carbide,
	// keyed by BMC MAC address, including metadata (e.g., "host_mac_address" for the NVOS MAC).
	GetAllExpectedSwitches(ctx context.Context) (map[string]ExpectedSwitchInfo, error)

	// AddExpectedSwitch registers an expected switch with Carbide for ingestion.
	AddExpectedSwitch(ctx context.Context, req AddExpectedSwitchRequest) error

	// AddExpectedPowerShelf registers an expected power shelf with Carbide for ingestion.
	AddExpectedPowerShelf(ctx context.Context, req AddExpectedPowerShelfRequest) error

	// InsertHealthReportOverride inserts a health-report override for a machine
	// (replaces the deprecated SetMaintenance RPC).
	InsertHealthReportOverride(ctx context.Context, machineID string, source string) error

	// RemoveHealthReportOverride removes a previously inserted health-report override.
	RemoveHealthReportOverride(ctx context.Context, machineID string, source string) error

	// ComponentPowerControl performs power control on component targets (switches, power shelves).
	ComponentPowerControl(ctx context.Context, req *pb.ComponentPowerControlRequest) (*pb.ComponentPowerControlResponse, error)

	// UpdateComponentFirmware queues firmware updates for component targets.
	UpdateComponentFirmware(ctx context.Context, req *pb.UpdateComponentFirmwareRequest) (*pb.UpdateComponentFirmwareResponse, error)

	// GetComponentFirmwareStatus returns firmware update status for component targets.
	GetComponentFirmwareStatus(ctx context.Context, req *pb.GetComponentFirmwareStatusRequest) (*pb.GetComponentFirmwareStatusResponse, error)

	// ListComponentFirmwareVersions lists available firmware versions for component targets.
	ListComponentFirmwareVersions(ctx context.Context, req *pb.ListComponentFirmwareVersionsRequest) (*pb.ListComponentFirmwareVersionsResponse, error)

	// GetComponentInventory retrieves inventory (including site exploration reports) for component targets.
	GetComponentInventory(ctx context.Context, req *pb.GetComponentInventoryRequest) (*pb.GetComponentInventoryResponse, error)

	// GetAllExpectedSwitchesLinked returns expected switches linked to their
	// explored endpoints and live Switch resources. Each entry includes the
	// BMC MAC, Core's SwitchId (if the switch has been created), and the
	// expected switch UUID.
	GetAllExpectedSwitchesLinked(ctx context.Context) ([]LinkedExpectedSwitch, error)

	// GetAllExpectedPowerShelvesLinked returns expected power shelves linked
	// to their explored endpoints and live PowerShelf resources. Each entry
	// includes the BMC/PMC MAC, Core's PowerShelfId (if the shelf has been
	// created), and the expected power shelf UUID.
	GetAllExpectedPowerShelvesLinked(ctx context.Context) ([]LinkedExpectedPowerShelf, error)

	// GetDesiredFirmwareVersions returns a slice of desired firmware version
	// entries configured in Core. Each entry carries vendor and model fields;
	// iterate the slice to find matching entries.
	GetDesiredFirmwareVersions(ctx context.Context) ([]*pb.DesiredFirmwareVersionEntry, error)

	// FindExploredEndpointsByIds returns explored endpoint data (including
	// firmware_versions) for the given BMC IP addresses.
	FindExploredEndpointsByIds(ctx context.Context, bmcIPs []string) ([]*pb.ExploredEndpoint, error)

	// SetMachineAutoUpdate enables or disables firmware auto-update for a machine.
	SetMachineAutoUpdate(ctx context.Context, machineID string, enable bool) error

	// The following are only valid in the mock environment and should only be called by unit tests
	AddMachine(MachineDetail)
	AddPowerState(machineID string, state PowerState)
	SetFirmwareUpdateTimeWindowError(err error)
	SetAdminPowerControlError(err error)
	AddMachineInterface(iface MachineInterface)
	AddExpectedSwitchInfo(info ExpectedSwitchInfo)
	SetLeakingMachineIds(ids []string)
}

Client allow us to have both a real implemenation and a mock implementation for unit tests which can be switched transparently

func NewClient

func NewClient(grpcTimeout time.Duration) (Client, error)

NewClient creates a GRPC connection pool to carbide-api. Returning success does not mean that we have yet made an actual connection; that happens when making an actual request.

func NewMockClient

func NewMockClient() Client

NewMockClient returns a "GRPC" client that returns mock values so it can be used in unit tests.

type ExpectedSwitchInfo added in v1.2.0

type ExpectedSwitchInfo struct {
	BMCMACAddress      string
	SwitchSerialNumber string
	Metadata           map[string]string
}

ExpectedSwitchInfo represents an expected switch retrieved from Carbide, including metadata labels (e.g., "host_mac_address" for the NVOS MAC). Credentials are omitted; Carbide configures them in Vault and NSM queries Vault by MAC address.

type LinkedExpectedPowerShelf added in v1.2.0

type LinkedExpectedPowerShelf struct {
	BMCMACAddress        string
	PowerShelfID         string // Core's live PowerShelf ID; empty if not yet created
	ExpectedPowerShelfID string
	ShelfSerialNumber    string
}

LinkedExpectedPowerShelf represents an expected power shelf linked to its explored endpoint and live PowerShelf resource in Core.

type LinkedExpectedSwitch added in v1.2.0

type LinkedExpectedSwitch struct {
	BMCMACAddress      string
	SwitchID           string // Core's live Switch ID; empty if not yet created
	ExpectedSwitchID   string
	SwitchSerialNumber string
}

LinkedExpectedSwitch represents an expected switch linked to its explored endpoint and live Switch resource in Core.

type MachineDetail

type MachineDetail struct {
	MachineID           string
	ChassisSerial       *string
	State               string
	MachineType         string
	BmcIP               string
	BmcMac              string
	FirmwareVersion     string
	UpdateComplete      bool
	HealthStatus        string
	LastObservationTime *time.Time
	FirmwareAutoupdate  *bool
}

MachineDetail represents detailed machine information from Carbide

type MachineInterface

type MachineInterface struct {
	MacAddress string
	Addresses  []string // IP addresses assigned to this interface
}

MachineInterface represents a network interface from carbide-api

type MachinePosition

type MachinePosition struct {
	MachineID        string
	PhysicalSlotNum  *int32
	ComputeTrayIndex *int32
	TopologyID       *int32
}

MachinePosition represents machine position information from Carbide

type MachinePowerState

type MachinePowerState struct {
	MachineID  string
	PowerState PowerState
}

MachinePowerState is information about current and desired power states

type PowerState

type PowerState int
const (
	PowerStateUnknown PowerState = iota
	PowerStateOff
	PowerStateOn
	PowerStateDisabled
)

type SystemPowerControl

type SystemPowerControl int

SystemPowerControl represents power control actions for AdminPowerControl

const (
	// Power On
	PowerControlOn      SystemPowerControl = iota
	PowerControlForceOn                    // maps to On (Carbide doesn't distinguish)
	// Power Off
	PowerControlGracefulShutdown
	PowerControlForceOff
	// Restart (OS level)
	PowerControlGracefulRestart
	PowerControlForceRestart
	// Reset (hardware level)
	PowerControlWarmReset // maps to GracefulRestart
	PowerControlColdReset // maps to ACPowercycle
)

func (SystemPowerControl) String

func (s SystemPowerControl) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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