smdclient

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 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 added in v1.0.0

func AddNodeToInventoryHandler(f *FakeSMDClient) http.HandlerFunc

func ListNodesHandler added in v1.0.0

func ListNodesHandler(f *FakeSMDClient) http.HandlerFunc

func UpdateNodeHandler added in v1.0.0

func UpdateNodeHandler(f *FakeSMDClient) http.HandlerFunc

Types

type ErrSMDResponse added in v1.3.0

type ErrSMDResponse struct {
	HTTPResponse *http.Response
}

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

func (ErrSMDResponse) Error added in v1.3.0

func (esr ErrSMDResponse) Error() string

type FakeSMDClient added in v1.0.0

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

func NewFakeSMDClient added in v1.0.0

func NewFakeSMDClient(clusterName string, count int) *FakeSMDClient

func (*FakeSMDClient) AddNodeToGroups added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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

func (*FakeSMDClient) ClusterName added in v1.0.0

func (f *FakeSMDClient) ClusterName() string

func (*FakeSMDClient) ComponentInformation added in v1.0.0

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

func (*FakeSMDClient) GroupMembership added in v1.0.0

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

func (*FakeSMDClient) IDfromIP added in v1.0.0

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

func (*FakeSMDClient) IDfromMAC added in v1.0.0

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

func (*FakeSMDClient) IPfromID added in v1.0.0

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

func (*FakeSMDClient) ListNodes added in v1.0.0

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

func (*FakeSMDClient) MACfromID added in v1.0.0

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

func (*FakeSMDClient) PopulateNodes added in v1.0.0

func (f *FakeSMDClient) PopulateNodes()

func (*FakeSMDClient) Summary added in v1.0.0

func (f *FakeSMDClient) Summary()

func (*FakeSMDClient) UpdateNode added in v1.0.0

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

func (*FakeSMDClient) WGIPfromID added in v1.0.0

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

type NodeInterface added in v1.0.0

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 added in v1.0.0

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

type OpenCHAMINodeWithGroups added in v1.0.0

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 added in v1.0.0

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

func (*SMDClient) ClusterName added in v1.0.0

func (s *SMDClient) ClusterName() string

ClusterName returns the name of the cluster

func (*SMDClient) ComponentInformation added in v1.0.0

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

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 added in v0.1.1

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 added in v1.0.0

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

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

func (*SMDClient) MACfromID added in v1.0.0

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

func (*SMDClient) PopulateNodes added in v1.0.0

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, and descriptions.

func (*SMDClient) RefreshCache added in v1.0.0

func (s *SMDClient) RefreshCache()

RefreshCache refreshes the cache

func (*SMDClient) RefreshToken added in v0.1.0

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 added in v1.0.0

func (s *SMDClient) StopCacheRefresh()

StopCacheRefresh stops the cache refresh goroutine

func (*SMDClient) WGIPfromID added in v1.0.0

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

type SMDClientInterface added in v1.0.0

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)
	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 added in v1.0.0

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