inventory

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributesExtrasAsMap added in v0.0.7

func AttributesExtrasAsMap(attributeExtras *AttributesExtras) (extras map[string]string)

AttributesExtrasAsMap accepts a AttributesExtras struct as input, and returns all attributes as a map

func ExecCmd added in v0.0.7

func ExecCmd(exe string, args []string, retry int) (out []byte, err error)

ExecCmd executes the executable with the given args and returns if retry is declared, the command is retried for the given number with an interval of 10 seconds, the response as a slice of bytes, and the error if any.

Types

type AssetAttributes added in v0.0.5

type AssetAttributes struct {
	Data        map[string]Attributes `json:"data"` // Map of asset IPs/Serials to attributes.
	EndOfAssets bool                  `json:"end_of_assets"`
}

AssetAttributes is used to unmarshal data returned from an ENC.

type Attributes added in v0.0.5

type Attributes struct {
	Location          string              `json:"location"`
	NetworkInterfaces *[]NetworkInterface `json:"network_interfaces"`
	BMCIPAddresses    []string            `json:"-"`
	Extras            *AttributesExtras   `json:"extras"`
}

Attributes is used to unmarshal data returned from an ENC.

type AttributesExtras added in v0.0.5

type AttributesExtras struct {
	State   string `json:"status"`
	Company string `json:"company"`
	// If it's a chassis, this would hold serials for blades in the Live state.
	LiveAssets *[]string `json:"live_assets,omitempty"`
}

AttributesExtras is used to unmarshal data returned from an ENC.

type Csv

type Csv struct {
	Config          *config.Params
	Log             *logrus.Logger
	BatchSize       int // Number of inventory assets to return per iteration.
	AssetsChan      chan<- []asset.Asset
	FilterAssetType []string
}

Csv inventory struct holds attributes required to read in assets from a csv file.

func (*Csv) AssetIter

func (c *Csv) AssetIter()

AssetIter reads in assets and passes them to the inventory channel.

func (*Csv) AssetIterByIP added in v0.0.7

func (c *Csv) AssetIterByIP()

AssetIterByIP reads in list of ips passed in via cli, attempts to lookup any attributes for the IP in the inventory, and sends an asset for each attribute over the asset channel

func (*Csv) AssetIterBySerial

func (c *Csv) AssetIterBySerial()

Iterates over assets and passes these over the inventory channel.

func (*Csv) AssetRetrieve added in v0.0.4

func (c *Csv) AssetRetrieve() func()

Looks at c.Config.FilterParams and returns the appropriate function that will retrieve assets.

type CsvAsset

type CsvAsset struct {
	BmcAddress string `csv:"bmcaddress"`
	Serial     string `csv:"serial"` // optional
	Vendor     string `csv:"vendor"` // optional
	Type       string `csv:"type"`   // optional
}

CsvAsset struct holds attributes of an asset listed in a csv file.

type Dora

type Dora struct {
	Log             *logrus.Logger
	BatchSize       int
	AssetsChan      chan<- []asset.Asset
	Config          *config.Params
	FilterAssetType []string
}

Dora struct holds attributes required to retrieve assets from Dora, and pass them to the butlers.

func (*Dora) AssetIter

func (d *Dora) AssetIter()

Stuffs assets into an array, writes that to the channel.

func (*Dora) AssetIterBySerial

func (d *Dora) AssetIterBySerial()

AssetIterBySerial is an iterator method, to retrieve assets from Dora by the given serial numbers, assets are then sent over the inventory channel.

func (*Dora) AssetRetrieve added in v0.0.4

func (d *Dora) AssetRetrieve() func()

type DoraAsset

type DoraAsset struct {
	Data  []DoraAssetData `json:"data"`
	Links DoraLinks       `json:"links"`
}

DoraAsset struct is used to unmarshal Dora data.

type DoraAssetAttributes

type DoraAssetAttributes struct {
	Serial         string `json:"serial"`
	BmcAddress     string `json:"bmc_address"`
	Vendor         string `json:"vendor"`
	ScannedAddress string `json:"ip"`   // set when we unmarshal the scanned_ports data
	Site           string `json:"site"` // set when we unmarshal the scanned_ports data
}

DoraAssetAttributes struct is used to unmarshal Dora data.

type DoraAssetData

type DoraAssetData struct {
	Attributes DoraAssetAttributes `json:"attributes"`
}

DoraAssetData struct is used to unmarshal Dora data.

type DoraLinks struct {
	First string `json:"first"`
	Last  string `json:"last"`
	Next  string `json:"next"`
}

DoraLinks struct is used to unmarshal Dora data.

type Enc added in v0.0.5

type Enc struct {
	Log             *logrus.Logger
	BatchSize       int
	AssetsChan      chan<- []asset.Asset
	Config          *config.Params
	FilterAssetType []string
	StopChan        <-chan struct{}
}

Enc struct holds attributes required to run inventory/enc methods.

func (*Enc) AssetIter added in v0.0.5

func (e *Enc) AssetIter()

AssetIter fetches assets and sends them over the asset channel. Iter stuffs assets into an array of Assets, writes that to the channel.

func (*Enc) AssetIterByIP added in v0.0.7

func (e *Enc) AssetIterByIP()

Reads the list of IPs passed by the user via CLI. Queries ENC for attributes related to those, then passes them to the assets channel. If no attributes for a given IP are returned, an asset with just the IP is returned.

func (*Enc) AssetIterBySerial added in v0.0.5

func (e *Enc) AssetIterBySerial()

Reads the list of serials passed by the user via CLI. Queries ENC for the serials, then passes them to the assets channel.

func (*Enc) AssetRetrieve added in v0.0.5

func (e *Enc) AssetRetrieve() func()

func (*Enc) SetBMCInterfaces added in v0.0.7

func (e *Enc) SetBMCInterfaces(attributes Attributes) Attributes

SetBMCInterfaces populates IPAddresses of BMC interfaces, from the Slice of NetworkInterfaces

func (*Enc) SetChassisInstalled added in v0.0.5

func (e *Enc) SetChassisInstalled(serials string)

SetChassisInstalled is a method used to update a chassis state in the inventory.

type IPList added in v0.0.7

type IPList struct {
	Log       *logrus.Logger
	BatchSize int                  // Number of inventory assets to return per iteration.
	Channel   chan<- []asset.Asset // The channel to send inventory assets over.
	Config    *config.Params       // bmcbutler config + CLI params passed by the user.
}

An inventory source that holds attributes to setup the IP list source.

func (*IPList) AssetIter added in v0.0.7

func (i *IPList) AssetIter()

AssetIter is an iterator method that sends assets to configure over the inventory channel.

func (*IPList) AssetRetrieve added in v0.0.7

func (i *IPList) AssetRetrieve() func()

type NetworkInterface added in v0.0.7

type NetworkInterface struct {
	Name       string `json:"name"`
	MACAddress string `json:"mac_address"`
	IPAddress  string `json:"ip_address"`
}

NetworkInterface is used to unmarshal data returned from the ENC.

Jump to

Keyboard shortcuts

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