model

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppKindInband      = "inband"
	AppKindOutOfBand   = "outofband"
	LogLevelInfo       = 0
	LogLevelDebug      = 1
	LogLevelTrace      = 2
	ConcurrencyDefault = 5
	ProfilingEndpoint  = "localhost:9091"
	MetricsEndpoint    = "0.0.0.0:9090"
	// EnvVarDumpFixtures when enabled, will dump data for assets, to be used as fixture data.
	EnvVarDumpFixtures = "DEBUG_DUMP_FIXTURES"
	// EnvVarDumpDiffers when enabled, will dump component differ data for debugging
	// differences identified in component objects in the publish package.
	EnvVarDumpDiffers = "DEBUG_DUMP_DIFFERS"
)
View Source
const (
	// EnvServerserviceSkipOAuth when set to true will skip server service OAuth.
	EnvVarServerserviceSkipOAuth = "SERVERSERVICE_SKIP_OAUTH"

	// serverservice namespace prefix the data is stored in.
	ServerServiceNSPrefix = "sh.hollow.alloy"

	// server vendor, model attributes are stored in this namespace.
	ServerVendorAttributeNS = ServerServiceNSPrefix + ".server_vendor_attributes"

	// additional server metadata are stored in this namespace.
	ServerMetadataAttributeNS = ServerServiceNSPrefix + ".server_metadata_attributes"

	// errors that occurred when connecting/collecting inventory from the bmc are stored here.
	ServerBMCErrorsAttributeNS = ServerServiceNSPrefix + ".server_bmc_errors"

	// server service server serial attribute key
	ServerSerialAttributeKey = "serial"

	// server service server model attribute key
	ServerModelAttributeKey = "model"

	// server service server vendor attribute key
	ServerVendorAttributeKey = "vendor"
)

Variables

View Source
var (
	ErrConfig = errors.New("configuration error")
)
View Source
var (
	// App logging level
	LogLevel = 0
)

Functions

func ServerBIOSConfigNS added in v0.2.0

func ServerBIOSConfigNS(appKind string) string

ServerBIOSConfigNS returns the namespace server bios configuration are stored in.

func ServerComponentAttributeNS

func ServerComponentAttributeNS(appKind string) string

ServerServiceAttributeNS returns the namespace server component attributes are stored in.

func ServerComponentFirmwareNS added in v0.3.6

func ServerComponentFirmwareNS(appKind string) string

ServerComponentFirmwareNS returns the namespace server component firmware attributes are stored in.

func ServerComponentStatusNS added in v0.3.6

func ServerComponentStatusNS(appKind string) string

ServerComponentStatusNS returns the namespace server component statuses are stored in.

Types

type Asset

type Asset struct {
	// Inventory collected from the device
	Inventory *common.Device
	// The device metadata attribute
	Metadata map[string]string
	// BIOS configuration
	BiosConfig map[string]string
	// The device ID from the inventory store
	ID string
	// The device vendor attribute
	Vendor string
	// The device model attribute
	Model string
	// The device serial attribute
	Serial string
	// The datacenter facility attribute from the configuration
	Facility string
	// Username is the BMC login username from the inventory store
	BMCUsername string
	// Password is the BMC login password from the inventory store
	BMCPassword string
	// Errors is a map of errors,
	// where the key is the stage at which the error occurred,
	// and the value is the error.
	Errors map[string]string
	// Address is the BMC IP address from the inventory store
	BMCAddress net.IP
}

Asset represents attributes of an asset retrieved from the asset store

func (*Asset) AppendError added in v0.3.8

func (a *Asset) AppendError(key CollectorError, value string)

AppendError includes the given error key and value in the asset which is then available to the publisher for reporting.

func (*Asset) HasError added in v0.3.8

func (a *Asset) HasError(cErr CollectorError) bool

type CollectorError added in v0.3.8

type CollectorError string

type Config

type Config struct {
	// File is the configuration file path
	File string
	// LogLevel is the app verbose logging level.
	LogLevel int
	// AppKind is one of inband, outofband
	AppKind string `mapstructure:"app_kind"`

	// Out of band collector configuration
	CollectorOutofband struct {
		Concurrency int `mapstructure:"concurrency"`
	} `mapstructure:"collector_outofband"`

	// ServerService is the Hollow server inventory store
	// https://github.com/metal-toolbox/hollow-serverservice
	ServerService struct {
		Endpoint             string   `mapstructure:"endpoint"`
		OidcProviderEndpoint string   `mapstructure:"oidc_provider_endpoint"`
		AudienceEndpoint     string   `mapstructure:"audience_endpoint"`
		ClientSecret         string   `mapstructure:"client_secret"`
		ClientID             string   `mapstructure:"client_id"`
		ClientScopes         []string `mapstructure:"client_scopes"` // []string{"read:server", ..}
		FacilityCode         string   `mapstructure:"facility_code"`
		Concurrency          int      `mapstructure:"concurrency"`
	} `mapstructure:"serverService"`

	// AssetGetter is where alloy looks up assets information like BMC credentials
	// to collect inventory.
	AssetGetter struct {
		// supported parameters: csv OR serverService
		Kind string `mapstructure:"kind"`

		// Csv is the CSV asset getter type configuration.
		Csv struct {
			File string `mapstructure:"file"`
		} `mapstructure:"csv"`
	} `mapstructure:"asset_getter"`

	// Publisher is the inventory store where alloy writes collected inventory data
	InventoryPublisher struct {
		// supported parameters: stdout, serverService
		Kind string `mapstructure:"kind"`
	} `mapstructure:"inventory_publisher"`
}

Config holds application configuration read from a YAML or set by env variables.

nolint:govet // prefer readability over field alignment optimization for this case.

func (*Config) LoadServerServiceEnvVars

func (c *Config) LoadServerServiceEnvVars()

LoadServerServiceEnvVars sets any env SERVERSERVICE_* configuration parameters

func (*Config) ValidateServerServiceParams

func (c *Config) ValidateServerServiceParams() (*url.URL, error)

ValidateServerServiceParams checks required serverservice configuration parameters are present and returns the serverservice URL endpoint

Jump to

Keyboard shortcuts

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