-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathconstants.go
95 lines (78 loc) · 3.36 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package constants
import "strings"
const (
// Unknown is the constant that defines unknown things
Unknown = "Unknown"
// Vendor constants
// HP is the constant that defines the vendor HP
HP = "HP"
// Dell is the constant that defines the vendor Dell
Dell = "Dell"
// Supermicro is the constant that defines the vendor Supermicro
Supermicro = "Supermicro"
// Cloudline is the constant that defines the cloudlines
Cloudline = "Cloudline"
// Quanta is the contant to identify Quanta hardware
Quanta = "Quanta"
// Quanta is the contant to identify Intel hardware
Intel = "Intel"
// Redfish firmware apply at constants
// FirmwareApplyImmediate sets the firmware to be installed immediately after upload
FirmwareApplyImmediate = "Immediate"
//FirmwareApplyOnReset sets the firmware to be install on device power cycle/reset
FirmwareApplyOnReset = "OnReset"
// Firmware install states returned by bmclib provider FirmwareInstallStatus implementations
//
// The redfish from the redfish spec are exposed as a smaller set of bmclib states for callers
// https://www.dmtf.org/sites/default/files/standards/documents/DSP2046_2020.3.pdf
// FirmwareInstallInitializing indicates the device is performing init actions to install the update
// this covers the redfish states - 'starting', 'downloading'
// no action is required from the callers part in this state
FirmwareInstallInitializing = "initializing"
// FirmwareInstallQueued indicates the device has queued the update, but has not started the update task yet
// this covers the redfish states - 'pending', 'new'
// no action is required from the callers part in this state
FirmwareInstallQueued = "queued"
// FirmwareInstallRunner indicates the device is installing the update
// this covers the redfish states - 'running', 'stopping', 'cancelling'
// no action is required from the callers part in this state
FirmwareInstallRunning = "running"
// FirmwareInstallComplete indicates the device completed the firmware install
// this covers the redfish state - 'complete'
FirmwareInstallComplete = "complete"
// FirmwareInstallFailed indicates the firmware install failed
// this covers the redfish states - 'interrupted', 'killed', 'exception', 'cancelled', 'suspended'
FirmwareInstallFailed = "failed"
// FirmwareInstallPowerCycleHost indicates the firmware install requires a host power cycle
FirmwareInstallPowerCyleHost = "powercycle-host"
// FirmwareInstallPowerCycleBMC indicates the firmware install requires a BMC power cycle
FirmwareInstallPowerCycleBMC = "powercycle-bmc"
FirmwareInstallUnknown = "unknown"
// device BIOS/UEFI POST code bmclib identifiers
POSTStateBootINIT = "boot-init/pxe"
POSTStateUEFI = "uefi"
POSTStateOS = "grub/os"
POSTCodeUnknown = "unknown"
)
// ListSupportedVendors returns a list of supported vendors
func ListSupportedVendors() []string {
return []string{HP, Dell, Supermicro}
}
// VendorFromProductName attempts to identify the vendor from the given productname
func VendorFromProductName(productName string) string {
n := strings.ToLower(productName)
switch {
case strings.Contains(n, "intel"):
return Intel
case strings.Contains(n, "dell"):
return Dell
case strings.Contains(n, "supermicro"):
return Supermicro
case strings.Contains(n, "cloudline"):
return Cloudline
case strings.Contains(n, "quanta"):
return Quanta
default:
return productName
}
}