forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchassis.go
856 lines (769 loc) · 35.8 KB
/
chassis.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"fmt"
"reflect"
"github.com/stmcginnis/gofish/common"
)
// ChassisType is a physical form of the chassis
type ChassisType string
const (
// BladeChassisType is an enclosed or semi-enclosed, typically vertically-oriented, system
// chassis which must be plugged into a multi-system chassis to function normally.
BladeChassisType ChassisType = "Blade"
// CardChassisType is a loose device or circuit board intended to be installed in a system
// or other enclosure.
CardChassisType ChassisType = "Card"
// CartridgeChassisType is a small self-contained system intended to be plugged into a multi-system
// chassis.
CartridgeChassisType ChassisType = "Cartridge"
// ComponentChassisType is a small chassis, card, or device which contains devices for a particular
// subsystem or function.
ComponentChassisType ChassisType = "Component"
// DrawerChassisType is an enclosed or semi-enclosed, typically horizontally-oriented, system
// chassis which may be slid into a multi-system chassis.
DrawerChassisType ChassisType = "Drawer"
// EnclosureChassisType is a generic term for a chassis that does not fit any other description.
EnclosureChassisType ChassisType = "Enclosure"
// ExpansionChassisType is a chassis which expands the capabilities or capacity of another
// chassis.
ExpansionChassisType ChassisType = "Expansion"
// HeatExchangerChassisType A heat exchanger.
HeatExchangerChassisType ChassisType = "HeatExchanger"
// ImmersionTankChassisType An immersion cooling tank.
ImmersionTankChassisType ChassisType = "ImmersionTank"
// IPBasedDriveChassisType is a chassis in a drive form factor with IP-based network connections.
IPBasedDriveChassisType ChassisType = "IPBasedDrive"
// ModuleChassisType is a small, typically removable, chassis or card which contains devices
// for a particular subsystem or function.
ModuleChassisType ChassisType = "Module"
// OtherChassisType is a chassis that does not fit any of these definitions.
OtherChassisType ChassisType = "Other"
// PodChassisType is a collection of equipment racks in a large, likely transportable, container.
PodChassisType ChassisType = "Pod"
// PowerStripChassisType A power strip, typically placed in the zero-U space of a rack.
PowerStripChassisType ChassisType = "PowerStrip"
// RackChassisType is an equipment rack, typically a 19-inch wide freestanding unit.
RackChassisType ChassisType = "Rack"
// RackGroupChassisType is a group of racks which form a single entity or share infrastructure.
RackGroupChassisType ChassisType = "RackGroup"
// RackMountChassisType is a single system chassis designed specifically for mounting in an
// equipment rack.
RackMountChassisType ChassisType = "RackMount"
// RowChassisType is a collection of equipment racks.
RowChassisType ChassisType = "Row"
// ShelfChassisType is an enclosed or semi-enclosed, typically horizontally-oriented, system
// chassis which must be plugged into a multi-system chassis to function normally.
ShelfChassisType ChassisType = "Shelf"
// SidecarChassisType is a chassis that mates mechanically with another chassis to expand
// its capabilities or capacity.
SidecarChassisType ChassisType = "Sidecar"
// SledChassisType is an enclosed or semi-enclosed, system chassis which must be plugged into
// a multi-system chassis to function normally similar to a blade type chassis.
SledChassisType ChassisType = "Sled"
// StandAloneChassisType is a single, free-standing system, commonly called a tower or desktop
// chassis.
StandAloneChassisType ChassisType = "StandAlone"
// StorageEnclosureChassisType is a chassis which encloses storage.
StorageEnclosureChassisType ChassisType = "StorageEnclosure"
// ZoneChassisType is a logical division or portion of a physical chassis that contains multiple
// devices or systems that cannot be physically separated.
ZoneChassisType ChassisType = "Zone"
)
// Door shall describe a door or access panel on the chassis.
type Door struct {
// DoorState shall contain the current state of the door.
DoorState DoorState
// Locked shall indicate if the door is locked.
Locked bool
// UserLabel shall contain a user-assigned label used to identify this resource. If a value has not been assigned
// by a user, the value of this property shall be an empty string.
UserLabel string
}
// Doors shall describe the doors or access panels of the chassis.
type Doors struct {
// Front shall contain information related to the front door, as defined by the manufacturer, of the chassis.
Front Door
// Rear shall contain information related to the rear door, as defined by the manufacturer, of the chassis.
Rear Door
}
type DoorState string
const (
// LockedDoorState shall indicate that the door is both closed and locked. In this state, the door cannot be opened
// unless the value of the Locked property is set to 'false'.
LockedDoorState DoorState = "Locked"
// ClosedDoorState shall indicate that the door is closed but unlocked.
ClosedDoorState DoorState = "Closed"
// LockedAndOpenDoorState shall indicate that the door is open but the lock has been engaged. It may be possible to
// close the door while in this state.
LockedAndOpenDoorState DoorState = "LockedAndOpen"
// OpenDoorState shall indicate that the door is open.
OpenDoorState DoorState = "Open"
)
// EnvironmentalClass is
type EnvironmentalClass string
const (
// A1EnvironmentalClass ASHRAE Environmental Class 'A1'.
A1EnvironmentalClass EnvironmentalClass = "A1"
// A2EnvironmentalClass ASHRAE Environmental Class 'A2'.
A2EnvironmentalClass EnvironmentalClass = "A2"
// A3EnvironmentalClass ASHRAE Environmental Class 'A3'.
A3EnvironmentalClass EnvironmentalClass = "A3"
// A4EnvironmentalClass ASHRAE Environmental Class 'A4'.
A4EnvironmentalClass EnvironmentalClass = "A4"
)
type IntrusionSensor string
const (
// NormalIntrusionSensor No abnormal physical security condition is
// detected at this time.
NormalIntrusionSensor IntrusionSensor = "Normal"
// HardwareIntrusionIntrusionSensor A door, lock, or other mechanism
// protecting the internal system hardware from being accessed is
// detected to be in an insecure state.
HardwareIntrusionIntrusionSensor IntrusionSensor = "HardwareIntrusion"
// TamperingDetectedIntrusionSensor Physical tampering of the monitored
// entity is detected.
TamperingDetectedIntrusionSensor IntrusionSensor = "TamperingDetected"
)
// IntrusionSensorReArm is
type IntrusionSensorReArm string
const (
// ManualIntrusionSensorReArm A manual re-arm of this sensor restores it
// to the normal state.
ManualIntrusionSensorReArm IntrusionSensorReArm = "Manual"
// AutomaticIntrusionSensorReArm Because no abnormal physical security
// condition is detected, this sensor is automatically restored to the
// normal state.
AutomaticIntrusionSensorReArm IntrusionSensorReArm = "Automatic"
)
type ThermalDirection string
const (
// FrontToBackThermalDirection shall indicate a chassis with the air intake generally from the front of the chassis
// and the air exhaust out the back of the chassis.
FrontToBackThermalDirection ThermalDirection = "FrontToBack"
// BackToFrontThermalDirection shall indicate a chassis with the air intake generally from the back of the chassis
// and the air exhaust out the front of the chassis.
BackToFrontThermalDirection ThermalDirection = "BackToFront"
// TopExhaustThermalDirection shall indicate a chassis with the air exhaust out the top of the chassis.
TopExhaustThermalDirection ThermalDirection = "TopExhaust"
// SealedThermalDirection shall indicate a sealed chassis with no air pathway through the chassis.
SealedThermalDirection ThermalDirection = "Sealed"
)
// PhysicalSecurity shall describe the sensor state of the physical
// security.
type PhysicalSecurity struct {
// IntrusionSensor is This property shall represent the state of this
// physical security sensor. Hardware intrusion indicates the internal
// hardware is detected as being accessed in an insecure state.
// Tampering detected indicates the physical tampering of the monitored
// entity is detected.
IntrusionSensor IntrusionSensor
// IntrusionSensorNumber is This property shall contain a numerical
// identifier for this physical security sensor that is unique within
// this resource.
IntrusionSensorNumber int
// IntrusionSensorReArm is This property shall represent the method that
// restores this physical security sensor to the normal state. Manual
// indicates manual re-arm is needed. Automatic indicates the state is
// restored automatically because no abnormal physical security
// conditions are detected.
IntrusionSensorReArm IntrusionSensorReArm
}
// Chassis represents the physical components of a system. This
// resource represents the sheet-metal confined spaces and logical zones such
// as racks, enclosures, chassis and all other containers. Subsystems (like sensors)
// that operate outside of a system's data plane (meaning the resources are not
// accessible to software running on the system) are linked either directly or
// indirectly through this resource.
type Chassis struct {
common.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
assembly string
// AssetTag shall contain an identifying string that
// tracks the chassis for inventory purposes.
AssetTag string
// Certificates shall contain a link to a resource collection of type CertificateCollection that contains
// certificates for device identity and attestation.
certificates string
// ChassisType shall indicate the physical form factor
// for the type of chassis.
ChassisType ChassisType
controls string
// DepthMm shall represent the depth (length) of the
// chassis, in millimeters, as specified by the manufacturer.
DepthMm float64
// Description provides a description of this resource.
Description string
// linkedDrives shall contain an array of links to resources
// of type Drive that are in this chassis.
linkedDrives []string
// Doors shall contain information about the doors or access panels of the chassis.
// Added in v1.24.0.
Doors Doors
// Drives shall contain a link to a resource collection of type DriveCollection.
drives string
// DrivesCount is the number of drives attached to this chassis.
DrivesCount int `json:"[email protected]"`
// ElectricalSourceManagerURIs shall contain an array of URIs to the management applications or devices that
// provide monitoring or control of the external electrical sources that provide power to this chassis.
ElectricalSourceManagerURIs []string
// ElectricalSourceNames shall contain an array of strings that identify the external electrical sources, such as
// the names of circuits or outlets, that provide power to this chassis.
ElectricalSourceNames []string
// EnvironmentMetrics shall contain a link to a resource of type EnvironmentMetrics that specifies the environment
// metrics for this chassis.
environmentMetrics string
// EnvironmentalClass shall contain the ASHRAE
// Environmental Class for this chassis, as defined by ASHRAE Thermal
// Guidelines for Data Processing Environments. These classes define
// respective environmental limits that include temperature, relative
// humidity, dew point, and maximum allowable elevation.
EnvironmentalClass EnvironmentalClass
// FabricAdapters shall contain a link to a resource collection of type FabricAdapterCollection that represents
// fabric adapters in this chassis that provide access to fabric-related resource pools.
fabricAdapters string
// HeatingCoolingEquipmentNames shall contain an array of strings that identify the external heating or cooling
// equipment, such as the names of specific coolant distribution units, that provide thermal management for this
// chassis.
HeatingCoolingEquipmentNames []string
// HeatingCoolingManagerURIs shall contain an array of URIs to the management applications or devices that provide
// monitoring or control of the external heating or cooling equipment that provide thermal management for this
// chassis.
HeatingCoolingManagerURIs []string
// HeightMm shall represent the height of the chassis,
// in millimeters, as specified by the manufacturer.
HeightMm float64
// HotPluggable shall indicate whether the component can be inserted or removed while the underlying equipment
// otherwise remains in its current operational state. Components indicated as hot-pluggable shall allow the
// component to become operable without altering the operational state of the underlying equipment. Components that
// cannot be inserted or removed from equipment in operation, or components that cannot become operable without
// affecting the operational state of that equipment, shall be indicated as not hot-pluggable.
HotPluggable bool
// IndicatorLED shall contain the indicator light state
// for the indicator light associated with this system.
// Deprecated v1.14+ in favor of LocationIndicatorActive property
IndicatorLED common.IndicatorLED
// Location shall contain location information of the
// associated chassis.
Location common.Location
// LocationIndicatorActive shall contain the state of the indicator used to physically identify or locate this
// resource. A write to this property shall update the value of IndicatorLED in this resource, if supported, to
// reflect the implementation of the locating function. Modifying this property may modify the
// LocationIndicatorActive in the resource that represents the functional view of this Chassis, such as a
// ComputerSystem resource.
LocationIndicatorActive bool
logServices string
// Manufacturer shall contain the name of the
// organization responsible for producing the chassis. This organization
// might be the entity from whom the chassis is purchased, but this is
// not necessarily true.
Manufacturer string
// MaxPowerWatts shall contain the upper bound of the total power consumed by the chassis.
MaxPowerWatts float64
// Memory shall contain a link to a resource collection of type MemoryCollection that represents memory in this
// chassis that belong to fabric-related resource pools.
memory string
// MemoryDomains shall contain a link to a resource collection of type MemoryDomainCollection that represents
// memory domains in this chassis that belong to fabric-related resource pools.
memoryDomains string
// MinPowerWatts shall contain the lower bound of the total power consumed by the chassis.
MinPowerWatts float64
// Model shall contain the name by which the
// manufacturer generally refers to the chassis.
Model string
networkAdapters string
// PartNumber shall contain a part number assigned by
// the organization that is responsible for producing or manufacturing
// the chassis.
PartNumber string
// PCIeDevices shall contain a link to a resource collection of type PCIeDeviceCollection.
pcieDevices string
// PhysicalSecurity shall contain the sensor state of
// the physical security.
PhysicalSecurity PhysicalSecurity
// PowerState shall contain the power state of the
// chassis.
PowerState PowerState
// PowerSubsystem shall contain a link to a resource of type PowerSubsystem that represents the power subsystem
// information for this chassis.
powerSubsystem string
// PoweredByParent shall indicate whether the chassis receives power from the chassis that contains it. The value
// 'true' shall indicate that the containing chassis provides power. The value 'false' shall indicate the chassis
// receives power from its own power subsystem, another chassis instance's power supplies, or outlets.
PoweredByParent bool
// Processors shall contain a link to a resource collection of type ProcessorCollection
// that represents processors in this chassis that belong to fabric-related resource pools.
processors string
// Replaceable shall indicate whether this component can be independently replaced as allowed by the vendor's
// replacement policy. A value of 'false' indicates the component needs to be replaced by policy as part of another
// component. If the 'LocationType' property of this component contains 'Embedded', this property shall contain
// 'false'.
Replaceable bool
// SKU shall contain the stock-keeping unit number for
// this chassis.
SKU string
sensors string
// SerialNumber shall contain a manufacturer-allocated
// number that identifies the chassis.
SerialNumber string
// SparePartNumber shall contain the spare part number of the chassis.
SparePartNumber string
// Status shall contain any status or health properties
// of the resource.
Status common.Status
// ThermalDirection shall indicate the general direction of the thermal management path through the chassis.
ThermalDirection ThermalDirection
// ThermalManagedByParent shall indicate whether the chassis relies on the containing chassis to provide thermal
// management. The value 'true' shall indicate that the chassis relies on the containing chassis to provide thermal
// management. The value 'false' shall indicate the chassis provides thermal management, and may provide details in
// a ThermalSubsystem resource, or by populating the Fans property in Links.
ThermalManagedByParent bool
// ThermalSubsystem shall contain a link to a resource of type ThermalSubsystem that represents the thermal
// subsystem information for this chassis.
thermalSubsystem string
// TrustedComponents shall contain a link to a resource collection of type TrustedComponentCollection.
trustedComponents string
// UUID shall contain the universal unique identifier
// number for this chassis.
UUID string
// WeightKg shall represent the published mass, commonly
// referred to as weight, of the chassis, in kilograms.
WeightKg float64
// WidthMm shall represent the width of the chassis, in
// millimeters, as specified by the manufacturer.
WidthMm float64
// rawData holds the original serialized JSON so we can compare updates.
RawData []byte
// Deprecated properties
power string
thermal string
pcieSlots string
// Action links
// resetTarget is the internal URL to send reset actions to.
resetTarget string
// SupportedResetTypes, if provided, is the reset types this chassis supports.
SupportedResetTypes []ResetType
// Links
cables []string
// CablesCount is the number of connected cables
CablesCount int
computerSystems []string
// ComputerSystemsCount is the number of computer systems in this chassis.
ComputerSystemsCount int
connectedCoolingLoops []string
// ConnectedCoolingLoopsCount is the number of cooling loops connected to this chassis.
ConnectedCoolingLoopsCount int
containedBy string
contains []string
// ContainsCount is the number of chassis this chassis contains.
ContainsCount int
coolingUnits []string
// CoolingUnitsCount is the number of cooling units connected to this chassis.
CoolingUnitsCount int
facility string
fans []string
// FansCount is the number of fans connected to this chassis.
FansCount int
managedBy []string
// ManagedByCount is the number of managers for this chassis.
ManagedByCount int
managersInChassis []string
// ManagersInChassisCount is the number of managers contained in this chassis.
ManagersInChassisCount int
powerDistribution string
powerOutlets []string
// PowerOutletsCount is the number of power outlets in this chassis.
PowerOutletsCount int
powerSupplies []string
// PowerSuppliesCount gets the number of power supplies in the chassis.
PowerSuppliesCount int
resourceBlocks []string
// ResourceBlocksCount is the number of resource blocks in this chassis.
ResourceBlockCount int
storage []string
// StorageCount is the number of storage instances connected to this chassis.
StorageCount int
switches []string
// SwitchesCount is the number of switches in this chassis.
SwitchesCount int
}
type chassisLinks struct {
Cables common.Links
CablesCount int `json:"[email protected]"`
ComputerSystems common.Links
ComputerSystemsCount int `json:"[email protected]"`
ConnectedCoolingLoops common.Links
ConnectedCoolingLoopsCount int `json:"[email protected]"`
ContainedBy common.Link
Contains common.Links
ContainsCount int `json:"[email protected]"`
CoolingUnits common.Links
CoolingUnitsCount int `json:"[email protected]"`
Drives common.Links
DrivesCount int `json:"[email protected]"`
Facility common.Link
Fans common.Links
FansCount int `json:"[email protected]"`
ManagedBy common.Links
ManagedByCount int `json:"[email protected]"`
ManagersInChassis common.Links
ManagersInChassisCount int `json:"[email protected]"`
PowerDistribution common.Link
PowerOutlets common.Links
PowerOutletsCount int `json:"[email protected]"`
PowerSupplies common.Links
PowerSuppliesCount int `json:"[email protected]"`
Processors common.Links
ProcessorsCount int `json:"[email protected]"`
ResourceBlocks common.Links
ResourceBlocksCount int `json:"[email protected]"`
Storage common.Links
StorageCount int `json:"[email protected]"`
Switches common.Links
SwitchesCount int `json:"[email protected]"`
}
type chassisActions struct {
ChassisReset struct {
AllowedResetTypes []ResetType `json:"[email protected]"`
Target string
} `json:"#Chassis.Reset"`
}
// UnmarshalJSON unmarshals a Chassis object from the raw JSON.
//
//nolint:funlen
func (chassis *Chassis) UnmarshalJSON(b []byte) error {
type temp Chassis
var t struct {
temp
Assembly common.Link
Certificates common.Link
Controls common.Link
Drives common.Link
EnvironmentMetrics common.Link
FabricAdapters common.Link
LogServices common.Link
Memory common.Link
MemoryDomains common.Link
NetworkAdapters common.Link
PCIeDevices common.Link
PCIeSlots common.Link
Power common.Link
PowerSubsystem common.Link
Processors common.Link
Sensors common.Link
Thermal common.Link
ThermalSubsystem common.Link
TrustedComponents common.Link
Links chassisLinks
Actions chassisActions
}
err := json.Unmarshal(b, &t)
if err != nil {
return err
}
*chassis = Chassis(t.temp)
// Extract the links to other entities for later
chassis.assembly = t.Assembly.String()
chassis.certificates = t.Certificates.String()
chassis.controls = t.Controls.String()
chassis.drives = t.Drives.String()
chassis.environmentMetrics = t.EnvironmentMetrics.String()
chassis.fabricAdapters = t.FabricAdapters.String()
chassis.logServices = t.LogServices.String()
chassis.memory = t.Memory.String()
chassis.memoryDomains = t.MemoryDomains.String()
chassis.networkAdapters = t.NetworkAdapters.String()
chassis.pcieDevices = t.PCIeDevices.String()
chassis.pcieSlots = t.PCIeSlots.String()
chassis.power = t.Power.String()
chassis.powerSubsystem = t.PowerSubsystem.String()
chassis.processors = t.Processors.String()
chassis.sensors = t.Sensors.String()
chassis.thermal = t.Thermal.String()
chassis.thermalSubsystem = t.ThermalSubsystem.String()
chassis.trustedComponents = t.TrustedComponents.String()
chassis.resetTarget = t.Actions.ChassisReset.Target
chassis.SupportedResetTypes = t.Actions.ChassisReset.AllowedResetTypes
chassis.cables = t.Links.Cables.ToStrings()
chassis.computerSystems = t.Links.ComputerSystems.ToStrings()
chassis.ComputerSystemsCount = t.Links.ComputerSystemsCount
chassis.connectedCoolingLoops = t.Links.ConnectedCoolingLoops.ToStrings()
chassis.ConnectedCoolingLoopsCount = t.Links.ConnectedCoolingLoopsCount
chassis.containedBy = t.Links.ContainedBy.String()
chassis.contains = t.Links.Contains.ToStrings()
chassis.ContainsCount = t.Links.ContainsCount
chassis.coolingUnits = t.Links.CoolingUnits.ToStrings()
chassis.CoolingUnitsCount = t.Links.CoolingUnitsCount
chassis.facility = t.Links.Facility.String()
chassis.fans = t.Links.Fans.ToStrings()
chassis.FansCount = t.Links.FansCount
chassis.managedBy = t.Links.ManagedBy.ToStrings()
chassis.ManagedByCount = t.Links.ManagedByCount
chassis.managersInChassis = t.Links.ManagersInChassis.ToStrings()
chassis.ManagersInChassisCount = t.Links.ManagersInChassisCount
chassis.powerDistribution = t.Links.PowerDistribution.String()
chassis.powerOutlets = t.Links.PowerOutlets.ToStrings()
chassis.PowerOutletsCount = t.Links.PowerOutletsCount
chassis.powerSupplies = t.Links.PowerSupplies.ToStrings()
chassis.PowerSuppliesCount = t.Links.PowerSuppliesCount
// Links contain processors, but so does the chassis object. Since the chassis
// object includes a collection link that is a little more efficient, sticking
// with that until there is a need identified to grab it a different way.
chassis.resourceBlocks = t.Links.ResourceBlocks.ToStrings()
chassis.storage = t.Links.Storage.ToStrings()
chassis.StorageCount = t.Links.StorageCount
chassis.switches = t.Links.Switches.ToStrings()
chassis.SwitchesCount = t.Links.SwitchesCount
chassis.linkedDrives = t.Links.Drives.ToStrings()
if chassis.DrivesCount == 0 && t.Links.DrivesCount > 0 {
chassis.DrivesCount = t.Links.DrivesCount
}
// This is a read/write object, so we need to save the raw object data for later
chassis.RawData = b
return nil
}
// Update commits updates to this object's properties to the running system.
func (chassis *Chassis) Update() error {
// Get a representation of the object's original state so we can find what
// to update.
original := new(Chassis)
err := original.UnmarshalJSON(chassis.RawData)
if err != nil {
return err
}
readWriteFields := []string{
"AssetTag",
"IndicatorLED",
"ElectricalSourceManagerURIs",
"ElectricalSourceNames",
"EnvironmentalClass",
"HeatingCoolingEquipmentNames",
"HeatingCoolingManagerURIs",
"LocationIndicatorActive",
}
originalElement := reflect.ValueOf(original).Elem()
currentElement := reflect.ValueOf(chassis).Elem()
return chassis.Entity.Update(originalElement, currentElement, readWriteFields)
}
// GetChassis will get a Chassis instance from the Redfish service.
func GetChassis(c common.Client, uri string) (*Chassis, error) {
return common.GetObject[Chassis](c, uri)
}
// ListReferencedChassis gets the collection of Chassis from a provided reference.
func ListReferencedChassis(c common.Client, link string) ([]*Chassis, error) {
return common.GetCollectionObjects[Chassis](c, link)
}
// Certificates returns certificates in this Chassis.
func (chassis *Chassis) Certificates() ([]*Certificate, error) {
return ListReferencedCertificates(chassis.GetClient(), chassis.certificates)
}
// Controls returns controls in this Chassis.
func (chassis *Chassis) Controls() ([]*Control, error) {
return ListReferencedControls(chassis.GetClient(), chassis.controls)
}
// ConnectedCoolingLoops returns a collection of CoolingLoops associated with this Chassis.
func (chassis *Chassis) ConnectedCoolingLoops() ([]*CoolingLoop, error) {
return common.GetObjects[CoolingLoop](chassis.GetClient(), chassis.connectedCoolingLoops)
}
// CoolingUnits returns a collection of CoolingUnits associated with this Chassis.
func (chassis *Chassis) CoolingUnits() ([]*CoolingUnit, error) {
return common.GetObjects[CoolingUnit](chassis.GetClient(), chassis.coolingUnits)
}
// Drives gets the drives attached to the storage controllers that this
// resource represents.
func (chassis *Chassis) Drives() ([]*Drive, error) {
// In version v1.2.0 of the spec, Drives were added to the Chassis.Links
// property. But in v1.14.0 of the spec, Chassis.Drives was added as a
// direct property.
if chassis.drives != "" {
return common.GetCollectionObjects[Drive](chassis.GetClient(), chassis.drives)
}
if len(chassis.linkedDrives) > 0 {
return common.GetObjects[Drive](chassis.GetClient(), chassis.linkedDrives)
}
return []*Drive{}, nil
}
// EnvironmentMetrics gets the environment metrics for the chassis
func (chassis *Chassis) EnvironmentMetrics() (*EnvironmentMetrics, error) {
if chassis.environmentMetrics == "" {
return nil, nil
}
return GetEnvironmentMetrics(chassis.GetClient(), chassis.environmentMetrics)
}
// Facility gets the smallest facility that contains the chassis.
func (chassis *Chassis) Facility() (*Facility, error) {
if chassis.facility == "" {
return nil, nil
}
return GetFacility(chassis.GetClient(), chassis.facility)
}
// Memory gets the memory in the chassis.
func (chassis *Chassis) Memory() ([]*Memory, error) {
return ListReferencedMemorys(chassis.GetClient(), chassis.memory)
}
// MemoryDomains gets the memory domains in the chassis.
func (chassis *Chassis) MemoryDomains() ([]*MemoryDomain, error) {
return ListReferencedMemoryDomains(chassis.GetClient(), chassis.memoryDomains)
}
// Thermal gets the thermal temperature and cooling information for the chassis
// This link has been deprecated in favor of the ThermalSubsystem link property.
func (chassis *Chassis) Thermal() (*Thermal, error) {
if chassis.thermal == "" {
return nil, nil
}
return GetThermal(chassis.GetClient(), chassis.thermal)
}
// ThermalSubsystem gets the thermal subsystem for this chassis.
func (chassis *Chassis) ThermalSubsystem() (*ThermalSubsystem, error) {
if chassis.thermalSubsystem == "" {
return nil, nil
}
return GetThermalSubsystem(chassis.GetClient(), chassis.thermalSubsystem)
}
// PCIeDevices gets the PCIe devices in the chassis
func (chassis *Chassis) PCIeDevices() ([]*PCIeDevice, error) {
return ListReferencedPCIeDevices(chassis.GetClient(), chassis.pcieDevices)
}
// PCIeSlots gets the PCIe slots properties for the chassis.
// This property has been deprecated in favor of the PCIeDevices property. The PCIeSlots schema has been
// deprecated in favor of the PCIeDevice schema. Empty PCIe slots are represented by PCIeDevice resources
// using the `Absent` value of the State property within Status.
func (chassis *Chassis) PCIeSlots() (*PCIeSlots, error) {
if chassis.pcieSlots == "" {
return nil, nil
}
return GetPCIeSlots(chassis.GetClient(), chassis.pcieSlots)
}
// Power gets the power information for the chassis
// This link has been deprecated in favor of the PowerSubsystem link property.
func (chassis *Chassis) Power() (*Power, error) {
if chassis.power == "" {
return nil, nil
}
return GetPower(chassis.GetClient(), chassis.power)
}
// PowerSubsystem gets the power subsystem for the chassis
// This link has been deprecated in favor of the PowerSubsystem link property.
func (chassis *Chassis) PowerSubsystem() (*PowerSubsystem, error) {
if chassis.powerSubsystem == "" {
return nil, nil
}
return GetPowerSubsystem(chassis.GetClient(), chassis.powerSubsystem)
}
// Cables gets the connected cables.
func (chassis *Chassis) Cables() ([]*Cable, error) {
return common.GetObjects[Cable](chassis.GetClient(), chassis.cables)
}
// ComputerSystems returns the collection of systems from this chassis
func (chassis *Chassis) ComputerSystems() ([]*ComputerSystem, error) {
return common.GetObjects[ComputerSystem](chassis.GetClient(), chassis.computerSystems)
}
// ContainedBy gets the chassis that contains this chassis. The result is nil
// if this chassis is not contained by another one.
func (chassis *Chassis) ContainedBy() (*Chassis, error) {
if chassis.containedBy == "" {
return nil, nil
}
return GetChassis(chassis.GetClient(), chassis.containedBy)
}
// Contains gets the chassis instances that this chassis contains.
func (chassis *Chassis) Contains() ([]*Chassis, error) {
return common.GetObjects[Chassis](chassis.GetClient(), chassis.contains)
}
// Fans gets the the fans that provide cooling to this chassis. This property shall not be present if the
// ThermalManagedByParent property contains `true` or if the fans are contained in the ThermalSubsystem
// resource for this chassis.
func (chassis *Chassis) Fans() ([]*Fan, error) {
return common.GetObjects[Fan](chassis.GetClient(), chassis.fans)
}
// ManagedBy gets the collection of managers of this chassis
func (chassis *Chassis) ManagedBy() ([]*Manager, error) {
return common.GetObjects[Manager](chassis.GetClient(), chassis.managedBy)
}
// ManagersInChassis gets the managers contained in this chassis.
func (chassis *Chassis) ManagersInChassis() ([]*Manager, error) {
return common.GetObjects[Manager](chassis.GetClient(), chassis.managersInChassis)
}
// PowerDistribution gets the power distribution functionality contained within this chassis.
func (chassis *Chassis) PowerDistribution() (*PowerDistribution, error) {
if chassis.powerDistribution == "" {
return nil, nil
}
return GetPowerDistribution(chassis.GetClient(), chassis.powerDistribution)
}
// PowerOutlets gets the power outlets in this chassis.
func (chassis *Chassis) PowerOutlets() ([]*Outlet, error) {
return common.GetObjects[Outlet](chassis.GetClient(), chassis.powerOutlets)
}
// PowerSupplies gets the power supplies that provide power to this chassis. This property shall not be
// present if the PoweredByParent property contains 'true' or if the power supplies are contained in the
// PowerSubsystem resource for this chassis.
func (chassis *Chassis) PowerSupplies() ([]*PowerSupply, error) {
return common.GetObjects[PowerSupply](chassis.GetClient(), chassis.powerSupplies)
}
// Processors returns the collection of systems from this chassis.
// Added in v1.25.0.
func (chassis *Chassis) Processors() ([]*Processor, error) {
return ListReferencedProcessors(chassis.GetClient(), chassis.processors)
}
// ResourceBlocks gets the resource blocks located in this chassis.
func (chassis *Chassis) ResourceBlocks() ([]*ResourceBlock, error) {
return common.GetObjects[ResourceBlock](chassis.GetClient(), chassis.resourceBlocks)
}
// Storage gets the storage subsystems connected to or inside this chassis.
func (chassis *Chassis) Storage() ([]*Storage, error) {
return common.GetObjects[Storage](chassis.GetClient(), chassis.storage)
}
// Sensors gets the collection of sensors located in the equipment and sub-components of this chassis
func (chassis *Chassis) Sensors() ([]*Sensor, error) {
return ListReferencedSensors(chassis.GetClient(), chassis.sensors)
}
// Switches gets the switches in this chassis.
func (chassis *Chassis) Switches() ([]*Switch, error) {
return common.GetObjects[Switch](chassis.GetClient(), chassis.switches)
}
// NetworkAdapters gets the collection of network adapters of this chassis
func (chassis *Chassis) NetworkAdapters() ([]*NetworkAdapter, error) {
return ListReferencedNetworkAdapter(chassis.GetClient(), chassis.networkAdapters)
}
// LogServices get this chassis's log services.
func (chassis *Chassis) LogServices() ([]*LogService, error) {
return ListReferencedLogServices(chassis.GetClient(), chassis.logServices)
}
// The Assembly schema defines an assembly.
// Assembly information contains details about a device, such as part number, serial number, manufacturer, and production date.
// It also provides access to the original data for the assembly.
func (chassis *Chassis) Assembly() (*Assembly, error) {
return GetAssembly(chassis.GetClient(), chassis.assembly)
}
// Reset shall reset the chassis. This action shall not reset Systems or other
// contained resource, although side effects may occur which affect those resources.
func (chassis *Chassis) Reset(resetType ResetType) error {
// Make sure the requested reset type is supported by the chassis
valid := false
if len(chassis.SupportedResetTypes) > 0 {
for _, allowed := range chassis.SupportedResetTypes {
if resetType == allowed {
valid = true
break
}
}
} else {
// No allowed values supplied, assume we are OK
valid = true
}
if !valid {
return fmt.Errorf("reset type '%s' is not supported by this chassis",
resetType)
}
t := struct {
ResetType ResetType
}{ResetType: resetType}
return chassis.Post(chassis.resetTarget, t)
}