Add constant for rbd and ndb

Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
Madhu Rajanna 2019-01-17 11:50:33 +05:30
parent fa78c00535
commit 1c03334a90

View File

@ -31,6 +31,9 @@ import (
const ( const (
envHostRootFS = "HOST_ROOTFS" envHostRootFS = "HOST_ROOTFS"
rbdTonbd = "rbd-nbd"
rbd = "rbd"
nbd = "nbd"
) )
var ( var (
@ -154,7 +157,7 @@ func getNbdDevFromImageAndPool(pool string, image string) (string, bool) {
// Check if this process is mapping a rbd device. // Check if this process is mapping a rbd device.
// Only accepted pattern of cmdline is from execRbdMap: // Only accepted pattern of cmdline is from execRbdMap:
// rbd-nbd map pool/image ... // rbd-nbd map pool/image ...
if len(cmdlineArgs) < 3 || cmdlineArgs[0] != "rbd-nbd" || cmdlineArgs[1] != "map" { if len(cmdlineArgs) < 3 || cmdlineArgs[0] != rbdTonbd || cmdlineArgs[1] != "map" {
glog.V(4).Infof("nbd device %s is not used by rbd", nbdPath) glog.V(4).Infof("nbd device %s is not used by rbd", nbdPath)
continue continue
} }
@ -199,7 +202,7 @@ func checkRbdNbdTools() bool {
glog.V(3).Infof("rbd-nbd: nbd modprobe failed with error %v", err) glog.V(3).Infof("rbd-nbd: nbd modprobe failed with error %v", err)
return false return false
} }
if _, err := execCommand("rbd-nbd", []string{"--version"}); err != nil { if _, err := execCommand(rbdTonbd, []string{"--version"}); err != nil {
glog.V(3).Infof("rbd-nbd: running rbd-nbd --version failed with error %v", err) glog.V(3).Infof("rbd-nbd: running rbd-nbd --version failed with error %v", err)
return false return false
} }
@ -215,12 +218,12 @@ func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string
imagePath := fmt.Sprintf("%s/%s", volOptions.Pool, image) imagePath := fmt.Sprintf("%s/%s", volOptions.Pool, image)
useNBD := false useNBD := false
cmdName := "rbd" cmdName := rbd
moduleName := "rbd" moduleName := rbd
if volOptions.Mounter == "rbd-nbd" && hasNBD { if volOptions.Mounter == rbdTonbd && hasNBD {
useNBD = true useNBD = true
cmdName = "rbd-nbd" cmdName = rbdTonbd
moduleName = "nbd" moduleName = nbd
} }
devicePath, found := waitForPath(volOptions.Pool, image, 1, useNBD) devicePath, found := waitForPath(volOptions.Pool, image, 1, useNBD)
@ -285,9 +288,9 @@ func detachRBDDevice(devicePath string) error {
glog.V(3).Infof("rbd: unmap device %s", devicePath) glog.V(3).Infof("rbd: unmap device %s", devicePath)
cmdName := "rbd" cmdName := rbd
if strings.HasPrefix(devicePath, "/dev/nbd") { if strings.HasPrefix(devicePath, "/dev/nbd") {
cmdName = "rbd-nbd" cmdName = rbdTonbd
} }
output, err = execCommand(cmdName, []string{"unmap", devicePath}) output, err = execCommand(cmdName, []string{"unmap", devicePath})