magellan

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package magellan implements the core routines for the tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectInventory

func CollectInventory(assets *[]RemoteAsset, params *CollectParams) 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

func FindMACAddressWithIP(config crawler.CrawlerConfig, targetIP net.IP) (string, error)

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 LoadConfig

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

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

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.

Types

type CollectParams

type CollectParams struct {
	URI         string // set by the 'host' flag
	Username    string // set the BMC username with the 'username' flag
	Password    string // set the BMC password with the 'password' flag
	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
	Verbose     bool   // set whether to include verbose output with 'verbose' flag
	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
}

CollectParams is a collection of common parameters passed to the CLI for the 'collect' subcommand.

type RemoteAsset

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

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 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 ScanParams

type ScanParams struct {
	TargetHosts    [][]string
	Scheme         string
	Protocol       string
	Concurrency    int
	Timeout        int
	DisableProbing bool
	Verbose        bool
	Debug          bool
}

ScanParams is a collection of commom parameters passed to the CLI

type UpdateParams

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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