From 8a13310ddb887908062e223d6446e29925313df1 Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Wed, 25 Mar 2020 10:50:46 +0000 Subject: [PATCH] ceph: Consider the various paths of sgdisk The path of sgdisk depends on the systems. Signed-off-by: Satoru Takeuchi --- pkg/util/sys/device.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/util/sys/device.go b/pkg/util/sys/device.go index dfca6d5a2..f2fcb6f4a 100644 --- a/pkg/util/sys/device.go +++ b/pkg/util/sys/device.go @@ -19,7 +19,7 @@ package sys import ( "encoding/json" "fmt" - "os" + osexec "os/exec" "path" "strconv" "strings" @@ -41,7 +41,7 @@ const ( LVMType = "lvm" // LinearType is a linear type LinearType = "linear" - sgdisk = "sgdisk" + sgdiskCmd = "sgdisk" mountCmd = "mount" // CephLVPrefix is the prefix of a LV owned by ceph-volume CephLVPrefix = "ceph--" @@ -258,7 +258,7 @@ func GetDeviceFilesystems(device string, executor exec.Executor) (string, error) // GetDiskUUID look up the UUID for a disk. func GetDiskUUID(device string, executor exec.Executor) (string, error) { - if _, err := os.Stat("/usr/sbin/sgdisk"); err != nil { + if _, err := osexec.LookPath(sgdiskCmd); err != nil { logger.Warningf("sgdisk not found. skipping disk UUID.") return "sgdiskNotFound", nil } @@ -268,7 +268,7 @@ func GetDiskUUID(device string, executor exec.Executor) (string, error) { device = fmt.Sprintf("/dev/%s", device) } - output, err := executor.ExecuteCommandWithOutput(sgdisk, "--print", device) + output, err := executor.ExecuteCommandWithOutput(sgdiskCmd, "--print", device) if err != nil { return "", err }