mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Add socket type and construct correct xname
This commit is contained in:
parent
dc09b7051d
commit
940e7fee2a
3 changed files with 8 additions and 5 deletions
|
|
@ -22,7 +22,6 @@ func transformToSMDFormat(inventory *pdu.PDUInventory) []map[string]any {
|
||||||
log.Warn().Msgf("could not parse outlet ID format for '%s', skipping outlet", outlet.ID)
|
log.Warn().Msgf("could not parse outlet ID format for '%s', skipping outlet", outlet.ID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
letterPart = outlet.ID[:splitIndex]
|
letterPart = outlet.ID[:splitIndex]
|
||||||
numberPart = outlet.ID[splitIndex:]
|
numberPart = outlet.ID[splitIndex:]
|
||||||
|
|
||||||
|
|
@ -30,14 +29,15 @@ func transformToSMDFormat(inventory *pdu.PDUInventory) []map[string]any {
|
||||||
if len(letterPart) > 1 {
|
if len(letterPart) > 1 {
|
||||||
pValue = int(unicode.ToUpper(rune(letterPart[1])) - 'A')
|
pValue = int(unicode.ToUpper(rune(letterPart[1])) - 'A')
|
||||||
}
|
}
|
||||||
|
|
||||||
newIDSuffix := fmt.Sprintf("p%dv%s", pValue, numberPart)
|
idSuffix := fmt.Sprintf("p%dv%s", pValue, numberPart)
|
||||||
|
|
||||||
rawOutlet := map[string]any{
|
rawOutlet := map[string]any{
|
||||||
"id": newIDSuffix, // Pass the newly formatted suffix to SMD
|
"original_id": outlet.ID,
|
||||||
|
"id_suffix": idSuffix,
|
||||||
"name": outlet.Name,
|
"name": outlet.Name,
|
||||||
"state": outlet.PowerState,
|
"state": outlet.PowerState,
|
||||||
"socket_type": "Cx", // This seems to be static
|
"socket_type": outlet.SocketType,
|
||||||
}
|
}
|
||||||
smdOutlets = append(smdOutlets, rawOutlet)
|
smdOutlets = append(smdOutlets, rawOutlet)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ type JawsOutlet struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
|
SocketType string `json:"socket_type"`
|
||||||
Current float32 `json:"current"`
|
Current float32 `json:"current"`
|
||||||
Voltage float32 `json:"voltage"`
|
Voltage float32 `json:"voltage"`
|
||||||
ActivePower int `json:"active_power"`
|
ActivePower int `json:"active_power"`
|
||||||
|
|
@ -85,6 +86,7 @@ func CrawlPDU(config CrawlerConfig) (*pdu.PDUInventory, error) {
|
||||||
ID: rawOutlet.ID,
|
ID: rawOutlet.ID,
|
||||||
Name: rawOutlet.Name,
|
Name: rawOutlet.Name,
|
||||||
PowerState: rawOutlet.State,
|
PowerState: rawOutlet.State,
|
||||||
|
SocketType: rawOutlet.SocketType,
|
||||||
}
|
}
|
||||||
inventory.Outlets = append(inventory.Outlets, outlet)
|
inventory.Outlets = append(inventory.Outlets, outlet)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ type PDUOutlet struct {
|
||||||
ID string `json:"id"` // e.g., "35" or "BA35"
|
ID string `json:"id"` // e.g., "35" or "BA35"
|
||||||
Name string `json:"name"` // e.g., "Link1_Outlet_35"
|
Name string `json:"name"` // e.g., "Link1_Outlet_35"
|
||||||
PowerState string `json:"power_state"` // e.g., "ON" or "OFF"
|
PowerState string `json:"power_state"` // e.g., "ON" or "OFF"
|
||||||
|
SocketType string `json:"socket_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PDUInventory struct {
|
type PDUInventory struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue