|
| 1 | +// |
| 2 | +// SPDX-License-Identifier: BSD-3-Clause |
| 3 | +// |
| 4 | + |
| 5 | +package ami |
| 6 | + |
| 7 | +import ( |
| 8 | + "encoding/json" |
| 9 | + |
| 10 | + "github.com/stmcginnis/gofish/common" |
| 11 | + "github.com/stmcginnis/gofish/redfish" |
| 12 | +) |
| 13 | + |
| 14 | +// ManagerBootMode is is the boot mode of the manager. |
| 15 | +type ManagerBootMode string |
| 16 | + |
| 17 | +const ( |
| 18 | + // NoneManagerBootMode Added None in Boot Option |
| 19 | + NoneManagerBootMode ManagerBootMode = "None" |
| 20 | + // SoftResetManagerBootMode Added SoftReset in Boot Option |
| 21 | + SoftResetManagerBootMode ManagerBootMode = "SoftReset" |
| 22 | + // ResetTimeoutManagerBootMode ResetTimeout support is Boot Option |
| 23 | + ResetTimeoutManagerBootMode ManagerBootMode = "ResetTimeout" |
| 24 | +) |
| 25 | + |
| 26 | +// AMIBIOSInventoryCRC provides the information related to inventory data/ |
| 27 | +// |
| 28 | +//nolint:revive |
| 29 | +type AMIBIOSInventoryCRC struct { |
| 30 | + // Bios provides the information related to inventory data. |
| 31 | + Bios Bios |
| 32 | + // ManagerBootConfiguration indicates the properties related to ManagerBoot |
| 33 | + ManagerBootConfiguration ManagerBootConfiguration |
| 34 | +} |
| 35 | + |
| 36 | +// BiosTableis the root for BiosTable information. |
| 37 | +type BiosTable struct { |
| 38 | + common.Entity |
| 39 | + // ODataContext is the odata context. |
| 40 | + ODataContext string `json:"@odata.context"` |
| 41 | + // ODataType is the odata type. |
| 42 | + ODataType string `json:"@odata.type"` |
| 43 | + // Description provides a description of this resource. |
| 44 | + Description string |
| 45 | + // FilesContent contains the contents of the BiosTable file. |
| 46 | + FilesContent string |
| 47 | +} |
| 48 | + |
| 49 | +// TableTag contains the TableTag informations. |
| 50 | +type TableTag struct { |
| 51 | + // TableType shall contain a string representing the TableTag. |
| 52 | + TableType string |
| 53 | + // Value shall contains the value for the corresponding TableTag. |
| 54 | + Value string |
| 55 | +} |
| 56 | + |
| 57 | +// BiosTableTags is the root for TableTags information. |
| 58 | +type BiosTableTags struct { |
| 59 | + common.Entity |
| 60 | + // ODataContext is the odata context. |
| 61 | + ODataContext string `json:"@odata.context"` |
| 62 | + // ODataType is the odata type. |
| 63 | + ODataType string `json:"@odata.type"` |
| 64 | + // Description provides a description of this resource. |
| 65 | + Description string |
| 66 | + // NumberofTables contains the number of TableTags present. |
| 67 | + NumberofTables string |
| 68 | + // TableTags contains the TableTags informations. |
| 69 | + TableTags []TableTag |
| 70 | +} |
| 71 | + |
| 72 | +// Bios |
| 73 | +type Bios struct { |
| 74 | + // BiosTable provides the information related to BiosTable |
| 75 | + BiosTable BiosTable |
| 76 | + // BiosTableTags provides the information related to BiosTableTags. |
| 77 | + BiosTableTags BiosTableTags |
| 78 | + // Inventory provides the information related to inventory data Crc value. |
| 79 | + Inventory Inventory |
| 80 | + // RedfishVersion shall represent the version of the Redfish service. The format of this string shall be of the |
| 81 | + // format majorversion.minorversion.errata in compliance with Protocol Version section of the Redfish |
| 82 | + // specification. |
| 83 | + RedfishVersion string |
| 84 | + // RTPVersion shall represent the version of the RTP Version. |
| 85 | + RTPVersion string |
| 86 | +} |
| 87 | + |
| 88 | +// Crc |
| 89 | +type Crc struct { |
| 90 | + // GroupCrcList provides the information related to inventory data of GroupCrcList value. |
| 91 | + GroupCrcList []map[string]uint64 |
| 92 | +} |
| 93 | + |
| 94 | +// Inventory |
| 95 | +type Inventory struct { |
| 96 | + // Crc provides the information related to inventory data of Crc value. |
| 97 | + Crc Crc |
| 98 | +} |
| 99 | + |
| 100 | +// ManagerBootConfiguration |
| 101 | +type ManagerBootConfiguration struct { |
| 102 | + // ManagerBootMode shall specify the enum supported by ManagerBootMode. |
| 103 | + ManagerBootMode ManagerBootMode |
| 104 | +} |
| 105 | + |
| 106 | +// ComputerSystem is the update service instance associated with the system. |
| 107 | +type ComputerSystem struct { |
| 108 | + redfish.ComputerSystem |
| 109 | + |
| 110 | + BIOS Bios |
| 111 | + ManagerBootConfiguration ManagerBootConfiguration |
| 112 | + SSIFMode string |
| 113 | +} |
| 114 | + |
| 115 | +// FromComputerSystem gets the OEM instance of the ComputerSystemSystem. |
| 116 | +func FromComputerSystem(computerSystem *redfish.ComputerSystem) (*ComputerSystem, error) { |
| 117 | + us := ComputerSystem{ |
| 118 | + ComputerSystem: *computerSystem, |
| 119 | + } |
| 120 | + |
| 121 | + var t struct { |
| 122 | + Oem struct { |
| 123 | + Ami struct { |
| 124 | + BIOS Bios `json:"BIOS"` |
| 125 | + ManagerBootConfiguration ManagerBootConfiguration `json:"ManagerBootConfiguration"` |
| 126 | + SSIFMode string `json:"SSIFMode"` |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + err := json.Unmarshal(computerSystem.RawData, &t) |
| 132 | + if err != nil { |
| 133 | + return nil, err |
| 134 | + } |
| 135 | + |
| 136 | + us.BIOS = t.Oem.Ami.BIOS |
| 137 | + us.ManagerBootConfiguration = t.Oem.Ami.ManagerBootConfiguration |
| 138 | + us.SSIFMode = t.Oem.Ami.SSIFMode |
| 139 | + |
| 140 | + return &us, nil |
| 141 | +} |
0 commit comments