Update sysfs.go

This commit is contained in:
Shahid 2015-10-05 21:10:58 +05:30
parent 65019576b3
commit 259e42d118

View File

@ -235,21 +235,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 {
//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 {
// s390/s390x changes
id, err = ioutil.ReadFile(path.Join(s390xDevTree, "machine-id"))
if err != nil {
return "", err
}
}
}
}
return strings.TrimSpace(string(id)), nil
if id, err := ioutil.ReadFile(path.Join(dmiDir, "id", "product_uuid")); err == nil {
return strings.TrimSpace(string(id)), nil
} else if id, err = ioutil.ReadFile(path.Join(ppcDevTree, "system-id")); err == nil {
return strings.TrimSpace(string(id)), nil
} else if id, err = ioutil.ReadFile(path.Join(ppcDevTree, "vm,uuid")); err == nil {
return strings.TrimSpace(string(id)), nil
} else if id, err = ioutil.ReadFile(path.Join(s390xDevTree, "machine-id")); err == nil {
return strings.TrimSpace(string(id)), nil
} else {
return "", err
}
}