mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Set the systemUUID for windows nodes
This commit is contained in:
parent
04c9bd9bfa
commit
7adb0a2656
@ -20,6 +20,8 @@ limitations under the License.
|
|||||||
package winstats
|
package winstats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@ -103,9 +105,24 @@ func (c *StatsClient) WinContainerInfos() (map[string]cadvisorapiv2.ContainerInf
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WinMachineInfo returns a cadvisorapi.MachineInfo with details about the
|
// WinMachineInfo returns a cadvisorapi.MachineInfo with details about the
|
||||||
// node machine. Analogous to cadvisor MachineInfo method.
|
// node machine. Run the powershell command to get the SystemUUID for Windows node
|
||||||
|
// in here if it isn't provided by cadvisor.
|
||||||
func (c *StatsClient) WinMachineInfo() (*cadvisorapi.MachineInfo, error) {
|
func (c *StatsClient) WinMachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
return c.client.getMachineInfo()
|
infos, err := c.client.getMachineInfo()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if infos.SystemUUID == "" {
|
||||||
|
cmd := exec.Command("powershell.exe", "-Command", "(Get-CimInstance -Class Win32_ComputerSystemProduct).UUID")
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return infos, err
|
||||||
|
}
|
||||||
|
infos.SystemUUID = strings.TrimRight(string(out), "\r\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
return infos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WinVersionInfo returns a cadvisorapi.VersionInfo with version info of
|
// WinVersionInfo returns a cadvisorapi.VersionInfo with version info of
|
||||||
|
Loading…
Reference in New Issue
Block a user