-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinterface.go
218 lines (182 loc) · 7.26 KB
/
interface.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package actions
import (
"context"
common "github.com/metal-toolbox/bmc-common"
"github.com/sirupsen/logrus"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
)
// DeviceManager interface is returned to the caller when calling ironlib.New()
type DeviceManager interface {
Setter
Getter
Updater
}
// RaidController interface declares methods to manage virtual disks.
type RaidController interface {
VirtualDiskCreator
VirtualDiskDestroyer
}
// Setter interface declares methods to set attributes on a system.
type Setter interface {
SetBIOSConfiguration(ctx context.Context, config map[string]string) error
}
// Getter interface declares methods implemented by providers to return various attributes.
type Getter interface {
// Get device model
GetModel() string
// Get device vendor
GetVendor() string
// Check the device reboot required flag
RebootRequired() bool
// Check if any updates were applied
UpdatesApplied() bool
// Retrieve inventory for the device
GetInventory(ctx context.Context, options ...Option) (*common.Device, error)
// Retrieve inventory using the OEM tooling for the device,
GetInventoryOEM(ctx context.Context, device *common.Device, options *model.UpdateOptions) error
// List updates identifed by the vendor tooling (DSU for dells)
ListAvailableUpdates(ctx context.Context, options *model.UpdateOptions) (*common.Device, error)
// Retrieve BIOS configuration for device
GetBIOSConfiguration(ctx context.Context) (map[string]string, error)
// UpdateRequirements returns requirements to be met before and after a firmware install
UpdateRequirements(ctx context.Context, componentSlug, componentVendor, componentModel string) (*model.UpdateRequirements, error)
}
// Utility interface couples the configuration, collection and update interfaces
type Utility interface {
BIOSConfiguror
InventoryCollector
Updater
}
// BIOSConfiguror defines an interface to collect BIOS configuration
type BIOSConfiguror interface {
// GetBIOSConfiguration returns the BIOS configuration for the device
// deviceModel is an optional parameter depending on the hardware variants
GetBIOSConfiguration(ctx context.Context, deviceModel string) (map[string]string, error)
}
// UtilAttributeGetter defines methods to retrieve utility attributes.
type UtilAttributeGetter interface {
Attributes() (utilName model.CollectorUtility, absolutePath string, err error)
}
// Updater defines an interface to install an update file
type Updater interface {
// ApplyUpdate is to be deprecated in favor of InstallUpdates, its implementations are to be moved
// to use InstallUpdates.
ApplyUpdate(ctx context.Context, updateFile, component string) error
// InstallUpdates installs updates based on the update options
InstallUpdates(ctx context.Context, options *model.UpdateOptions) error
}
// InventoryCollector defines an interface to collect all device inventory
type InventoryCollector interface {
UtilAttributeGetter
Collect(ctx context.Context, device *common.Device) error
}
// DriveCollector defines an interface to return disk drive inventory
type DriveCollector interface {
UtilAttributeGetter
Drives(ctx context.Context) ([]*common.Drive, error)
}
// DriveCapabilityCollector defines an interface to collect disk drive capability attributes
//
// The logicalName is the kernel/OS assigned drive name - /dev/sdX or /dev/nvmeX
type DriveCapabilityCollector interface {
UtilAttributeGetter
DriveCapabilities(ctx context.Context, logicalName string) ([]*common.Capability, error)
}
// NICCollector defines an interface to returns NIC inventory
type NICCollector interface {
UtilAttributeGetter
NICs(ctx context.Context) ([]*common.NIC, error)
}
// BMCCollector defines an interface to return BMC inventory
type BMCCollector interface {
UtilAttributeGetter
BMC(ctx context.Context) (*common.BMC, error)
}
// CPLDCollector defines an interface to return CPLD inventory
type CPLDCollector interface {
UtilAttributeGetter
CPLDs(ctx context.Context) ([]*common.CPLD, error)
}
// BIOSCollector defines an interface to return BIOS inventory
type BIOSCollector interface {
UtilAttributeGetter
BIOS(ctx context.Context) (*common.BIOS, error)
}
// StorageControllerCollector defines an interface to returns storage controllers inventory
type StorageControllerCollector interface {
UtilAttributeGetter
StorageControllers(ctx context.Context) ([]*common.StorageController, error)
}
// TPMCollector defines an interface to collect TPM device inventory
type TPMCollector interface {
UtilAttributeGetter
TPMs(ctx context.Context) ([]*common.TPM, error)
}
// Checksum collectors
// FirmwareChecksumCollector defines an interface to collect firmware checksums
type FirmwareChecksumCollector interface {
UtilAttributeGetter
// return the sha-256 of the BIOS logo as a string, or the associated error
BIOSLogoChecksum(ctx context.Context) (string, error)
}
// UEFIVarsCollector defines an interface to collect EFI variables
type UEFIVarsCollector interface {
UtilAttributeGetter
GetUEFIVars(ctx context.Context) (utils.UEFIVars, error)
}
// Updaters
// UpdateRequirements returns requirements to be met before and after a firmware install,
// the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.
type UpdateRequirementsGetter interface {
UpdateRequirements(componentModel string) *model.UpdateRequirements
}
// DriveUpdater defines an interface to update drive firmware
type DriveUpdater interface {
UtilAttributeGetter
UpdateDrive(ctx context.Context, updateFile, modelNumber, serialNumber string) error
}
// NICUpdater defines an interface to update NIC firmware
type NICUpdater interface {
UtilAttributeGetter
UpdateRequirementsGetter
UpdateNIC(ctx context.Context, updateFile, modelNumber string, force bool) error
}
// BMCUpdater defines an interface to update BMC firmware
type BMCUpdater interface {
UtilAttributeGetter
UpdateBMC(ctx context.Context, updateFile, modelNumber string) error
}
// CPLDUpdater defines an interface to update CPLD firmware
type CPLDUpdater interface {
UtilAttributeGetter
UpdateCPLD() error
}
// BIOSUpdater defines an interface to update BIOS firmware
type BIOSUpdater interface {
UtilAttributeGetter
UpdateBIOS(ctx context.Context, updateFile, modelNumber string) error
}
// StorageControllerUpdater defines an interface to update storage controller firmware
type StorageControllerUpdater interface {
UtilAttributeGetter
UpdateStorageController() error
}
// VirtualDiskCreator defines an interface to create virtual disks, generally via a StorageController
type VirtualDiskCreator interface {
CreateVirtualDisk(ctx context.Context, raidMode string, physicalDisks []uint, name string, blockSize uint) error
}
// VirtualDiskCreator defines an interface to destroy virtual disks, generally via a StorageController
type VirtualDiskDestroyer interface {
DestroyVirtualDisk(ctx context.Context, virtualDiskID int) error
}
type VirtualDiskManager interface {
VirtualDiskCreator
VirtualDiskDestroyer
VirtualDisks(ctx context.Context) ([]*utils.MvcliDevice, error)
}
// DriveWiper defines an interface to override disk data
type DriveWiper interface {
// WipeDrive wipes away all data from the drive, wipe is always verified to have succeeded
WipeDrive(context.Context, *logrus.Logger, *common.Drive) error
}