cmd

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright © 2022 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	CmdTimeout = 20 * time.Second

	// TODO: merge constants along with the ones in Alloy into a separate library
	ServerVendorAttributeNS = "sh.hollow.alloy.server_vendor_attributes"
	FirmwareSetAttributeNS  = "sh.hollow.firmware_set.labels"
)

Variables

View Source
var (
	ErrAttributeFromLabel = errors.New("error creating Attribute from Label")
	ErrLabelFromAttribute = errors.New("error creating Label from Attribute")
	ErrFwSetByVendorModel = errors.New("error identifying firmware set by server vendor, model")
)
View Source
var (
	ConfigFileFlag                    = &flagDetails{name: "config", short: "c"}
	ReAuthFlag                        = &flagDetails{name: "reauth"}
	ServerFlag                        = &flagDetails{name: "server", short: "s"}
	SkipFWStatusFlag                  = &flagDetails{name: "skip-fw-status"}
	SkipBiosConfigFlag                = &flagDetails{name: "skip-bios-config"}
	FromFileFlag                      = &flagDetails{name: "from-file", short: "F"}
	FirmwareIDsFlag                   = &flagDetails{name: "firmware-ids", short: "U"}
	NameFlag                          = &flagDetails{name: "name", short: "n"}
	LabelsFlag                        = &flagDetails{name: "labels", short: "l"}
	FacilityFlag                      = &flagDetails{name: "facility"}
	BMCAddressFlag                    = &flagDetails{name: "bmc-addr", short: "a"}
	BMCUsernameFlag                   = &flagDetails{name: "bmc-user", short: "u"}
	BMCPasswordFlag                   = &flagDetails{name: "bmc-pass", short: "p"}
	FirmwareIDFlag                    = &flagDetails{name: "firmware-id", short: "f"}
	FirmwareVersionFlag               = &flagDetails{name: "firmware-version", short: "V"}
	FirmwareSetFlag                   = &flagDetails{name: "set-id"}
	FirmwareAddFlag                   = &flagDetails{name: "add-firmware-ids"}
	FirmwareRemoveFlag                = &flagDetails{name: "remove-firmware-ids"}
	MacAOCFlag                        = &flagDetails{name: "aoc-mac"}
	MacBMCFlag                        = &flagDetails{name: "bmc-mac"}
	OutputFlag                        = &flagDetails{name: "output", short: "o"}
	ForceFlag                         = &flagDetails{name: "force"}
	DryRunFlag                        = &flagDetails{name: "dry-run"}
	SkipBmcResetFlag                  = &flagDetails{name: "skip-bmc-reset"}
	PowerOffRequiredFlag              = &flagDetails{name: "power-off-required"}
	ModelFlag                         = &flagDetails{name: "model", short: "m"}
	VendorFlag                        = &flagDetails{name: "vendor", short: "v"}
	SlugFlag                          = &flagDetails{name: "slug"}
	WithRecordsFlag                   = &flagDetails{name: "with-records"}
	PageFlag                          = &flagDetails{name: "page"}
	LimitFlag                         = &flagDetails{name: "limit"}
	WithBMCErrorsFlag                 = &flagDetails{name: "with-bmc-errors"}
	WithCredsFlag                     = &flagDetails{name: "with-creds"}
	PrintTableFlag                    = &flagDetails{name: "table", short: "t"}
	BiosConfigFlag                    = &flagDetails{name: "bios-config"}
	ListComponentsFlag                = &flagDetails{name: "list-components"}
	ServerSerialFlag                  = &flagDetails{name: "serial"}
	ServerActionPowerActionFlag       = &flagDetails{name: "action"}
	ServerActionPowerActionStatusFlag = &flagDetails{name: "action-status"}
	ComponentTypeFlag                 = &flagDetails{name: "component"}

	OutputTypeJSON outputType = "json"
	OutputTypeText outputType = "text"
)
View Source
var RootCmd = &cobra.Command{
	Use:   "mctl",
	Short: "mctl is a CLI utility to interact with metal toolbox services",

	DisableAutoGenTag: true,
}

RootCmd represents the base command when called without any subcommands

Functions

func AddBIOSConfigFlag added in v1.0.2

func AddBIOSConfigFlag(cmd *cobra.Command, ptr *bool)

func AddBMCAddressFlag added in v1.0.2

func AddBMCAddressFlag(cmd *cobra.Command, ptr *string)

func AddBMCPasswordFlag added in v1.0.2

func AddBMCPasswordFlag(cmd *cobra.Command, ptr *string)

func AddBMCUsernameFlag added in v1.0.2

func AddBMCUsernameFlag(cmd *cobra.Command, ptr *string)

func AddComponentTypeFlag added in v1.0.2

func AddComponentTypeFlag(cmd *cobra.Command, ptr *string)

func AddConfigFileFlag added in v1.0.2

func AddConfigFileFlag(cmd *cobra.Command, ptr *string)

func AddDryRunFlag added in v1.0.2

func AddDryRunFlag(cmd *cobra.Command, ptr *bool, usage string)

func AddFacilityFlag added in v1.0.2

func AddFacilityFlag(cmd *cobra.Command, ptr *string)

func AddFirmwareAddIDsFlag added in v1.0.2

func AddFirmwareAddIDsFlag(cmd *cobra.Command, ptr *[]string)

func AddFirmwareIDFlag added in v1.0.2

func AddFirmwareIDFlag(cmd *cobra.Command, ptr *string)

func AddFirmwareIDsFlag added in v1.0.2

func AddFirmwareIDsFlag(cmd *cobra.Command, ptr *[]string)

func AddFirmwareRemoveIDsFlag added in v1.0.2

func AddFirmwareRemoveIDsFlag(cmd *cobra.Command, ptr *[]string)

func AddFirmwareSetFlag added in v1.0.2

func AddFirmwareSetFlag(cmd *cobra.Command, ptr *string)

func AddFirmwareVersionFlag added in v1.0.2

func AddFirmwareVersionFlag(cmd *cobra.Command, ptr *string)

func AddForceFlag added in v1.0.2

func AddForceFlag(cmd *cobra.Command, ptr *bool, usage string)

func AddFromFileFlag added in v1.0.2

func AddFromFileFlag(cmd *cobra.Command, ptr *string, usage string)

func AddLabelsFlag added in v1.0.2

func AddLabelsFlag(cmd *cobra.Command, ptr *map[string]string, usage string)

func AddListComponentsFlag added in v1.0.2

func AddListComponentsFlag(cmd *cobra.Command, ptr *bool)

func AddMacAOCFlag added in v1.0.2

func AddMacAOCFlag(cmd *cobra.Command, ptr *string)

func AddMacBMCFlag added in v1.0.2

func AddMacBMCFlag(cmd *cobra.Command, ptr *string)

func AddModelFlag added in v1.0.2

func AddModelFlag(cmd *cobra.Command, ptr *string)

func AddNameFlag added in v1.0.2

func AddNameFlag(cmd *cobra.Command, ptr *string, usage string)

func AddOutputFlag added in v1.0.2

func AddOutputFlag(cmd *cobra.Command, ptr *string)

func AddPageFlag added in v1.0.2

func AddPageFlag(cmd *cobra.Command, ptr *int)

func AddPageLimitFlag added in v1.0.2

func AddPageLimitFlag(cmd *cobra.Command, ptr *int)

func AddPowerOffRequiredFlag added in v1.0.2

func AddPowerOffRequiredFlag(cmd *cobra.Command, ptr *bool, usage string)

func AddPrintTableFlag added in v1.0.2

func AddPrintTableFlag(cmd *cobra.Command, ptr *bool)

func AddReAuthFlag added in v1.0.2

func AddReAuthFlag(cmd *cobra.Command, ptr *bool)

func AddServerFlag added in v1.0.2

func AddServerFlag(cmd *cobra.Command, ptr *string)

func AddServerPowerActionFlag added in v1.0.2

func AddServerPowerActionFlag(cmd *cobra.Command, ptr *string, params []string)

func AddServerPowerActionStatusFlag added in v1.0.2

func AddServerPowerActionStatusFlag(cmd *cobra.Command, ptr *bool)

func AddServerSerialFlag added in v1.0.2

func AddServerSerialFlag(cmd *cobra.Command, ptr *string)

func AddSkipBiosConfigFlag added in v1.0.2

func AddSkipBiosConfigFlag(cmd *cobra.Command, ptr *bool)

func AddSkipBmcResetFlag added in v1.0.2

func AddSkipBmcResetFlag(cmd *cobra.Command, ptr *bool)

func AddSkipFWStatusFlag added in v1.0.2

func AddSkipFWStatusFlag(cmd *cobra.Command, ptr *bool)

func AddSlugFlag added in v1.0.2

func AddSlugFlag(cmd *cobra.Command, ptr *string, usage string)

func AddVendorFlag added in v1.0.2

func AddVendorFlag(cmd *cobra.Command, ptr *string)

func AddWithBMCErrorsFlag added in v1.0.2

func AddWithBMCErrorsFlag(cmd *cobra.Command, ptr *bool)

func AddWithCredsFlag added in v1.0.2

func AddWithCredsFlag(cmd *cobra.Command, ptr *bool)

func AddWithRecordsFlag added in v1.0.2

func AddWithRecordsFlag(cmd *cobra.Command, ptr *bool)

func AttributeByNamespace

func AttributeByNamespace(ns string, attributes []fleetdbapi.Attributes) *fleetdbapi.Attributes

AttributeByNamespace returns the serverservice attribute in the slice that matches the namespace

TODO: move into common library and share with Alloy

func AttributeFromLabels

func AttributeFromLabels(ns string, labels map[string]string) (*fleetdbapi.Attributes, error)

func ConditionFromResponse added in v0.1.3

func ConditionFromResponse(response *coapiv1.ServerResponse) (rctypes.Condition, error)

ConditionFromResponse returns a Condition object from the Condition API ServerResponse object

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the RootCmd.

func FirmwareSetByVendorModel

func FirmwareSetByVendorModel(ctx context.Context, vendor, model string, client *fleetdbapi.Client) ([]fleetdbapi.ComponentFirmwareSet, error)

FirmwareSetByVendorModel returns the firmware set matched by the vendor, model attributes

TODO: move into common library

func FirmwareSetIDByVendorModel

func FirmwareSetIDByVendorModel(ctx context.Context, vendor, model string, client *fleetdbapi.Client) (uuid.UUID, error)

FirmwareSetIDByVendorModel returns the firmware set ID matched by the vendor, model attributes

TODO: move into common library

func FormatConditionResponse added in v0.1.3

func FormatConditionResponse(response *coapiv1.ServerResponse, kind rctypes.Kind) (string, error)

FormatConditionResponse returns a prettyish JSON formatted output that can be printed to stdout.

func MustCreateApp

func MustCreateApp(ctx context.Context) *app.App

func MutuallyExclusiveFlags added in v1.0.2

func MutuallyExclusiveFlags(cmd *cobra.Command, flags ...*flagDetails)

func PrintResults added in v1.0.1

func PrintResults(format string, data ...any)

func RequireFlag added in v1.0.2

func RequireFlag(cmd *cobra.Command, flagDetail *flagDetails)

func RequireOneFlag added in v1.0.2

func RequireOneFlag(cmd *cobra.Command, flags ...*flagDetails)

func ServerBMCCredentials added in v1.0.1

func ServerBMCCredentials(ctx context.Context, client *fleetdbapi.Client, server *rt.Server) error

Query server BMC credentials and update the given server object

func VendorModelFromAttrs

func VendorModelFromAttrs(attrs []fleetdbapi.Attributes) (vendor, model string)

VendorModelFromAttrs unpacks the attributes payload to return the vendor, model attributes for a server

TODO: move into common library and share with Alloy

Types

type ErrUnexpectedResponse added in v0.1.3

type ErrUnexpectedResponse struct {
	// contains filtered or unexported fields
}

func (*ErrUnexpectedResponse) Error added in v0.1.3

func (e *ErrUnexpectedResponse) Error() string

type FirmwareSetFlags

type FirmwareSetFlags struct {
	// labels are key values
	Labels map[string]string
	// id is the firmware set id
	ID string
	// list of firmware UUIDs to be added to the set
	AddFirmwareUUIDs []string
	// list of firmware UUIDs to be removed from the set
	RemoveFirmwareUUIDs []string
	// name for the firmware set to be created/edited
	FirmwareSetName string
	// create firmware set from file
	CreateFromFile string
	// ignore any create errors
	IgnoreCreateErrors bool
}

firmware set command flags

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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