[lxc-devel] [lxd/master] lxd/storage/ceph: Fix to work on older releases

stgraber on Github lxc-bot at linuxcontainers.org
Thu Oct 10 02:36:00 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191009/3da84508/attachment.bin>
-------------- next part --------------
From a7944c145dd6fcb449b6d20d95d1265e07aaea0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 9 Oct 2019 22:34:53 -0400
Subject: [PATCH] lxd/storage/ceph: Fix to work on older releases
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_ceph_utils.go | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/lxd/storage_ceph_utils.go b/lxd/storage_ceph_utils.go
index b3c4c04f8e..ec8c7dc076 100644
--- a/lxd/storage_ceph_utils.go
+++ b/lxd/storage_ceph_utils.go
@@ -74,16 +74,23 @@ func cephOSDPoolDestroy(clusterName string, poolName string, userName string) er
 // occur.
 func cephRBDVolumeCreate(clusterName string, poolName string, volumeName string,
 	volumeType string, size string, userName string, dataPoolName string) error {
-	_, err := shared.RunCommand(
-		"rbd",
+	cmd := []string{
 		"--id", userName,
 		"--image-feature", "layering,",
 		"--cluster", clusterName,
 		"--pool", poolName,
-		"--data-pool", dataPoolName,
+	}
+
+	if dataPoolName != "" {
+		cmd = append(cmd, "--data-pool", dataPoolName)
+	}
+
+	cmd = append(cmd,
 		"--size", size,
 		"create",
 		fmt.Sprintf("%s_%s", volumeType, volumeName))
+
+	_, err := shared.RunCommand("rbd", cmd...)
 	return err
 }
 
@@ -367,17 +374,24 @@ func cephRBDCloneCreate(sourceClusterName string, sourcePoolName string,
 	sourceSnapshotName string, targetPoolName string,
 	targetVolumeName string, targetVolumeType string,
 	userName string, targetDataPoolName string) error {
-	_, err := shared.RunCommand(
-		"rbd",
+	cmd := []string{
 		"--id", userName,
 		"--cluster", sourceClusterName,
 		"--image-feature", "layering",
-		"--data-pool", targetDataPoolName,
+	}
+
+	if targetDataPoolName != "" {
+		cmd = append(cmd, "--data-pool", targetDataPoolName)
+	}
+
+	cmd = append(cmd,
 		"clone",
 		fmt.Sprintf("%s/%s_%s@%s", sourcePoolName, sourceVolumeType,
 			sourceVolumeName, sourceSnapshotName),
 		fmt.Sprintf("%s/%s_%s", targetPoolName, targetVolumeType,
 			targetVolumeName))
+
+	_, err := shared.RunCommand("rbd", cmd...)
 	if err != nil {
 		return err
 	}


More information about the lxc-devel mailing list