utils

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SummaryResultsLegendPass is the symbol displayed in summary results table for pass.
	SummaryResultsLegendPass = "✔"
	// SummaryResultsLegendFail is the symbol displayed in summary results table for fail.
	SummaryResultsLegendFail = "✗"
	// SummaryResultsLegendSkip is the symbol displayed in summary results table for skip.
	SummaryResultsLegendSkip = "-"
	// SummaryResultsMinCommentSize is the minimum length of the comment string to be displayed.
	SummaryResultsMinCommentSize = 15
	// SummaryResultsTableMinWidth is the min width of a cell including padding in the summary results table.
	SummaryResultsTableMinWidth = 2
	// SummaryResultsTableTabWidth is the tab width to be used in the summary results table.
	SummaryResultsTableTabWidth = 2
	// SummaryResultsTablePadding is the padding added to the cell before computing its width.
	SummaryResultsTablePadding = 4
	// SummaryResultsTablePadChar is the char used for padding a cell in the table.
	SummaryResultsTablePadChar = ' '
)
View Source
const (
	SummaryResultsSkipped = iota // To represent that the operation was skipped.
	SummaryResultsPass           // To represent that the operation was a success.
	SummaryResultsFail           // To represent that the operation failed.
)

Enum to represent states of SummaryResults

View Source
const (
	InputDetails              string = "Please enter the details: "
	RequiredField             string = "is a required field. It cannot be blank/empty."
	WrongInput                string = "\n  WRONG INPUT!!\n"
	ChooseOption              string = "\n Choose an option\n"
	ChooseChromePlatform      string = "\n Choose a ChromePlatform\n"
	ChooseMachineLSEPrototype string = "\n Choose a MachineLSE Prototype\n"
	ChooseChameleonType       string = "\n Choose a ChameleonType \n"
	ChooseCameraType          string = "\n Choose a CameraType \n"
	ChooseAntennaConnection   string = "\n Choose an AntennaConnection \n"
	ChooseRouter              string = "\n Choose a Router \n"
	ChooseCableType           string = "\n Choose a Cable \n"
	ChooseCameraboxFacing     string = "\n Choose a Facing for CameraBox \n"
	ChoosePheripheralType     string = "\n Choose a PheripheralType \n"
	ChooseVirtualType         string = "\n Choose a VirtualType \n"
	OptionToEnter             string = "\nDo you want to enter a "
	OptionToEnterMore         string = "\nDo you want to enter one more "
	ChooseLab                 string = "\n Choose a Lab\n"
	ChooseZone                string = "\n Choose a Zone\n"
	BroswerOrOSLab            string = "1=\"Browser Lab\"\n2=\"OS Lab\"\n"
	BrowserOrATLOrACSLab      string = "1=\"Browser Lab\"\n2=\"ATL Lab\"\n3=\"ACS Lab\"\n"
	DutOrLabstationOrServer   string = "1=\"DUT\"\n2=\"Labstation\"\n3=\"Server\"\n"
	DoesNotExist              string = " doesnt not exist in the system. Please check and enter again."
	AlreadyExists             string = " already exists in the system. Please check and enter again."
	ATL                       string = "ATL"
	ACS                       string = "ACS"
	Browser                   string = "Browser"
	Unknown                   string = "Unknown"

	YesNo       string = " (y/n)"
	ATLLab      string = "atl:"
	ACSLab      string = "acs:"
	BrowserLab  string = "browser:"
	MinMaxError string = "Maximum value must be greater than or equal to Minimum value."
)

Interactive mode messages for user input

Variables

View Source
var (
	SwitchTitle               = []string{"Switch Name", "CapacityPort", "Zone", "Rack", "State", "UpdateTime"}
	KvmTitle                  = []string{"KVM Name", "MAC Address", "ChromePlatform", "CapacityPort", "Zone", "Rack", "State", "UpdateTime"}
	KvmFullTitle              = []string{"KVM Name", "MAC Address", "ChromePlatform", "CapacityPort", "IP", "Vlan", "State", "Zone", "Rack", "UpdateTime"}
	RpmTitle                  = []string{"RPM Name", "MAC Address", "CapacityPort", "Zone", "Rack", "State", "UpdateTime"}
	DracTitle                 = []string{"Drac Name", "Display name", "MAC Address", "Switch", "Switch Port", "Password", "Zone", "Rack", "Machine", "UpdateTime"}
	DracFullTitle             = []string{"Drac Name", "MAC Address", "Switch", "Switch Port", "Attached Host", "IP", "Vlan", "Zone", "Rack", "Machine", "UpdateTime"}
	NicTitle                  = []string{"Nic Name", "MAC Address", "Switch", "Switch Port", "Zone", "Rack", "Machine", "UpdateTime"}
	BrowserMachineTitle       = []string{"Machine Name", "Serial Number", "Zone", "Rack", "KVM", "KVM Port", "ChromePlatform", "DeploymentTicket", "Description", "State", "Realm", "UpdateTime"}
	OSMachineTitle            = []string{"Machine Name", "Zone", "Rack", "Barcode", "Hardware ID", "Model", "DeviceType", "MacAddress", "SKU", "Phase", "Build Target", "State", "Realm", "UpdateTime"}
	MachinelseprototypeTitle  = []string{"Machine Prototype Name", "Occupied Capacity", "PeripheralTypes", "VirtualTypes", "Tags", "UpdateTime"}
	RacklseprototypeTitle     = []string{"Rack Prototype Name", "PeripheralTypes", "Tags", "UpdateTime"}
	ChromePlatformTitle       = []string{"Platform Name", "Manufacturer", "Description", "UpdateTime"}
	VlanTitle                 = []string{"Vlan Name", "CIDR Block", "IP Capacity", "DHCP range", "Description", "State", "Zones", "Reserved IPs", "UpdateTime"}
	VMTitle                   = []string{"VM Name", "OS Version", "MAC Address", "Zone", "Host", "Vlan", "IP", "State", "DeploymentTicket", "Description", "UpdateTime"}
	RackTitle                 = []string{"Rack Name", "Zone", "Capacity", "State", "Realm", "UpdateTime"}
	MachineLSETitle           = []string{"Host", "OS Version", "Zone", "Virtual Datacenter", "Rack", "Machine(s)", "Nic", "Vlan", "IP", "State", "VM capacity", "DeploymentTicket", "Description", "UpdateTime"}
	MachineLSEFullTitle       = []string{"Host", "OS Version", "Manufacturer", "Machine", "Zone", "Virtual Datacenter", "Rack", "Nic", "IP", "Vlan", "MAC Address", "State", "VM capacity", "Description", "UpdateTime"}
	MachineLSEDeploymentTitle = []string{"Serial Number", "Hostname", "Deployment Identifier", "Deployment Env", "UpdateTime"}
	VMFreeSlotTitle           = []string{"Host", "OS Version", "Zone", "Virtual Datacenter", "Rack", "Machine(s)", "Nic", "Vlan", "IP", "State", "Free slots", "DeploymentTicket", "Description", "UpdateTime"}
	VMFreeSlotFullTitle       = []string{"Host", "OS Version", "Manufacturer", "Machine", "Zone", "Virtual Datacenter", "Rack", "Nic", "IP", "Vlan", "MAC Address", "State", "Free slots", "Description", "UpdateTime"}
	ZoneTitle                 = []string{"Name", "EnumName", "Department"}
	StateTitle                = []string{"Name", "EnumName", "Description"}
	AssetTitle                = []string{"Asset Name", "Zone", "Rack", "Barcode", "Serial Number", "Hardware ID", "Model", "AssetType", "MacAddress", "SKU", "Phase", "Build Target", "Realm", "UpdateTime"}
	CachingServiceTitle       = []string{"CachingService Name", "Port", "Subnets", "Primary", "Secondary", "State", "Description", "UpdateTime"}
	SchedulingUnitTitle       = []string{"SchedulingUnit Name", "DUTs", "Pools", "Type", "Description", "UpdateTime"}
)

Titles for printing table format list

View Source
var ClearFieldValue string = "-"

ClearFieldValue specifying this value in update command will send empty value while doing partial updates using update field mask.

Functions

func BatchList

func BatchList(ctx context.Context, ic ufsAPI.FleetClient, listFunc listAll, filters []string, pageSize int, keysOnly, full bool) ([]proto.Message, error)

BatchList returns the all listed entities by filters

func CSVString

func CSVString(s *[]string) flag.Getter

CSVString returns a flag.Getter which reads flags into the given []string pointer.

func CheckExistsVM

func CheckExistsVM(existingVMs []*ufspb.VM, vmName string) bool

CheckExistsVM checks if the given vm already exists in the slice

func ChromePlatformExists

func ChromePlatformExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

ChromePlatformExists checks if the given ChromePlatform exists in the system

func ConcurrentDelete

func ConcurrentDelete(ctx context.Context, ic ufsAPI.FleetClient, names []string, deleteSingle deleteSingleFunc) ([]string, []string)

ConcurrentDelete runs multiple goroutines making Delete calls to UFS

func ConcurrentGet

func ConcurrentGet(ctx context.Context, ic ufsAPI.FleetClient, names []string, getSingle getSingleFunc) []proto.Message

ConcurrentGet runs multiple goroutines making Get calls to UFS

func DoList

func DoList(ctx context.Context, ic ufsAPI.FleetClient, listFunc listAll, pageSize int32, filter string, keysOnly, full bool) ([]proto.Message, error)

DoList lists the outputs

func DracExists

func DracExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

DracExists checks if the given Drac exists in the system

func EntityExists

func EntityExists(ctx context.Context, ic UfleetAPI.FleetClient, resource, name string) bool

EntityExists checks if the given resource exists in the system

func FullMode

func FullMode(full bool) bool

FullMode checks if full mode is enabled

func GenerateAssetUpdate

func GenerateAssetUpdate(hostname, machine, model, board, zone, rack string) (*ufspb.Asset, []string, error)

GenerateAssetUpdate generates an AssetUpdate request for location, model and board updates

func GetAssetsInOrder

func GetAssetsInOrder(logFile string) ([]*fleet.ChopsAsset, error)

GetAssetsInOrder reads a group of assets from log file.

func GetChromePlatformInteractiveInput

func GetChromePlatformInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, cp *fleet.ChromePlatform, update bool)

GetChromePlatformInteractiveInput gets ChromePlatform input in interactive mode

Name(string) -> Manufacturer(string) -> Description(string)

func GetDracInteractiveInput

func GetDracInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, drac *fleet.Drac, update bool) string

GetDracInteractiveInput get drac input in interactive mode

Name(string) -> Display name(string) -> MAC Address(string) -> -> SwitchInterface[Switch(string, resource) -> Switch Port(int)] -> -> Password(string)

func GetInteractiveInput

func GetInteractiveInput() []string

GetInteractiveInput collects the scanned string list.

func GetKVMInteractiveInput

func GetKVMInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, kvm *fleet.KVM, update bool) string

GetKVMInteractiveInput get kvm input in interactive mode

Name(string) -> MAC Address(string) -> ChromePlatform(string, resource) -> -> CapacityPort(int) -> Rack name(string)

func GetLocation

func GetLocation(input string) (*ufspb.Location, error)

GetLocation returns Location proto from barcode name

func GetMachineInteractiveInput

func GetMachineInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, machine *fleet.Machine, update bool)

GetMachineInteractiveInput get Machine input in interactive mode

Name(string) -> Lab(enum) -> Browser/OS LAB(choice to branch) -> -> getBrowserMachine()/getOSMachine() -> Realm(string)

func GetMachinelseInteractiveInput

func GetMachinelseInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, machinelse *fleet.MachineLSE, update bool)

GetMachinelseInteractiveInput get MachineLSE input in interactive mode

Name(string) -> Broswer/ATL/ACS LAB(choice to branch) -> -> getBrowserMachineLse()/getOSMachineLse() -> -> Machine(repeated string, resource)

func GetMachinelsePrototypeInteractiveInput

func GetMachinelsePrototypeInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, mlsep *fleet.MachineLSEPrototype, update bool)

GetMachinelsePrototypeInteractiveInput gets MachineLSEPrototype input in interactive mode

Name(string) -> Broswer/ATL/ACS LAB(choice) -> Occupied Capacity(int) -> -> getPeripheralRequirements() -> getVirtualRequirements()

func GetNextPage

func GetNextPage(pageToken string) (bool, error)

GetNextPage gets user input for to get next page of items

func GetNicInteractiveInput

func GetNicInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, nic *fleet.Nic, update bool) string

GetNicInteractiveInput get nic input in interactive mode

Name(string) -> MAC Address(string) -> -> SwitchInterface[Switch(string, resource) -> Switch Port(int)] -> -> Machine name(string)

func GetRPMInteractiveInput

func GetRPMInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, rpm *fleet.RPM)

GetRPMInteractiveInput get rpm input in interactive mode

Name(string) -> Rack name(string) -> MAC Address(string) -> CapacityPort(int)

func GetRackInteractiveInput

func GetRackInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, req *UfleetAPI.RackRegistrationRequest)

GetRackInteractiveInput get rack input in interactive mode

Name(string) -> Rack name(string) -> CapacityPort(int)

func GetRacklsePrototypeInteractiveInput

func GetRacklsePrototypeInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, rlsep *fleet.RackLSEPrototype, update bool)

GetRacklsePrototypeInteractiveInput gets RackLSEPrototype input in interactive mode

Name(string) -> Broswer/ATL/ACS LAB(choice) -> getPeripheralRequirements()

func GetStringSlice

func GetStringSlice(msg string) []string

GetStringSlice converts the comma separated string to a slice of strings

func GetSwitchInteractiveInput

func GetSwitchInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, s *fleet.Switch)

GetSwitchInteractiveInput get switch input in interactive mode

Name(string) -> Rack name(string) -> CapacityPort(int)

func GetUpdateMask

func GetUpdateMask(set *flag.FlagSet, paths map[string]string) *field_mask.FieldMask

GetUpdateMask returns a *field_mask.FieldMask containing paths based on which flags have been set.

paths is a map of cmd line option flags to field names of the object.

func IsCSVFile

func IsCSVFile(filename string) bool

IsCSVFile return true if its a csv file

func IsDUT

func IsDUT(lse *ufspb.MachineLSE) error

IsDUT returns nil if lse represents DUT or returns error with a reason

func IsLocation

func IsLocation(iput string) bool

IsLocation determines if a string describes a ChromeOS lab location

func JoinFilters

func JoinFilters(old []string, filters ...string) []string

JoinFilters joins several filters together

func KVMExists

func KVMExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

KVMExists checks if the given KVM exists in the system

func LooksLikeHeader

func LooksLikeHeader(rec []string) bool

LooksLikeHeader heuristically determines whether a CSV line looks like a CSV header for the MCSV format.

func MachineExists

func MachineExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

MachineExists checks if the given Machine exists in the system

func MachineLSEExists

func MachineLSEExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

MachineLSEExists checks if the given MachineLSE exists in the system

func MachineLSEPrototypeExists

func MachineLSEPrototypeExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

MachineLSEPrototypeExists checks if the given MachineLSEPrototype exists in the system

func NicExists

func NicExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

NicExists checks if the given Nic exists in the system

func NoEmitMode

func NoEmitMode(noemit bool) bool

NoEmitMode checks if emit mode is enabled for json output

func ParseJSONFile

func ParseJSONFile(jsonFile string, pm proto.Message) error

ParseJSONFile parses json input from the user provided file.

func ParseMCSVFile

func ParseMCSVFile(specsFile string) ([][]string, error)

ParseMCSVFile parse a mcsv file and return the records as 2D string slice

func PrefixFilters

func PrefixFilters(prefix string, filters []string) []string

PrefixFilters returns a group of filter strings with prefix

func PrintAllNormal

func PrintAllNormal(title []string, res [][]string, keysOnly bool)

PrintAllNormal prints a 2D slice with tabwriter

func PrintAllTSVs

func PrintAllTSVs(res [][]string)

PrintAllTSVs prints all in tsv format of the input

func PrintAssets

func PrintAssets(res []proto.Message, keysOnly bool)

PrintAssets prints the all assets in table form.

func PrintAssetsJSON

func PrintAssetsJSON(res []proto.Message, emit bool)

PrintAssetsJSON prints the asset details in json format.

func PrintCachingServices

func PrintCachingServices(res []proto.Message, keysOnly bool)

PrintCachingServices prints the all CachingServices in table form.

func PrintCachingServicesJSON

func PrintCachingServicesJSON(res []proto.Message, emit bool)

PrintCachingServicesJSON prints the CachingService details in json format.

func PrintChromePlatforms

func PrintChromePlatforms(res []proto.Message, keysOnly bool)

PrintChromePlatforms prints the all msleps in table form.

func PrintChromePlatformsJSON

func PrintChromePlatformsJSON(res []proto.Message, emit bool)

PrintChromePlatformsJSON prints the mslep details in json format.

func PrintDracFull

func PrintDracFull(entities []*ufspb.Drac, dhcps map[string]*ufspb.DHCPConfig)

PrintDracFull prints the full related msg for drac

func PrintDracs

func PrintDracs(res []proto.Message, keysOnly bool)

PrintDracs prints the all dracs in table form.

func PrintDracsJSON

func PrintDracsJSON(res []proto.Message, emit bool)

PrintDracsJSON prints the drac details in json format.

func PrintDutsFull

func PrintDutsFull(duts []*ufspb.MachineLSE, machineMap map[string]*ufspb.Machine)

PrintDutsFull prints the most commonly used dut information in a human-readable format along with Machine information.

TODO(xixuan): remove the similar function for skylab tooling package

func PrintDutsShort

func PrintDutsShort(res []proto.Message, keysOnly bool)

PrintDutsShort prints only the dut info from MachineLSE

func PrintEntities

func PrintEntities(ctx context.Context, ic ufsAPI.FleetClient, res []proto.Message, printJSON printJSONFunc, printFull printFullFunc, printNormal printNormalFunc, json, emit, full, tsv, keysOnly bool) error

PrintEntities a batch of entities based on user parameters

func PrintExistingAsset

func PrintExistingAsset(ctx context.Context, ic ufsAPI.FleetClient, name string) (*ufspb.Asset, error)

PrintExistingAsset prints the old asset in update/delete operations.

func PrintExistingCachingService

func PrintExistingCachingService(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingCachingService prints the old CachingService in update/delete operations

func PrintExistingDUT

func PrintExistingDUT(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingDUT prints the old host in update/delete operations

func PrintExistingDrac

func PrintExistingDrac(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingDrac prints the old drac in update/delete operations

func PrintExistingHost

func PrintExistingHost(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingHost prints the old host in update/delete operations

func PrintExistingKVM

func PrintExistingKVM(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingKVM prints the old kvm in update/delete operations

func PrintExistingLSEDeploymentRecord

func PrintExistingLSEDeploymentRecord(ctx context.Context, ic ufsAPI.FleetClient, name string)

PrintExistingLSEDeploymentRecord prints the old deployment record in update/delete operations

func PrintExistingMachine

func PrintExistingMachine(ctx context.Context, ic ufsAPI.FleetClient, name string) (*ufspb.Machine, error)

PrintExistingMachine prints the old machine in update/delete operations.

func PrintExistingMachinePrototype

func PrintExistingMachinePrototype(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingMachinePrototype prints the old machine prototype in update/delete operations

func PrintExistingNic

func PrintExistingNic(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingNic prints the old nic in update/delete operations

func PrintExistingPlatform

func PrintExistingPlatform(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingPlatform prints the old platform in update/delete operations

func PrintExistingRPM

func PrintExistingRPM(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingRPM prints the old rpm in update/delete operations

func PrintExistingRack

func PrintExistingRack(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingRack prints the old rack in update/delete operations

func PrintExistingRackPrototype

func PrintExistingRackPrototype(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingRackPrototype prints the old rack prototype in update/delete operations

func PrintExistingSchedulingUnit

func PrintExistingSchedulingUnit(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingSchedulingUnit prints the old SchedulingUnit in update/delete operations

func PrintExistingSwitch

func PrintExistingSwitch(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingSwitch prints the old switch in update/delete operations

func PrintExistingVM

func PrintExistingVM(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingVM prints the old vm in update/delete operations

func PrintExistingVlan

func PrintExistingVlan(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingVlan prints the old vlan update/delete operations

func PrintJSON

func PrintJSON(t interface{}) error

PrintJSON prints the interface output as json

func PrintKVMFull

func PrintKVMFull(kvms []*ufspb.KVM, dhcps map[string]*ufspb.DHCPConfig)

PrintKVMFull prints the full info for kvm

func PrintKVMs

func PrintKVMs(res []proto.Message, keysOnly bool)

PrintKVMs prints the all kvms in table form.

func PrintKVMsJSON

func PrintKVMsJSON(res []proto.Message, emit bool)

PrintKVMsJSON prints the kvm details in json format.

func PrintListJSONFormat

func PrintListJSONFormat(ctx context.Context, ic ufsAPI.FleetClient, f printAll, json bool, pageSize int32, filter string, keysOnly, emit bool) error

PrintListJSONFormat prints the list output in JSON format

func PrintListTableFormat

func PrintListTableFormat(ctx context.Context, ic ufsAPI.FleetClient, f printAll, json bool, pageSize int32, filter string, keysOnly bool, title []string, tsv bool) error

PrintListTableFormat prints list output in Table format

func PrintLogStats

func PrintLogStats(l LogStatsList, limit int, reverse bool)

PrintLogStats prints infos for a batch of audit scan runs.

func PrintLogStatsAndResult

func PrintLogStatsAndResult(l *LogStats, index int)

PrintLogStatsAndResult prints the stats and results for a specified audit scan run.

func PrintMachineLSEDeployments

func PrintMachineLSEDeployments(res []proto.Message, keysOnly bool)

PrintMachineLSEDeployments prints a list of machine lse deployment records

func PrintMachineLSEDeploymentsJSON

func PrintMachineLSEDeploymentsJSON(res []proto.Message, emit bool)

PrintMachineLSEDeploymentsJSON prints the machine lse deployment records details in json format.

func PrintMachineLSEFull

func PrintMachineLSEFull(entities []*ufspb.MachineLSE, dhcps map[string]*ufspb.DHCPConfig)

PrintMachineLSEFull prints the full info for a host

func PrintMachineLSEPrototypes

func PrintMachineLSEPrototypes(res []proto.Message, keysOnly bool)

PrintMachineLSEPrototypes prints the all msleps in table form.

func PrintMachineLSEPrototypesJSON

func PrintMachineLSEPrototypesJSON(res []proto.Message, emit bool)

PrintMachineLSEPrototypesJSON prints the mslep details in json format.

func PrintMachineLSEs

func PrintMachineLSEs(res []proto.Message, keysOnly bool)

PrintMachineLSEs prints the all machinelses in table form.

func PrintMachineLSEsJSON

func PrintMachineLSEsJSON(res []proto.Message, emit bool)

PrintMachineLSEsJSON prints the machinelse details in json format.

func PrintMachines

func PrintMachines(res []proto.Message, keysOnly bool)

PrintMachines prints the all machines in table form.

func PrintMachinesJSON

func PrintMachinesJSON(res []proto.Message, emit bool)

PrintMachinesJSON prints the machine details in json format.

func PrintNics

func PrintNics(res []proto.Message, keysOnly bool)

PrintNics prints the all nics in table form.

func PrintNicsJSON

func PrintNicsJSON(res []proto.Message, emit bool)

PrintNicsJSON prints the nic details in json format.

func PrintProtoJSON

func PrintProtoJSON(pm proto.Message, emit bool)

PrintProtoJSON prints the output as json

func PrintRPMs

func PrintRPMs(res []proto.Message, keysOnly bool)

PrintRPMs prints the all rpms in table form.

func PrintRPMsJSON

func PrintRPMsJSON(res []proto.Message, emit bool)

PrintRPMsJSON prints the rpm details in json format.

func PrintRackLSEPrototypes

func PrintRackLSEPrototypes(res []proto.Message, keysOnly bool)

PrintRackLSEPrototypes prints the all msleps in table form.

func PrintRackLSEPrototypesJSON

func PrintRackLSEPrototypesJSON(res []proto.Message, emit bool)

PrintRackLSEPrototypesJSON prints the mslep details in json format.

func PrintRacks

func PrintRacks(res []proto.Message, keysOnly bool)

PrintRacks prints the all racks in table form.

func PrintRacksJSON

func PrintRacksJSON(res []proto.Message, emit bool)

PrintRacksJSON prints the rack details in json format.

func PrintSchedulingUnits

func PrintSchedulingUnits(res []proto.Message, keysOnly bool)

PrintSchedulingUnits prints the all SchedulingUnits in table form.

func PrintSchedulingUnitsJSON

func PrintSchedulingUnitsJSON(res []proto.Message, emit bool)

PrintSchedulingUnitsJSON prints the SchedulingUnit details in json format.

func PrintSwitches

func PrintSwitches(res []proto.Message, keysOnly bool)

PrintSwitches prints the all switches in table form.

func PrintSwitchesJSON

func PrintSwitchesJSON(res []proto.Message, emit bool)

PrintSwitchesJSON prints the switch details in json format.

func PrintTSVAssets

func PrintTSVAssets(msgs []proto.Message, keysOnly bool)

PrintTSVAssets prints the tsv format of assets

func PrintTSVCachingServices

func PrintTSVCachingServices(msgs []proto.Message, keysOnly bool)

PrintTSVCachingServices prints the tsv format of CachingServices

func PrintTSVDracFull

func PrintTSVDracFull(drac *ufspb.Drac, dhcp *ufspb.DHCPConfig)

PrintTSVDracFull prints the full related msg for drac in tsv mode

func PrintTSVDracs

func PrintTSVDracs(msgs []proto.Message, keysOnly bool)

PrintTSVDracs prints the tsv format of dracs

func PrintTSVHostFull

func PrintTSVHostFull(lse *ufspb.MachineLSE, dhcp *ufspb.DHCPConfig)

PrintTSVHostFull prints the full related msg for host in tsv mode

func PrintTSVKVMFull

func PrintTSVKVMFull(kvm *ufspb.KVM, dhcp *ufspb.DHCPConfig)

PrintTSVKVMFull prints the full related msg for kvm in tsv mode

func PrintTSVKVMs

func PrintTSVKVMs(res []proto.Message, keysOnly bool)

PrintTSVKVMs prints the tsv format of kvms

func PrintTSVMachineLSEDeployments

func PrintTSVMachineLSEDeployments(msgs []proto.Message, keysOnly bool)

PrintTSVHostFull prints the full related msg for host in tsv mode

func PrintTSVMachineLSEPrototypes

func PrintTSVMachineLSEPrototypes(msgs []proto.Message, keysOnly bool)

PrintTSVMachineLSEPrototypes prints the tsv format of machine lse prototypes

func PrintTSVMachineLSEs

func PrintTSVMachineLSEs(msgs []proto.Message, keysOnly bool)

PrintTSVMachineLSEs prints the tsv format of machine lses

func PrintTSVMachines

func PrintTSVMachines(msgs []proto.Message, keysOnly bool)

PrintTSVMachines prints the tsv format of machines

func PrintTSVNics

func PrintTSVNics(msgs []proto.Message, keysOnly bool)

PrintTSVNics prints the tsv format of nics

func PrintTSVPlatforms

func PrintTSVPlatforms(msgs []proto.Message, keysOnly bool)

PrintTSVPlatforms prints the tsv format of chrome platforms

func PrintTSVRPMs

func PrintTSVRPMs(msgs []proto.Message, keysOnly bool)

PrintTSVRPMs prints the tsv format of rpms

func PrintTSVRackLSEPrototypes

func PrintTSVRackLSEPrototypes(msgs []proto.Message, keysOnly bool)

PrintTSVRackLSEPrototypes prints the tsv format of rack lse prototypes

func PrintTSVRacks

func PrintTSVRacks(msgs []proto.Message, keysOnly bool)

PrintTSVRacks prints the tsv format of racks

func PrintTSVSchedulingUnits

func PrintTSVSchedulingUnits(msgs []proto.Message, keysOnly bool)

PrintTSVSchedulingUnits prints the tsv format of SchedulingUnits

func PrintTSVSwitches

func PrintTSVSwitches(msgs []proto.Message, keysOnly bool)

PrintTSVSwitches prints the tsv format of switches

func PrintTSVVMs

func PrintTSVVMs(msgs []proto.Message, keysOnly bool)

PrintTSVVMs prints the tsv format of vms

func PrintTSVVlans

func PrintTSVVlans(msgs []proto.Message, keysOnly bool)

PrintTSVVlans prints the tsv format of vlans

func PrintTableTitle

func PrintTableTitle(title []string, tsv, keysOnly bool)

PrintTableTitle prints the table title with parameters

func PrintTitle

func PrintTitle(title []string)

PrintTitle prints the title fields in table form.

func PrintVMs

func PrintVMs(res []proto.Message, keysOnly bool)

PrintVMs prints the all vms in table form.

func PrintVMsJSON

func PrintVMsJSON(res []proto.Message, emit bool)

PrintVMsJSON prints the vm details in json format.

func PrintVlans

func PrintVlans(res []proto.Message, keysOnly bool)

PrintVlans prints the all vlans in table form.

func PrintVlansJSON

func PrintVlansJSON(res []proto.Message, emit bool)

PrintVlansJSON prints the vlan details in json format.

func RPMExists

func RPMExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

RPMExists checks if the given RPM exists in the system

func RackExists

func RackExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

RackExists checks if the given Rack exists in the system

func RackLSEPrototypeExists

func RackLSEPrototypeExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

RackLSEPrototypeExists checks if the given RackLSEPrototype exists in the system

func RemoveVM

func RemoveVM(existingVMs []*ufspb.VM, vmName string) []*ufspb.VM

RemoveVM removes the given vm from the slice

func SetupContext

func SetupContext(ctx context.Context, namespace string) context.Context

SetupContext sets up context with namespace

func SwitchExists

func SwitchExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

SwitchExists checks if the given Switch exists in the system

func ValidateSameStringArray

func ValidateSameStringArray(expected []string, actual []string) error

ValidateSameStringArray validates if 2 strings slice are same

func VlanExists

func VlanExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

VlanExists checks if the given Vlan exists in the system

Types

type AssetStats

type AssetStats struct {
	Asset    *fleet.ChopsAsset
	Action   string
	ErrorMsg string
}

AssetStats to store the statistics of a chops asset

type CSVStringFlag

type CSVStringFlag []string

CSVStringFlag is a flag.Getter implementation representing a []string.

func (CSVStringFlag) Get

func (f CSVStringFlag) Get() interface{}

Get retrieves the flag value.

func (*CSVStringFlag) Set

func (f *CSVStringFlag) Set(val string) error

Set records seeing a flag value.

func (CSVStringFlag) String

func (f CSVStringFlag) String() string

String returns a comma-separated string representation of the flag values.

type CSVWriter

type CSVWriter struct {
	*csv.Writer
}

CSVWriter refers to a customized csv writer

func NewCSVWriter

func NewCSVWriter() *CSVWriter

NewCSVWriter creates a new csv writer

type Input

type Input struct {
	Key      string
	Desc     string
	Required bool
}

Input deatils for the input variable

Key - input variable name Desc - description of the variable Required - if the variable is a required field

type LogStats

type LogStats struct {
	LogPath string
	ResPath string
	Tstamp  time.Time
	// The times that we scan an asset in the run
	ScannedAssetCount int
	// The times that we scan a location in the run
	ScannedLocationCount int
	SuccessfulAssetScan  int
	FailedAssetScan      int

	ScannedAssets    map[string]*AssetStats
	ScannedLocations map[string]bool
	MismatchedAssets map[string]*AssetStats
	// The failure when generating the stats
	FailureMsg []string
}

LogStats to store the statistics of any given run

type LogStatsList

type LogStatsList []*LogStats

LogStatsList refers to a list of log stats.

func ListLogs

func ListLogs(dir string) (LogStatsList, error)

ListLogs lists the logs and return the stats for each of the audit runs.

func (LogStatsList) Len

func (l LogStatsList) Len() int

func (LogStatsList) Less

func (l LogStatsList) Less(i, j int) bool

LogStats sort functions

func (LogStatsList) Swap

func (l LogStatsList) Swap(i, j int)

type PromptFunc

type PromptFunc func(string) bool

PromptFunc obtains consent from the user for the given request string.

This function is used to provide the user some context through the provided string and then obtain a yes/no answer from the user.

func CLIPrompt

func CLIPrompt(w io.Writer, r io.Reader, defaultResponse bool) PromptFunc

CLIPrompt returns a PromptFunc to prompt user on CLI.

If user set environment NO_PROMPT=true, it will returns a nil PromptFunc In case of erroneous input from user, the returned PromptFunc prompts the user again. defaultResponse is returned on empty response from the user. In case of other system errors, the returned promptFunc returns false.

type SummaryResultsTable

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

SummaryResultsTable is used to print the summary of operations.

func NewSummaryResultsTable

func NewSummaryResultsTable(cols []string) *SummaryResultsTable

NewSummaryResultsTable constructs a new SummaryResultsTable.

func (*SummaryResultsTable) IsSuccessForAny

func (sRes *SummaryResultsTable) IsSuccessForAny(operation string) bool

IsSuccessForAny returns true if the operation succeeded for any of the entities.

func (*SummaryResultsTable) PrintResultsTable

func (sRes *SummaryResultsTable) PrintResultsTable(out *os.File, fitWidth bool)

PrintResultsTable prints a summary table of the results of operations. Comments are truncated to fit terminal width if fitWidth is true. Doesn't truncate anything, if it results in comment becoming smaller than SummaryResultsMinCommentSize.

func (*SummaryResultsTable) RecordResult

func (sRes *SummaryResultsTable) RecordResult(operation, entity string, res error)

RecordResult records the res for operation on entity.

func (*SummaryResultsTable) RecordSkip

func (sRes *SummaryResultsTable) RecordSkip(operation, entity, reason string)

RecordSkip records an operation that was skipped.

type Updater

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

Updater is used to asynchronously update to datastore and write logs while doing so. This helps to save work and restart the application in case an update fails

func NewUpdater

func NewUpdater(ctx context.Context, c fleetAPI.InventoryClient, gsc gs.Client, logDir, username string) (u *Updater, err error)

NewUpdater create a new updater

func (*Updater) AddAsset

func (u *Updater) AddAsset(assetList []*fleet.ChopsAsset)

AddAsset asynchronously adds asset

func (*Updater) Close

func (u *Updater) Close()

Close terminates the Updater object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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