-
Notifications
You must be signed in to change notification settings - Fork 4
/
redfish-power.go
675 lines (581 loc) · 27.9 KB
/
redfish-power.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
// MIT License
//
// (C) Copyright [2019-2021] 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.
package rf
import (
"encoding/json"
)
/////////////////////////////////////////////////////////////////////////////
// Collections
// Collection of PowerDistribution references (e.g. RackPDU)
type PowerDistributionCollection GenericCollection
// Collection of Outlets, i.e. linked to a PDU
type OutletCollection GenericCollection
// Collection of Circuits, i.e. linked with a PDU
type CircuitCollection GenericCollection
// Collection of Sensors, i.e. linked to a parent component, e.g. PDU
type AlarmCollection GenericCollection
// Collection of Sensors, i.e. linked to a parent component, e.g. PDU
type SensorsCollection GenericCollection
/////////////////////////////////////////////////////////////////////////////
// Redfish PowerEquipment
//
// From DMTF: "This resource shall be used to represent the set of Power
// Equipment for a Redfish implementation."
// Example: /redfish/v1/PowerEquipment
type PowerEquipment struct {
OContext string `json:"@odata.context"`
Oid string `json:"@odata.id"`
Otype string `json:"@odata.type"`
Id string `json:"Id"`
Description string `json:"Description"`
Name string `json:"Name"`
Status StatusRF `json:"Status"`
Actions *PowerEquipmentActions `json:"Actions,omitempty"`
OemActions *json.RawMessage `json:"OemActions,omitempty"`
// These are all pointers to collections
Alarms ResourceID `json:"Alarms"`
Generators ResourceID `json:"Generators,omitempty"`
FloorPDUs ResourceID `json:"FloorPDUs"`
PowerMeters ResourceID `json:"PowerMeters,omitempty"`
RackPDUs ResourceID `json:"RackPDUs"`
Rectifiers ResourceID `json:"Rectifiers"`
Sensors ResourceID `json:"Sensors,omitempty"`
Switchgear ResourceID `json:"Switchgear,omitempty"`
TransferSwitches ResourceID `json:"TransferSwitches"`
UPSs ResourceID `json:"UPSs"`
VFDs ResourceID `json:"VFDs,omitempty"`
// Array of alarm objects
TriggeredAlarms []Alarm `json:"TriggeredAlarms"`
// Links to chassis/managers
Links PowerEquipmentLinks `json:"Links"`
}
// PowerEquipment sub-struct - PowerEquipmentLinks
type PowerEquipmentLinks struct {
Chassis []ResourceID `json:"Chassis"`
ChassisOCount int `json:"Chassis@odata.count"`
ManagedBy []ResourceID `json:"ManagedBy"`
ManagedByOCount int `json:"ManagedBy@odata.count"`
}
// Actions for PowerEquipment - OEM only for now
type PowerEquipmentActions struct {
OEM *json.RawMessage `json:"Oem,omitempty"`
}
/////////////////////////////////////////////////////////////////////////////
// Redfish PowerDistribution
//
// From DMTF: "This resource shall be used to represent a Power Distribution
// component or unit for a Redfish implementation."
// Example: /redfish/v1/PowerEquipment/RackPDUs/1
type PowerDistribution struct {
OContext string `json:"@odata.context"`
Oid string `json:"@odata.id"`
Otype string `json:"@odata.type"`
// Embedded structs - see below
PowerDistributionLocationInfo
PowerDistributionFRUInfo
Actions *PowerDistributionActions `json:"Actions,omitempty"`
OEM *json.RawMessage `json:"Oem,omitempty"`
// These are all links to collections that point to the given type
Alarms ResourceID `json:"Alarms"` // Alarms
Branches ResourceID `json:"Branches"` // Circuits
Feeders ResourceID `json:"Feeders,omitempty"` // Circuit
Mains ResourceID `json:"Mains"` // Circuits
Outlets ResourceID `json:"Outlets"` // Outlets
OutletGroups ResourceID `json:"OutletGroups"` // OutletGroups
Subfeeds ResourceID `json:"Subfeeds,omitempty"` // Circuits
Metrics ResourceID `json:"Metrics"` // PowerDistributionMetrics
Sensors ResourceID `json:"Sensors,omitempty"` // Sensors
// Current State (all enums)
PowerState string `json:"PowerState"`
Status StatusRF `json:"Status"`
}
// Redfish fields from the PowerDistributionFRUInfo schema that go into
// HWInventoryByLocation. We capture them as an embedded struct within the
// full schema during inventory discovery.
type PowerDistributionLocationInfo struct {
Id string `json:"Id"`
Description string `json:"Description"`
Name string `json:"Name"`
UUID string `json:"UUID"`
Location *Location `json:Location,omitempty"`
}
// Redfish fields from the PowerDistribution schema that go into
// HWInventoryByFRU. We capture them as an embedded struct within the
// full schema during inventory discovery.
type PowerDistributionFRUInfo struct {
AssetTag string `json:"AssetTag"`
DateOfManufacture string `json:"DateOfManufacture,omitempty"`
EquipmentType string `json:"EquipmentType"`
FirmwareVersion string `json:"FirmwareVersion"`
HardwareRevision string `json:"HardwareRevision"`
Manufacturer string `json:"Manufacturer"`
Model string `json:"Model"`
PartNumber string `json:"PartNumber"`
SerialNumber string `json:"SerialNumber"`
CircuitSummary CircuitSummary `json:"CircuitSummary"`
}
// Redfish PowerDistribution Actions sub-struct
type PowerDistributionActions struct {
OEM *json.RawMessage `json:"Oem,omitempty"`
}
// CircuitSummary sub-struct of PowerDistribution
// These are all-readonly
type CircuitSummary struct {
ControlledOutlets json.Number `json:"ControlledOutlets,omitempty"`
MonitoredBranches json.Number `json:"MonitoredBranches,omitempty"`
MonitoredOutlets json.Number `json:"MonitoredOutlets,omitempty"`
MonitoredPhases json.Number `json:"MonitoredPhases,omitempty"`
TotalBranches json.Number `json:"TotalBranches,omitempty"`
TotalOutlets json.Number `json:"TotalOutlets,omitempty"`
TotalPhases json.Number `json:"TotalPhases,omitempty"`
}
/////////////////////////////////////////////////////////////////////////////
// Redfish PDU Outlet
//
// This represents an individual outlet on a PDU
// Example: /redfish/v1/PowerEquipment/RackPDUs/1/Outlets/A1
type Outlet struct {
OContext string `json:"@odata.context"`
Oid string `json:"@odata.id"`
Otype string `json:"@odata.type"`
// HwInv instance properties - Embedded struct
OutletLocationInfo
// HwInv durable FRU properties - Embedded struct
OutletFRUInfo
// Actions
Actions *OutletActions `json:"Actions,omitempty"`
// Current State (all enums)
BreakerState string `json:"BreakerState"`
PowerState string `json:"PowerState"`
Status StatusRF `json:"Status"`
IndicatorLED string `json:"IndicatorLED"`
// Sensors
CurrentSensor *SensorExcerpt `json:"CurrentSensor,omitempty"`
EnergySensor *SensorExcerpt `json:"EnergySensor,omitempty"`
FrequencySensor *SensorExcerpt `json:"FrequencySensor,omitempty"`
PowerSensor *SensorPowerExcerpt `json:"PowerSensor,omitempty"`
PolyPhaseCurrentSensors *Currents `json:"PolyPhaseCurrentSensors,omitempty"`
PolyPhaseEnergySensors *EnergyReadings `json:"PolyPhaseEnergySensors,omitempty"`
PolyPhasePowerSensors *PowerReadings `json:"PolyPhasePowerSensors,omitempty"`
PolyPhaseVoltageSensors *Voltages `json:"PolyPhaseVoltageSensors,omitempty"`
TemperatureSensor *SensorExcerpt `json:"TemperatureSensor,omitempty"`
VoltageSensor *SensorExcerpt `json:"VoltageSensor,omitempty"`
// Configuration
PowerCycleDelaySeconds json.Number `json:"PowerCycleDelaySeconds,omitempty"`
PowerOnDelaySeconds json.Number `json:"PowerOnDelaySeconds,omitempty"`
PowerRestoreDelaySeconds json.Number `json:"PowerRestoreDelaySeconds,omitempty"`
PowerRestorePolicy string `json:"PowerRestorePolicy,omitempty"`
Oem *json.RawMessage `json:"Oem,omitempty"`
// Links - if useful to continue inventory discovery
Links OutletLinks `json:"Links"`
}
// Outlets do not have individual FRUs, PDUs do, but their properties are
// potentially important. This is location-dependent data for HwInventory
type OutletLocationInfo struct {
Id string `json:"Id"`
Description string `json:"Description"`
Name string `json:"Name"`
}
// Outlets do not have individual FRUs, PDUs do, but their properties are
// potentially important. This is FRU-dependent data for HwInventory
// Note: omits configurable parameters.
type OutletFRUInfo struct {
NominalVoltage string `json:"NominalVoltage,omitempty"`
OutletType string `json:"OutletType"` // Enum
EnergySensor *SensorExcerpt `json:"EnergySensor,omitempty"`
FrequencySensor *SensorExcerpt `json:"FrequencySensor,omitempty"`
PhaseWiringType string `json:"PhaseWiringType,omitempty"` // Enum
PowerEnabled *bool `json:"PowerEnabled,omitempty"` // Can be powered?
RatedCurrentAmps json.Number `json:"RatedCurrentAmps,omitempty"`
VoltageType string `json:"VoltageType,omitempty"` // Enum
}
// Redfish Outlet Actions sub-struct
type OutletActions struct {
PowerControl *ActionPowerControl `json:"#Outlet.PowerControl,omitempty"`
ResetBreaker *ActionResetBreaker `json:"#Outlet.ResetBreaker,omitempty"`
ResetStatistics *ActionResetStatistics `json:"#Outlet.ResetStatistics,omitempty"`
OEM *json.RawMessage `json:"Oem,omitempty"`
}
// PowerControl - Outlet
type ActionPowerControl struct {
AllowableValues []string `json:"PowerState@Redfish.AllowableValues,omitempty"`
Target string `json:"target"`
Title string `json:"title,omitempty"`
}
// Action type ResetBreaker - Outlet
type ActionResetBreaker struct {
AllowableValues []string `json:"ResetBreaker@Redfish.AllowableValues,omitempty"`
Target string `json:"target"`
Title string `json:"title,omitempty"`
}
// Action type ResetStatistics - Outlet
// Is there AllowableValues here? No idea what {type}@ prefix should be then.
type ActionResetStatistics struct {
AllowableValues []string `json:"ResetStatistics@Redfish.AllowableValues,omitempty"`
Target string `json:"target"`
Title string `json:"title,omitempty"`
}
// Links for outlet
type OutletLinks struct {
OEM *json.RawMessage `json:"Oem,omitempty"`
BranchCircuit ResourceID `json:"BranchCircuit"`
}
// PowerReadings - Used in Outlet and Circuit
// Note: For all of these, we may only have one of the particular fields in
// a given resource.
type PowerReadings struct {
Line1ToLine2 *SensorPowerExcerpt `json:"Line1ToLine2,omitempty"`
Line1ToNeutral *SensorPowerExcerpt `json:"Line1ToNeutral,omitempty"`
Line2ToLine3 *SensorPowerExcerpt `json:"Line2ToLine3,omitempty"`
Line2ToNeutral *SensorPowerExcerpt `json:"Line2ToNeutral,omitempty"`
Line3ToLine1 *SensorPowerExcerpt `json:"Line3ToLine1,omitempty"`
Line3ToNeutral *SensorPowerExcerpt `json:"Line3ToNeutral,omitempty"`
}
// EnergyReadings - Used in Outlet and Circuit
type EnergyReadings struct {
Line1ToLine2 *SensorExcerpt `json:"Line1ToLine2,omitempty"`
Line1ToNeutral *SensorExcerpt `json:"Line1ToNeutral,omitempty"`
Line2ToLine3 *SensorExcerpt `json:"Line2ToLine3,omitempty"`
Line2ToNeutral *SensorExcerpt `json:"Line2ToNeutral,omitempty"`
Line3ToLine1 *SensorExcerpt `json:"Line3ToLine1,omitempty"`
Line3ToNeutral *SensorExcerpt `json:"Line3ToNeutral,omitempty"`
}
// Voltages - Used in Outlet and Circuit
type Voltages struct {
Line1ToLine2 *SensorExcerpt `json:"Line1ToLine2,omitempty"`
Line1ToNeutral *SensorExcerpt `json:"Line1ToNeutral,omitempty"`
Line2ToLine3 *SensorExcerpt `json:"Line2ToLine3,omitempty"`
Line2ToNeutral *SensorExcerpt `json:"Line2ToNeutral,omitempty"`
Line3ToLine1 *SensorExcerpt `json:"Line3ToLine1,omitempty"`
Line3ToNeutral *SensorExcerpt `json:"Line3ToNeutral,omitempty"`
}
// Currents - Used in Outlet and Circuit
type Currents struct {
Line1 *SensorExcerpt `json:"Line1,omitempty"`
Line2 *SensorExcerpt `json:"Line2,omitempty"`
Line3 *SensorExcerpt `json:"Line3,omitempty"`
Neutral *SensorExcerpt `json:"Neutral,omitempty"`
}
/////////////////////////////////////////////////////////////////////////////
// Redfish Circuit
//
// This represents a Circuitwhich will have power components linked to it.
// Example: /redfish/v1/PowerEquipment/RackPDUs/1/Branches/A
type Circuit struct {
OContext string `json:"@odata.context"`
Oid string `json:"@odata.id"`
Otype string `json:"@odata.type"`
// Embedded structs
CircuitsLocationInfo
CircuitFRUInfo
Actions *CircuitActions `json:"Actions,omitempty"`
Id string `json:"Id"`
Description string `json:"Description"`
Name string `json:"Name"`
CircuitType string `json:"CircuitType"`
// Current State (all enums)
BreakerState string `json:"BreakerState"`
PowerState string `json:"PowerState"`
Status StatusRF `json:"Status"`
IndicatorLED string `json:"IndicatorLED"`
// Configuration
CriticalCircuit *bool `json:"CriticalCircuit,omitempty"`
PowerCycleDelaySeconds json.Number `json:"PowerCycleDelaySeconds,omitempty"`
PowerOnDelaySeconds json.Number `json:"PowerOnDelaySeconds,omitempty"`
PowerRestoreDelaySeconds json.Number `json:"PowerRestoreDelaySeconds,omitempty"`
PowerRestorePolicy string `json:"PowerRestorePolicy,omitempty"`
Outlets []ResourceID `json:"Outlets"`
OutletsOCount int `json:"Outlets@odata.count,omitempty"`
Oem *json.RawMessage `json:"Oem,omitempty"`
// Links for outlet
Links CircuitLinks `json:"Links"`
// Sensors
CurrentSensor SensorExcerpt `json:"CurrentSensor,omitempty"`
EnergySensor SensorExcerpt `json:"EnergySensor,omitempty"`
FrequencySensor SensorExcerpt `json:"FrequencySensor,omitempty"`
PowerSensor SensorPowerExcerpt `json:"PowerSensor,omitempty"`
PolyPhaseCurrentSensors Currents `json:"PolyPhaseCurrentSensors,omitempty"`
PolyPhaseEnergySensors EnergyReadings `json:"PolyPhaseEnergySensors,omitempty"`
PolyPhasePowerSensors PowerReadings `json:"PolyPhasePowerSensors,omitempty"`
PolyPhaseVoltageSensors Voltages `json:"PolyPhaseVoltageSensors,omitempty"`
TemperatureSensor SensorExcerpt `json:"TemperatureSensor,omitempty"`
VoltageSensor SensorExcerpt `json:"VoltageSensor,omitempty"`
}
// Redfish Circuit Actions sub-struct
type CircuitActions struct {
PowerControl *ActionPowerControl `json:"#Circuit.PowerControl,omitempty"`
ResetBreaker *ActionResetBreaker `json:"#Circuit.ResetBreaker,omitempty"`
ResetStatistics *ActionResetStatistics `json:"#Circuit.ResetStatistics,omitempty"`
OEM *json.RawMessage `json:"Oem,omitempty"`
}
// Circuits do not have individual FRUs, PDUs do, but their properties are
// potentially important. This is location-dependent data for HwInventory
// Note: Circuit schema is fairly similar to Outlet, and links to Outlets.
type CircuitsLocationInfo struct {
Id string `json:"Id"`
Description string `json:"Description"`
Name string `json:"Name"`
}
// Circuits do not have individual FRUs, PDUs do, but their properties are
// potentially important. This is FRU-dependent data for HwInventory
// Note: omits configurable parameters.
// Note2: Circuit schema is fairly similar to Outlet, and links to Outlets.
type CircuitFRUInfo struct {
NominalVoltage string `json:"NominalVoltage,omitempty"`
CircuitType string `json:"CircuitType"` // Enum
PlugType string `json:"PlugType"` // Enum - Matches OutletType
PhaseWiringType string `json:"PhaseWiringType,omitempty"`
PowerEnabled *bool `json:"PowerEnabled,omitempty"` // Can be powered?
RatedCurrentAmps json.Number `json:"RatedCurrentAmps,omitempty"`
VoltageType string `json:"VoltageType,omitempty"`
}
// Links for Circuit
type CircuitLinks struct {
OEM *json.RawMessage `json:"Oem,omitempty"`
BranchCircuit ResourceID `json:"BranchCircuit"`
}
/////////////////////////////////////////////////////////////////////////////
// Sensor
//
// From the DMTF: "This resource shall be used to represent resources that
// represent the sensor data."
// Example: /redfish/v1/PowerEquipment/RackPDUs/1/Sensors/FrequencyA1
type Sensor struct {
OContext string `json:"@odata.context"`
Oid string `json:"@odata.id"`
Otype string `json:"@odata.type"`
Id string `json:"Id"`
Description string `json:"Description"`
Name string `json:"Name"`
Location *Location `json:Location,omitempty"`
Actions SensorActions `json:"Actions,omitempty"`
Accuracy json.Number `json:"Accuracy,omitempty"`
AdjustedMaxAllowableOperatingValue json.Number `json:"AdjustedMaxAllowableOperatingValue,omitempty"`
AdjustedMinAllowableOperatingValue json.Number `json:"AdjustedMinAllowableOperatingValue,omitempty"`
ApparentVA json.Number `json:"ApparentVA,omitempty"`
ElectricalContext string `json:"ElectricalContext"` // enum
LoadPercent json.Number `json:"LoadPercent,omitempty"`
MaxAllowableOperatingValue json.Number `json:"MaxAllowableOperatingValue,omitempty"`
MinAllowableOperatingValue json.Number `json:"MinAllowableOperatingValue,omitempty"`
OEM *json.RawMessage `json:"Oem,omitempty"`
PeakReading json.Number `json:"PeakReading,omitempty"`
PeakReadingTime string `json:"PeakReadingtime,omitempty"`
PowerFactor json.Number `json:"PowerFactor,omitempty"`
PhysicalContext string `json:"PhysicalContext,omitempty"` //enum
PhysicalSubContext string `json:"PhysicalSubContext,omitempty"` //enum
Precision json.Number `json:"Precision,omitempty"`
ReactiveVAR json.Number `json:"ReactiveVAR,omitempty"`
Reading json.Number `json:"Reading,omitempty"`
ReadingRangeMax json.Number `json:"ReadingRangeMax,omitempty"`
ReadingRangeMin json.Number `json:"ReadingRangeMin,omitempty"`
ReadingType string `json:"ReadingType,omitempty"` //enum
ReadingUnits string `json:"ReadingUnits,omitempty"`
Status StatusRF `json:"Status,omitempty"`
SensingFrequency json.Number `json:"SensingFrequency,omitempty"`
SensorResetTime json.Number `json:"SensorResetTime,omitempty"`
Thresholds *Thresholds `json:"Thresholds,omitempty"`
VoltageType string `json:"VoltageType,omitempty"` // enum
}
// Redfish Sensor Actions sub-struct
type SensorActions struct {
ResetStatistics ActionResetStatistics `json:"#Sensor.ResetStatistics,omitempty"`
OEM *json.RawMessage `json:"Oem,omitempty"`
}
// SensorPowerExcerpt - Substruct of Outlet and other power-related objects
// From DMTF: "This resource shall be used to represent resources that
// represent the sensor data."
type SensorPowerExcerpt struct {
ApparentVA json.Number `json:"ApparentVA,omitempty"`
DataSourceUri string `json:"DataSourceUri"`
LoadPercent json.Number `json:"LoadPercent,omitempty"`
Name string `json:"Name"`
PeakReading json.Number `json:"PeakReading,omitempty"`
PowerFactor json.Number `json:"PowerFactor,omitempty"`
PhysicalContext string `json:"PhysicalContext,omitempty"` //enum
PhysicalSubContext string `json:"PhysicalSubContext,omitempty"` //enum
ReactiveVAR json.Number `json:"ReactiveVAR,omitempty"`
Reading json.Number `json:"Reading,omitempty"`
ReadingUnits string `json:"ReadingUnits,omitempty"`
Status StatusRF `json:"Status,omitempty"`
}
// SensorExcerpt - Substruct of Outlet and other power-related objects
// This is the more general non-power version of SensorPowerExcerpt
type SensorExcerpt struct {
DataSourceUri string `json:"DataSourceUri"`
Name string `json:"Name"`
PeakReading json.Number `json:"PeakReading,omitempty"`
PhysicalContext string `json:"PhysicalContext,omitempty"` //enum
PhysicalSubContext string `json:"PhysicalSubContext,omitempty"` //enum
Reading json.Number `json:"Reading,omitempty"`
ReadingUnits string `json:"ReadingUnits,omitempty"`
Status StatusRF `json:"Status,omitempty"`
}
// Sub-struct of Sensor - Thresholds
type Thresholds struct {
LowerCaution Threshold `json:LowerCaution"`
LowerCritical Threshold `json:LowerCritical"`
LowerFatal Threshold `json:LowerFatal"`
UpperCaution Threshold `json:UpperCaution"`
UpperCritical Threshold `json:UpperCritical"`
UpperFatal Threshold `json:UpperFatal"`
}
// Sub-struct of Sensor - Threshold
type Threshold struct {
Activation string `json:"Activation"` // enum
DwellTime string `json:"DwellTime"`
Reading json.Number `json:"Reading,omitempty"`
}
/////////////////////////////////////////////////////////////////////////////
// Redfish Alarms
//
// DMTF: "An Alarm is an entity that has a latch type behavior.
// It is designed to be used to persist sensor threshold crossing
// or to capture the momentary state of another property."
type Alarm struct {
OContext string `json:"@odata.context"`
Oid string `json:"@odata.id"`
Otype string `json:"@odata.type"`
Id string `json:"Id"`
Description string `json:"Description"`
Name string `json:"Name"`
Actions *AlarmActions `json:"Actions,omitempty"`
AlarmState string `json:"AlarmState"`
AutomaticReArm *bool `json:"AutomaticReArm,omitempty"`
OEM *json.RawMessage `json:"Oem,omitempty"`
Message string `json:"Message"`
MessageArgs []string `json:"MessageArgs"`
MessageId string `json:"MessageId"`
Severity string `json:"Severity"`
Links AlarmLinks `json:"Links"`
}
// Actions for Alarm - OEM only for now
type AlarmActions struct {
OEM *json.RawMessage `json:"Oem,omitempty"`
}
// Links for Alarm
type AlarmLinks struct {
OEM *json.RawMessage `json:"Oem,omitempty"`
RelatedProperty ResourceID `json:"RelatedProperty"`
RelatedSensor ResourceID `json:"RelatedSensor"`
}
/////////////////////////////////////////////////////////////////////////////
// Location
//
// Resource type. Appears under Chassis, PowerDistribution, etc.
type Location struct {
ContactInfo *ContactInfo `json:"ContactInfo,omitempty"`
Latitude json.Number `json:"Latitude,omitempty"`
Longitude json.Number `json:"Longitude,omitempty"`
PartLocation *PartLocation `json:"PartLocation,omitempty"`
Placement *Placement `json:"Placement,omitempty"`
PostalAddress *PostalAddress `json:"PostalAddress,omitempty"`
}
// Within Location - ContactInfo
type ContactInfo struct {
ContactName string `json:"ContactName"`
EmailAddress string `json:"EmailAddress"`
PhoneNumber string `json:"PhoneNumber,omitempty"`
}
// Within Location - PartLocation
type PartLocation struct {
LocationOrdinalValue json.Number `json:"LocationOrdinalValue,omitempty"`
LocationType string `json:"LocationType"` //enum
Orientation string `json:"Orientation"` //enum
Reference string `json:"Reference"` //enum
ServiceLabel string `json:"ServiceLabel"`
}
// Within Location - PostalAddress
type PostalAddress struct {
Country string `json:"Country"`
Territory string `json:"Territory"`
City string `json:"City"`
Street string `json:"Street"`
Name string `json:"Name"`
PostalCode string `json:"PostalCode"`
Building string `json:"Building"`
Floor string `json:"Floor"`
Room string `json:"Room"`
}
type Placement struct {
AdditionalInfo string `json:"AdditionalInfo,omitempty"`
Rack string `json:"Rack,omitempty"`
RackOffset json.Number `json:"RackOffset,omitempty"`
RackOffsetUnits string `json:"RackOffsetUnits,omitempty"`
Row string `json:"Row,omitempty"`
}
// Identifier
//
// Resource type. Appears under various schemas
type Identifier struct {
DurableName string `json:"DurableName"`
DurableNameFormat string `json:"DurableNameFormat"` // Enum
}
/////////////////////////////////////////////////////////////////////////////
// Power and PowerSupplies (Recitifiers)
//The Power type definition below is based on current L1 Power support, and does not have
//many of the fields defined in the DMTF Redfish Power 1.6.0 schema, specifically PowerControl.
//However, HSM does capture PowerControl info for ComputerSystems (Nodes), see ComponentSystemInfo definition.
type Power struct {
OContext string `json:"@odata.context"`
OCount int `json:"@odata.count"` // Oldest schemas use
Oid string `json:"@odata.id"`
Otype string `json:"@odata.type"`
Description string `json:"Description"`
Name string `json:"Name"`
Id string `json:"Id"`
PowerSupplies []*PowerSupply `json:"PowerSupplies"`
PowerSuppliesOCount int `json:"PowerSupplies@odata.count"` // Most schemas
}
// Redfish pass-through from Redfish "PowerSupply"
// This is the set of Redfish fields for this object that HMS understands
// and/or finds useful. Those assigned to either the *LocationInfo
// or *FRUInfo subfields constitute the type specific fields in the
// HWInventory objects that are returned in response to queries.
type PowerSupply struct {
Oid string `json:"@odata.id"`
// Embedded structs.
PowerSupplyLocationInfoRF
PowerSupplyFRUInfoRF
Status StatusRF `json:"Status"`
}
// Location-specific Redfish properties to be stored in hardware inventory
// These are only relevant to the currently installed location of the FRU
type PowerSupplyLocationInfoRF struct {
Name string `json:"Name"`
FirmwareVersion string `json:"FirmwareVersion"`
}
// Durable Redfish properties to be stored in hardware inventory as
// a specific FRU, which is then link with it's current location
// i.e. an x-name. These properties should follow the hardware and
// allow it to be tracked even when it is removed from the system.
// TODO: How to version these (as HMS structures)
type PowerSupplyFRUInfoRF struct {
//Manufacture Info
Manufacturer string `json:"Manufacturer"`
SerialNumber string `json:"SerialNumber"`
Model string `json:"Model"`
PartNumber string `json:"PartNumber"`
PowerCapacityWatts int `json:"PowerCapacityWatts"`
PowerInputWatts int `json:"PowerInputWatts"`
PowerOutputWatts int `json:"PowerOutputWatts"`
PowerSupplyType string `json:"PowerSupplyType"`
}