-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse PowerConsumedWatts for any data type
CASMHMS-6148
- Loading branch information
Showing
4 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.5.0 | ||
3.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// | ||
// MIT License | ||
// | ||
// (C) Copyright [2019-2022] Hewlett Packard Enterprise Development LP | ||
// (C) Copyright [2019-2022,2024] 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"), | ||
|
@@ -30,6 +30,7 @@ import ( | |
"fmt" | ||
"io" | ||
"log" | ||
"math" | ||
"net/http" | ||
"path" | ||
"strings" | ||
|
@@ -340,6 +341,22 @@ func (d *CapmcD) doPowerCapGet(w http.ResponseWriter, r *http.Request) { | |
continue | ||
} | ||
|
||
// Convert PowerConsumedWatts to an int if not already (it's an interface{} | ||
// type that can support ints and floats) - Needed for Foxconn Paradise, | ||
// perhaps others in the future | ||
for _, pwrCtl := range rfPower.PowerCtl { | ||
if pwrCtl.PowerConsumedWatts != nil { | ||
switch v := (*pwrCtl.PowerConsumedWatts).(type) { | ||
case float64: // Convert to int | ||
*pwrCtl.PowerConsumedWatts = int(math.Round(v)) | ||
case int: // noop - no conversion needed | ||
default: // unexpected type, set to zero | ||
*pwrCtl.PowerConsumedWatts = int(0) | ||
log.Printf("ERROR: unexpected type/value '%T'/'%v' detected for PowerConsumedWatts, setting to 0\n", *pwrCtl.PowerConsumedWatts, *pwrCtl.PowerConsumedWatts) | ||
} | ||
} | ||
} | ||
|
||
// This would be nice to use but not all versions | ||
// of the schema support [email protected]. | ||
// Looking at you Intel... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters