smdclient

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnmarshal = errors.New("cannot unmarshal JSON")
	ErrEmptyID   = errors.New("empty id")
)

Functions

func AddNodeToInventoryHandler

func AddNodeToInventoryHandler(f *FakeSMDClient) http.HandlerFunc

func ListNodesHandler

func ListNodesHandler(f *FakeSMDClient) http.HandlerFunc

func UpdateNodeHandler

func UpdateNodeHandler(f *FakeSMDClient) http.HandlerFunc

Types

type ErrSMDResponse

type ErrSMDResponse struct {
	HTTPResponse *http.Response
}

ErrSMDResponse contains the HTTP response of a REST API request to SMD.

func (ErrSMDResponse) Error

func (esr ErrSMDResponse) Error() string

type FakeSMDClient

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

func NewFakeSMDClient

func NewFakeSMDClient(clusterName string, count int) *FakeSMDClient

func (*FakeSMDClient) AddNodeToGroups

func (f *FakeSMDClient) AddNodeToGroups(id string, groups []string) error

AddNodeToGroups adds a node to the specified groups. This is not part of the SMDClient Interface and only useful as part of the simulator

func (*FakeSMDClient) AddNodeToInventory

func (f *FakeSMDClient) AddNodeToInventory(node cistore.OpenCHAMIComponent) error

AddNodeToInventory adds a node to the inventory. This is not part of the SMDClient Interface and only useful as part of the simulator

func (*FakeSMDClient) AddWGIP

func (f *FakeSMDClient) AddWGIP(id string, wgip string) error

func (*FakeSMDClient) ClusterName

func (f *FakeSMDClient) ClusterName() string

func (*FakeSMDClient) ComponentInformation

func (f *FakeSMDClient) ComponentInformation(id string) (base.Component, error)

func (*FakeSMDClient) ComponentInformationWithRetry

func (f *FakeSMDClient) ComponentInformationWithRetry(id string, maxRetries int) (base.Component, error)

func (*FakeSMDClient) GroupMembership

func (f *FakeSMDClient) GroupMembership(id string) ([]string, error)

func (*FakeSMDClient) IDfromIP

func (f *FakeSMDClient) IDfromIP(ipaddr string) (string, error)

func (*FakeSMDClient) IDfromMAC

func (f *FakeSMDClient) IDfromMAC(mac string) (string, error)

func (*FakeSMDClient) IPfromID

func (f *FakeSMDClient) IPfromID(id string) (string, error)

func (*FakeSMDClient) ListMemberships

func (f *FakeSMDClient) ListMemberships() []sm.Membership

ListMemberships returns memberships derived from the simulator's group state.

func (*FakeSMDClient) ListNodes

func (f *FakeSMDClient) ListNodes() []cistore.OpenCHAMIComponent

func (*FakeSMDClient) MACfromID

func (f *FakeSMDClient) MACfromID(id string) (string, error)

func (*FakeSMDClient) PopulateNodes

func (f *FakeSMDClient) PopulateNodes()

func (*FakeSMDClient) Summary

func (f *FakeSMDClient) Summary()

func (*FakeSMDClient) UpdateNode

func (f *FakeSMDClient) UpdateNode(node cistore.OpenCHAMIComponent) error

func (*FakeSMDClient) WGIPfromID

func (f *FakeSMDClient) WGIPfromID(id string) (string, error)

type NodeInterface

type NodeInterface struct {
	MAC  string `json:"mac" yaml:"mac"`
	IP   string `json:"ip" yaml:"ip"`
	WGIP string `json:"wgip" yaml:"wgip"`
	Desc string `json:"description" yaml:"description"`
}

type NodeMapping

type NodeMapping struct {
	Xname      string          `json:"xname" yaml:"xname"`
	Interfaces []NodeInterface `json:"interfaces" yaml:"interfaces"`
	Groups     []string        `json:"groups" yaml:"groups"`
}

type OpenCHAMINodeWithGroups

type OpenCHAMINodeWithGroups struct {
	cistore.OpenCHAMIComponent
	Groups []string `json:"groups,omitempty" yaml:"groups,omitempty"`
}

type SMDClient

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

SMDClient is a client for SMD

func NewSMDClient

func NewSMDClient(clusterName, baseurl, jwtURL, accessToken, certPath string, insecure bool) (*SMDClient, error)

NewSMDClient creates a new SMDClient which connects to the SMD server at baseurl and uses the provided JWT server for authentication

func (*SMDClient) AddWGIP

func (s *SMDClient) AddWGIP(id string, wgip string) error

func (*SMDClient) ClusterName

func (s *SMDClient) ClusterName() string

ClusterName returns the name of the cluster

func (*SMDClient) ComponentInformation

func (s *SMDClient) ComponentInformation(id string) (base.Component, error)

func (*SMDClient) ComponentInformationWithRetry

func (s *SMDClient) ComponentInformationWithRetry(id string, maxRetries int) (base.Component, error)

ComponentInformationWithRetry wraps ComponentInformation with exponential backoff retry logic for transient network errors and timeouts. This is critical during boot storms when SMD may be temporarily overloaded.

func (*SMDClient) GroupMembership

func (s *SMDClient) GroupMembership(id string) ([]string, error)

GroupMembership returns the group labels for the xname with the given ID

func (*SMDClient) IDfromIP

func (s *SMDClient) IDfromIP(ipaddr string) (string, error)

IDfromIP returns the ID of the xname that has the IP address

func (*SMDClient) IDfromMAC

func (s *SMDClient) IDfromMAC(mac string) (string, error)

IDfromMAC returns the ID of the xname that has the MAC address

func (*SMDClient) IPfromID

func (s *SMDClient) IPfromID(id string) (string, error)

IPfromID returns the IP address of the xname with the given ID

func (*SMDClient) MACfromID

func (s *SMDClient) MACfromID(id string) (string, error)

func (*SMDClient) PopulateNodes

func (s *SMDClient) PopulateNodes()

PopulateNodes fetches the Ethernet interface data from the SMD server and populates the nodes map with the corresponding node information, including MAC addresses, IP addresses, descriptions, and group membership.

func (*SMDClient) RefreshCache

func (s *SMDClient) RefreshCache()

RefreshCache refreshes the cache

func (*SMDClient) RefreshToken

func (s *SMDClient) RefreshToken() error

Refresh the cached access token, using the provided JWT server TODO: OPAAL returns a token without having to perform the usual OAuth2 authorization grant. Support for said grant should probably be implemented at some point.

func (*SMDClient) StopCacheRefresh

func (s *SMDClient) StopCacheRefresh()

StopCacheRefresh stops the cache refresh goroutine

func (*SMDClient) WGIPfromID

func (s *SMDClient) WGIPfromID(id string) (string, error)

type SMDClientInterface

type SMDClientInterface interface {
	IDfromMAC(mac string) (string, error)
	IDfromIP(ipaddr string) (string, error)
	IPfromID(id string) (string, error)
	MACfromID(id string) (string, error)
	GroupMembership(id string) ([]string, error)
	ComponentInformation(id string) (base.Component, error)
	ComponentInformationWithRetry(id string, maxRetries int) (base.Component, error)
	PopulateNodes()
	ClusterName() string
	AddWGIP(id string, wgip string) error
	WGIPfromID(id string) (string, error)
}

Create an SMDClient Interface which can be more easily tested and mocked

type SMDRosettaStone

type SMDRosettaStone struct {
	ComponentID   string
	BootMAC       string
	BootIPAddress string
	WGIPAddress   string
	NID           string
	Hostname      string
}

Jump to

Keyboard shortcuts

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