mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +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
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
@ -103,9 +105,24 @@ func (c *StatsClient) WinContainerInfos() (map[string]cadvisorapiv2.ContainerInf
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user