mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
Change format
This commit is contained in:
parent
4e4d00803d
commit
67f9d3e2b3
1 changed files with 20 additions and 32 deletions
|
|
@ -13,41 +13,29 @@ import (
|
||||||
var mock bool
|
var mock bool
|
||||||
|
|
||||||
func transformToSMDFormat(inventory *pdu.PDUInventory) []map[string]any {
|
func transformToSMDFormat(inventory *pdu.PDUInventory) []map[string]any {
|
||||||
smdRecords := make([]map[string]any, 0)
|
smdOutlets := make([]map[string]any, 0)
|
||||||
|
|
||||||
rtsHostname := fmt.Sprintf("%s-rts:8083", inventory.Hostname)
|
|
||||||
pduBank := "B"
|
|
||||||
|
|
||||||
for _, outlet := range inventory.Outlets {
|
for _, outlet := range inventory.Outlets {
|
||||||
smdID := fmt.Sprintf("%sp1v%s", inventory.Hostname, outlet.ID)
|
rawOutlet := map[string]any{
|
||||||
odataID := fmt.Sprintf("/redfish/v1/PowerEquipment/RackPDUs/%s/Outlets/%s", pduBank, outlet.ID)
|
"id": outlet.ID,
|
||||||
redfishURL := fmt.Sprintf("%s%s", rtsHostname, odataID)
|
"name": outlet.Name,
|
||||||
powerControlTarget := fmt.Sprintf("%s/Actions/Outlet.PowerControl", odataID)
|
"state": outlet.State,
|
||||||
|
"socket_type": outlet.SocketType,
|
||||||
|
}
|
||||||
|
smdOutlets = append(smdOutlets, rawOutlet)
|
||||||
|
}
|
||||||
|
|
||||||
record := map[string]any{
|
pduRecord := map[string]any{
|
||||||
"ID": smdID,
|
"ID": inventory.Hostname,
|
||||||
"Type": "CabinetPDUPowerConnector",
|
"Type": "Node",
|
||||||
"RedfishType": "Outlet",
|
"FQDN": inventory.Hostname,
|
||||||
"RedfishSubtype": "Cx",
|
"Hostname": inventory.Hostname,
|
||||||
"OdataID": odataID,
|
|
||||||
"RedfishEndpointID": inventory.Hostname,
|
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"RedfishEndpointFQDN": rtsHostname,
|
"RediscoverOnUpdate": false,
|
||||||
"RedfishURL": redfishURL,
|
"PDUInventory": map[string]any{
|
||||||
"ComponentEndpointType": "ComponentEndpointOutlet",
|
"Outlets": smdOutlets,
|
||||||
"RedfishOutletInfo": map[string]any{
|
|
||||||
"Name": outlet.Name,
|
|
||||||
"Actions": map[string]any{
|
|
||||||
"#Outlet.PowerControl": map[string]any{
|
|
||||||
"PowerState@Redfish.AllowableValues": []string{"On", "Off"},
|
|
||||||
"target": powerControlTarget,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
smdRecords = append(smdRecords, record)
|
return []map[string]any{pduRecord}
|
||||||
}
|
|
||||||
return smdRecords
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var pduCollectCmd = &cobra.Command{
|
var pduCollectCmd = &cobra.Command{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue