Documentation
¶
Overview ¶
Package magellan implements the core routines for the tools.
Index ¶
- func CollectInventory(assets *[]RemoteAsset, params *CollectParams) ([]map[string]any, error)
- func FindMACAddressWithIP(config crawler.CrawlerConfig, targetIP net.IP) (string, error)
- func GenerateHostsWithSubnet(subnet string, subnetMask *net.IPMask, additionalPorts []int, ...) [][]string
- func GetDefaultPorts() []int
- func GetUpdateStatus(q *UpdateParams) error
- func UpdateFirmwareRemote(q *UpdateParams) error
- type CollectParams
- type RemoteAsset
- type ScanParams
- type UpdateParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectInventory ¶
func CollectInventory(assets *[]RemoteAsset, params *CollectParams) ([]map[string]any, error)
This is the main function used to collect information from the BMC nodes via Redfish. The results of the collect are stored in a cache specified with the `--cache` flag. The function expects a list of hosts found using the `ScanForAssets()` function.
Requests can be made to several of the nodes using a goroutine by setting the q.Concurrency property value between 1 and 10000.
func FindMACAddressWithIP ¶
FindMACAddressWithIP() returns the MAC address of an ethernet interface with a matching IPv4Address. Returns an empty string and error if there are no matches found.
func GenerateHostsWithSubnet ¶
func GenerateHostsWithSubnet(subnet string, subnetMask *net.IPMask, additionalPorts []int, defaultScheme string) [][]string
GenerateHostsWithSubnet() builds a list of hosts to scan using the "subnet" and "subnetMask" arguments passed. The function is capable of distinguishing between IP formats: a subnet with just an IP address (172.16.0.0) and a subnet with IP address and CIDR (172.16.0.0/24).
NOTE: If a IP address is provided with CIDR, then the "subnetMask" parameter will be ignored. If neither is provided, then the default subnet mask will be used instead.
func GetDefaultPorts ¶
func GetDefaultPorts() []int
GetDefaultPorts() returns a list of default ports. The only reason to have this function is to add/remove ports without affecting usage.
func GetUpdateStatus ¶
func GetUpdateStatus(q *UpdateParams) error
func UpdateFirmwareRemote ¶
func UpdateFirmwareRemote(q *UpdateParams) error
UpdateFirmwareRemote() uses 'gofish' to update the firmware of a BMC node. The function expects the firmware URL, firmware version, and component flags to be set from the CLI to perform a firmware update. Example: ./magellan update https://192.168.23.40 --username root --password 0penBmc --firmware-url http://192.168.23.19:1337/obmc-phosphor-image.static.mtd.tar --scheme TFTP
being: q.URI https://192.168.23.40 q.TransferProtocol TFTP q.FirmwarePath http://192.168.23.19:1337/obmc-phosphor-image.static.mtd.tar
Types ¶
type CollectParams ¶
type CollectParams struct {
Concurrency int // set the of concurrent jobs with the 'concurrency' flag
Timeout int // set the timeout with the 'timeout' flag
CaCertPath string // set the cert path with the 'cacert' flag
OutputPath string // set the path to save output with 'output' flag
OutputDir string // set the directory path to save output with `output-dir` flag
Format format.DataFormat // set the output format
ForceUpdate bool // set whether to force updating SMD with 'force-update' flag
AccessToken string // set the access token to include in request with 'access-token' flag
BMCIDMap string // Set the path to the BMC ID mapping YAML or JSON data or file name (if any)
SecretStore secrets.SecretStore // set BMC credentials
}
CollectParams is a collection of common parameters passed to the CLI for the 'collect' subcommand.
type RemoteAsset ¶
type RemoteAsset struct {
Host string `json:"host"`
Port int `json:"port"`
Protocol string `json:"protocol"`
State bool `json:"state"`
Timestamp time.Time `json:"timestamp"`
ServiceType string `json:"service_type,omitempty"`
}
func ScanForAssets ¶
func ScanForAssets(params *ScanParams) []RemoteAsset
ScanForAssets() performs a net scan on a network to find available services running. The function expects a list of targets (as [][]string) to make requests. The 2D list is to permit one goroutine per BMC node when making each request.
This function runs in a goroutine with the "concurrency" flag setting the number of concurrent requests. Only one request is made to each BMC node at a time, but setting a value greater than 1 with enable the requests to be made concurrently.
If the "disableProbing" flag is set, then the function will skip the extra HTTP request made to check if the response was from a Redfish or JAWS service. Otherwise, not receiving a 200 OK response code from the HTTP request will remove the service from being stored in the list of scanned results.
Returns a list of scanned results to be stored in cache (but isn't doing here).
func (*RemoteAsset) String ¶ added in v0.5.1
func (ra *RemoteAsset) String() string
type ScanParams ¶
type ScanParams struct {
TargetHosts [][]string
Scheme string
Protocol string
Concurrency int
Timeout int
DisableProbing bool
Verbose bool
Debug bool
Insecure bool
Include []string
}
ScanParams is a collection of commom parameters passed to the CLI
type UpdateParams ¶
type UpdateParams struct {
CollectParams
URI string // Set from the positional paramters to update
FirmwareURI string // set from the --firmware-url flag
TransferProtocol string // set from the --scheme flag
Insecure bool // set from the --insecure flag
}