magellan

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package magellan implements the core routines for the tools.

Index

Constants

View Source
const (
	IPMI_PORT  = 623
	SSH_PORT   = 22
	HTTPS_PORT = 443
)

Variables

This section is empty.

Functions

func CollectAll

func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) error

This is the main function used to collect information from the BMC nodes via Redfish. 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 255.

func CollectChassis

func CollectChassis(c *gofish.APIClient, q *QueryParams) ([]map[string]any, error)

CollectChassis() fetches all chassis related information from each node specified via the Redfish API. Like the other collect functions, this function uses the gofish library to make requests to each node. Additionally, all of the network adapters found are added to the output as well.

Returns a map that represents a Chassis object with NetworkAdapters.

func CollectEthernetInterfaces

func CollectEthernetInterfaces(c *gofish.APIClient, q *QueryParams, systemID string) ([]byte, error)

CollectEthernetInterfaces() collects all of the ethernet interfaces found from all systems from under the "/redfish/v1/Systems" endpoint.

TODO: This function needs to be refactored entirely...if not deleted in favor of using crawler.CrawlBM() instead.

func CollectProcessors

func CollectProcessors(q *QueryParams) ([]byte, error)

TODO: MAYBE DELETE???

func CollectRegisteries

func CollectRegisteries(c *gofish.APIClient, q *QueryParams) ([]byte, error)

TODO: DELETE ME!!!

func CollectStorage

func CollectStorage(c *gofish.APIClient, q *QueryParams) ([]byte, error)

TODO: DELETE ME!!!

func CollectSystems

func CollectSystems(c *gofish.APIClient, q *QueryParams) ([]map[string]any, error)

CollectSystems pulls system information from each BMC node via Redfish using the `gofish` library.

The process of collecting this info is as follows: 1. check if system has ethernet interfaces 1.a. if yes, create system data and ethernet interfaces JSON 1.b. if no, try to get data using manager instead 2. check if manager has "ManagerForServices" and "EthernetInterfaces" properties 2.a. if yes, query both properties to use in next step 2.b. for each service, query its data and add the ethernet interfaces 2.c. add the system to list of systems to marshal and return

func GenerateHosts

func GenerateHosts(subnet string, subnetMask *net.IP) []string

GenerateHosts() 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

func GetUpdateStatus

func GetUpdateStatus(q *UpdateParams) error

func LoadConfig added in v0.0.7

func LoadConfig(path string) error

LoadConfig() will load a YAML config file at the specified path. There are some general considerations about how this is done with spf13/viper:

1. There are intentionally no search paths set, so config path has to be set explicitly 2. No data will be written to the config file from the tool 3. Parameters passed as CLI flags and envirnoment variables should always have precedence over values set in the config.

func Login added in v0.0.7

func Login(loginUrl string, targetHost string, targetPort int) (string, error)

Login() initiates the process to retrieve an access token from an identity provider. This function is especially designed to work by OPAAL, but will propably be changed in the future to be more agnostic.

The 'targetHost' and 'targetPort' parameters should point to the target host/port to create a temporary server to receive the access token. If an empty 'targetHost' or an invalid port range is passed, then neither of the parameters will be used and no server will be started.

Returns an access token as a string if successful and nil error. Otherwise, returns an empty string with an error set.

func UpdateFirmwareRemote

func UpdateFirmwareRemote(q *UpdateParams) error

UpdateFirmware() uses 'bmc-toolbox/bmclib' 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.

NOTE: Multipart HTTP updating may not work since older verions of OpenBMC, which bmclib uses underneath, did not support support multipart updates. This was changed with the inclusion of support for MultipartHttpPushUri in OpenBMC (https://gerrit.openbmc.org/c/openbmc/bmcweb/+/32174). Also, related to bmclib: https://github.com/bmc-toolbox/bmclib/issues/341

Types

type QueryParams

type QueryParams struct {
	Host         string   // set by the 'host' flag
	Port         int      // set by the 'port' flag
	Protocol     string   // set by the 'protocol' flag
	Username     string   // set the BMC username with the 'username' flag
	Password     string   // set the BMC password with the 'password' flag
	Drivers      []string // DEPRECATED: TO BE REMOVED!!!
	Concurrency  int      // set the of concurrent jobs with the 'concurrency' flag
	Preferred    string   // DEPRECATED: TO BE REMOVED!!!
	Timeout      int      // set the timeout with the 'timeout' flag
	CaCertPath   string   // set the cert path with the 'cacert' flag
	Verbose      bool     // set whether to include verbose output with 'verbose' flag
	IpmitoolPath string   // DEPRECATED: TO BE REMOVE!!!
	OutputPath   string   // set the path to save output with 'output' flag
	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
}

QueryParams is a collections of common parameters passed to the CLI. Each CLI subcommand has a corresponding implementation function that takes an object as an argument. However, the implementation may not use all of the properties within the object.

type ScannedResult

type ScannedResult struct {
	Host      string    `json:"host"`
	Port      int       `json:"port"`
	Protocol  string    `json:"protocol"`
	State     bool      `json:"state"`
	Timestamp time.Time `json:"timestamp"`
}

func ScanForAssets

func ScanForAssets(hosts []string, ports []int, concurrency int, timeout int, disableProbing bool, verbose bool) []ScannedResult

ScanForAssets() performs a net scan on a network to find available services running. The function expects a list of hosts and ports to make requests. Note that each all ports will be used per host.

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 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).

type UpdateParams

type UpdateParams struct {
	QueryParams
	FirmwarePath     string
	FirmwareVersion  string
	Component        string
	TransferProtocol string
}

Directories

Path Synopsis
api
smd
db

Jump to

Keyboard shortcuts

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