xnametypes

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 4 Imported by: 19

Documentation

Overview

MIT License

(C) Copyright 2018-2023 Hewlett Packard Enterprise Development LP

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ControllerHasChassis

func ControllerHasChassis(hmsType HMSType) bool

Normally every controller should has 1+ Chassis, but certain special types may not, and we don't use them if even if they are there.

func ControllerHasChassisStr

func ControllerHasChassisStr(hmsTypeStr string) bool

String version of above.

func ControllerHasSystems

func ControllerHasSystems(hmsType HMSType) bool

Returns whether hmsType does not expect System collections to be present, or if so, non-empty.

func ControllerHasSystemsStr

func ControllerHasSystemsStr(hmsTypeStr string) bool

String version of above.

func GetHMSCompParent

func GetHMSCompParent(xname string) string

Given a properly formatted xname, get its immediate parent.

i.e. x0c0s22b11 would become x0c0s22

func GetHMSCompRecognitionTable

func GetHMSCompRecognitionTable() map[string]HMSCompRecognitionEntry

func GetHMSTypeFormatString

func GetHMSTypeFormatString(hmsType HMSType) (string, int, error)

GetHMSTypeFormatString for a given HMSType will return the corresponding fmt.Sprintf compatible format string, and the number of verbs are required for the format string.

func GetHMSTypeList

func GetHMSTypeList() []string

func GetHMSTypeRegex

func GetHMSTypeRegex(hmsType HMSType) (*regexp.Regexp, error)

GetHMSTypeRegex for a given HMSType will return the regular expression that matches to match xnames of that HMSType.

func GetHMSTypeString

func GetHMSTypeString(xname string) string

Get the HMSType for a given xname, based on its pattern in the recognition table above (string version). If no type matches, the empty string is returned.

func IsHMSCompIDValid

func IsHMSCompIDValid(xname string) bool

Returns true if xname is valid, i.e. matches some format for a valid HMS component type. False if it is invalid.

func IsHMSTypeContainer

func IsHMSTypeContainer(hmsType HMSType) bool

Returns whether hmsType is a container type, i.e. that contains other components but is not a logical type (i.e. Node, that may or may not be a discrete hardware module), or a specialized terminal subcomponent (HSNAsic, Processor, etc.)

NOTE: This is used specifically for Redfish "Chassis" components. so non-Chassis (e.g. PDUs) don't apply (different type, outlets are not really separate physical pieces)

func IsHMSTypeController

func IsHMSTypeController(hmsType HMSType) bool

Returns whether hmsType is a controller type, i.e. that would host a Redfish entry point

func IsHMSTypeStrContainer

func IsHMSTypeStrContainer(hmsTypeStr string) bool

Returns whether hmsTypeStr matches a container type, i.e. that contains other components but is not a logical type (i.e. Node, that may or may not be a discrete hardware module), or a specialized terminal subcomponent (HSNAsic, Processor, etc.)

func IsHMSTypeStrController

func IsHMSTypeStrController(hmsTypeStr string) bool

Returns whether hmsTypeStr matches a controller type, i.e. that would host a Redfish entry point

func NormalizeHMSCompID

func NormalizeHMSCompID(xname string) string

This lower-cases the xname id does other normalization so we always represent the same location with the same string. NOTE: this does not validate the xname, so do not use it to see if it is valid. However, any string post normalization should still be as invalid or valid as an xname as it was prior to this call.

func RemoveLeadingZeros added in v1.0.1

func RemoveLeadingZeros(s string) string

Remove leading zeros, i.e. for each run of numbers, trim off leading zeros so each run starts with either non-zero, or is a single zero. This has been duplicated from hms-base, but it allows the packages to be independent.

func ValidateCompIDs

func ValidateCompIDs(compIDs []string, dupsValid bool) ([]string, []string)

ValidateCompIDs validates an array of component IDs (xnames) into valid and invalid arrays optionally adding duplicates to the invalid array or discarding them.

func VerifyNormalizeCompID

func VerifyNormalizeCompID(idStr string) string

Returns the given xname ID string (adjusting for any capitalization and whitespace and leading zero differences) if a valid xname was given. Else, return the empty string.

func VerifyNormalizeType

func VerifyNormalizeType(typeStr string) string

Returns the given HMS type string (adjusting any capitalization differences), if a valid HMS component type was given. Else, return the empty string.

Types

type HMSCompRecognitionEntry

type HMSCompRecognitionEntry struct {
	Type          HMSType
	ParentType    HMSType
	ExampleString string
	Regex         *regexp.Regexp
	GenStr        string
	NumArgs       int
}

type HMSType

type HMSType string
const (
	CDU                      HMSType = "CDU"                      // dD
	CDUMgmtSwitch            HMSType = "CDUMgmtSwitch"            // dDwW
	CabinetCDU               HMSType = "CabinetCDU"               // xXdD
	Cabinet                  HMSType = "Cabinet"                  // xX
	CabinetBMC               HMSType = "CabinetBMC"               // xXbB
	CabinetPDUController     HMSType = "CabinetPDUController"     // xXmM
	CabinetPDU               HMSType = "CabinetPDU"               // xXmMpP
	CabinetPDUNic            HMSType = "CabinetPDUNic"            // xXmMiI
	CabinetPDUOutlet         HMSType = "CabinetPDUOutlet"         // xXmMpPjJ DEPRECATED
	CabinetPDUPowerConnector HMSType = "CabinetPDUPowerConnector" // xXmMpPvV

	Chassis                  HMSType = "Chassis"                  // xXcC
	ChassisBMC               HMSType = "ChassisBMC"               // xXcCbB
	ChassisBMCNic            HMSType = "ChassisBMCNic"            // xXcCbBiI
	CMMRectifier             HMSType = "CMMRectifier"             // xXcCtT
	CMMFpga                  HMSType = "CMMFpga"                  // xXcCfF
	CEC                      HMSType = "CEC"                      // xXeE
	ComputeModule            HMSType = "ComputeModule"            // xXcCsS
	RouterModule             HMSType = "RouterModule"             // xXcCrR
	NodeBMC                  HMSType = "NodeBMC"                  // xXcCsSbB
	NodeBMCNic               HMSType = "NodeBMCNic"               // xXcCsSbBiI
	NodeEnclosure            HMSType = "NodeEnclosure"            // xXcCsSeE
	NodeEnclosurePowerSupply HMSType = "NodeEnclosurePowerSupply" // xXcCsSeEtT
	NodePowerConnector       HMSType = "NodePowerConnector"       // xXcCsSjJ
	Node                     HMSType = "Node"                     // xXcCsSbBnN
	VirtualNode              HMSType = "VirtualNode"              // xXcCsSbBnNvV
	Processor                HMSType = "Processor"                // xXcCsSbBnNpP
	StorageGroup             HMSType = "StorageGroup"             // xXcCsSbBnNgG
	Drive                    HMSType = "Drive"                    // xXcCsSbBnNgGkK
	NodeNic                  HMSType = "NodeNic"                  // xXcCsSbBnNiI
	NodeHsnNic               HMSType = "NodeHsnNic"               // xXcCsSbBnNhH
	Memory                   HMSType = "Memory"                   // xXcCsSbBnNdD
	NodeAccel                HMSType = "NodeAccel"                // xXcCsSbBnNaA
	NodeAccelRiser           HMSType = "NodeAccelRiser"           // xXcCsSbBnNrR
	NodeFpga                 HMSType = "NodeFpga"                 // xXcCsSbBfF
	HSNAsic                  HMSType = "HSNAsic"                  // xXcCrRaA
	RouterFpga               HMSType = "RouterFpga"               // xXcCrRfF
	RouterTOR                HMSType = "RouterTOR"                // xXcCrRtT
	RouterTORFpga            HMSType = "RouterTORFpga"            // xXcCrRtTfF
	RouterBMC                HMSType = "RouterBMC"                // xXcCrRbB
	RouterBMCNic             HMSType = "RouterBMCNic"             // xXcCrRbBiI
	RouterPowerConnector     HMSType = "RouterPowerConnector"     // xXcCrRvV

	HSNBoard              HMSType = "HSNBoard"              // xXcCrReE
	HSNLink               HMSType = "HSNLink"               // xXcCrRaAlL
	HSNConnector          HMSType = "HSNConnector"          // xXcCrRjJ
	HSNConnectorPort      HMSType = "HSNConnectorPort"      // xXcCrRjJpP
	MgmtSwitch            HMSType = "MgmtSwitch"            // xXcCwW
	MgmtHLSwitchEnclosure HMSType = "MgmtHLSwitchEnclosure" // xXcChH
	MgmtHLSwitch          HMSType = "MgmtHLSwitch"          // xXcChHsS
	MgmtSwitchConnector   HMSType = "MgmtSwitchConnector"   // xXcCwWjJ

	// Special types and wildcards
	SMSBox         HMSType = "SMSBox"    // smsN
	Partition      HMSType = "Partition" // pH.S
	System         HMSType = "System"    // s0
	HMSTypeAll     HMSType = "All"       // all
	HMSTypeAllComp HMSType = "AllComp"   // all_comp
	HMSTypeAllSvc  HMSType = "AllSvc"    // all_svc
	HMSTypeInvalid HMSType = "INVALID"   // Not a valid type/xname
)

This is an enum (though they have no numeric values in ReST and we don't want to store them that way since we could get bit by renumbering. the down-side is that we will have to normalize capitalization differences. This isn't a huge problem since the type field should only be modified by discovery. It shouldn't be changed by the user, since it must map to a corresponding cname and we can't change its hierarchical relationship.

func GetHMSType

func GetHMSType(xname string) HMSType

Get the HMSType for a given xname, based on its pattern in the recognition table above. If no string matches, HMSTypeInvalid is returned.

func ToHMSType

func ToHMSType(typeStr string) HMSType

Returns the given HMSType (adjusting any capitalization differences), if a valid HMS component type string was given. Else, return HMSTypeINVALID.

func (HMSType) String

func (t HMSType) String() string

Allow HMSType to be treated as a standard string type.

Jump to

Keyboard shortcuts

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