diff --git a/utils/sysfs/sysfs.go b/utils/sysfs/sysfs.go index d33b9d00..f1568b66 100644 --- a/utils/sysfs/sysfs.go +++ b/utils/sysfs/sysfs.go @@ -24,10 +24,11 @@ import ( ) const ( - blockDir = "/sys/block" - cacheDir = "/sys/devices/system/cpu/cpu" - netDir = "/sys/class/net" - dmiDir = "/sys/class/dmi" + blockDir = "/sys/block" + cacheDir = "/sys/devices/system/cpu/cpu" + netDir = "/sys/class/net" + dmiDir = "/sys/class/dmi" + ppcDevTree = "/proc/device-tree" ) type CacheInfo struct { @@ -235,7 +236,15 @@ func (self *realSysFs) GetCacheInfo(id int, name string) (CacheInfo, error) { func (self *realSysFs) GetSystemUUID() (string, error) { id, err := ioutil.ReadFile(path.Join(dmiDir, "id", "product_uuid")) if err != nil { - return "", err + //If running on baremetal Power then UID is /proc/device-tree/system-id + id, err = ioutil.ReadFile(path.Join(ppcDevTree, "system-id")) + if err != nil { + //If running on a KVM guest on Power then UUID is /proc/device-tree/vm,uuid + id, err = ioutil.ReadFile(path.Join(ppcDevTree, "vm,uuid")) + if err != nil { + return "", err + } + } } return strings.TrimSpace(string(id)), nil }