Skip to content

Commit

Permalink
Handle system UUID retrieval for Power(ppc64) Systems
Browse files Browse the repository at this point in the history
This patch adds requisite support to retrieve system uuid details for Power
systems. Power systems do not have DMI data. However most of the relevant details
are either in /proc or /sys. For baremetal servers, the UID is available in
/proc/device-tree/system-id. For guests the UUID is available in
/proc/device-tree/vm,uuid inside the guest. Guest's /proc filesystem do not have
/proc/device-tree/system-id

Example
On baremetal system
$cat /proc/device-tree/system-id
2122AAA

On a guest VM
$cat /proc/device-tree/vm,uuid
4b1a1a7e-079e-479c-8072-d8108f31050c

Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
  • Loading branch information
Pradipta Kr. Banerjee committed May 22, 2015
1 parent 690901d commit d88ed0a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions utils/sysfs/sysfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

0 comments on commit d88ed0a

Please sign in to comment.