This makes exactly file, shared file, plain, rbd, and gluster storage movable. Previously gluster and shared file were supposedly supported, but actually would throw an error if moving them would be tried. RBD wasn't supported.
Signed-off-by: Aaron Karper <[email protected]> --- lib/cmdlib/instance.py | 17 ++++++----------- src/Ganeti/Constants.hs | 7 +++++++ test/py/cmdlib/instance_unittest.py | 5 +++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/cmdlib/instance.py b/lib/cmdlib/instance.py index 0ad343d..8eb6e93 100644 --- a/lib/cmdlib/instance.py +++ b/lib/cmdlib/instance.py @@ -2111,10 +2111,12 @@ class LUInstanceMove(LogicalUnit): assert self.instance is not None, \ "Cannot retrieve locked instance %s" % self.op.instance_name - if self.instance.disk_template not in constants.DTS_COPYABLE: - raise errors.OpPrereqError("Disk template %s not suitable for copying" % - self.instance.disk_template, - errors.ECODE_STATE) + disks = self.cfg.GetInstanceDisks(self.instance.uuid) + for idx, dsk in enumerate(disks): + if dsk.dev_type not in constants.DTS_MOVABLE_INSTANCE: + raise errors.OpPrereqError("Instance disk %d has layout %s and is not" + " suitable for moving instances" + % (idx, dsk.dev_type), errors.ECODE_STATE) target_node = self.cfg.GetNodeInfo(self.op.target_node_uuid) assert target_node is not None, \ @@ -2129,13 +2131,6 @@ class LUInstanceMove(LogicalUnit): cluster = self.cfg.GetClusterInfo() bep = cluster.FillBE(self.instance) - disks = self.cfg.GetInstanceDisks(self.instance.uuid) - for idx, dsk in enumerate(disks): - if dsk.dev_type not in (constants.DT_PLAIN, constants.DT_FILE, - constants.DT_SHARED_FILE, constants.DT_GLUSTER): - raise errors.OpPrereqError("Instance disk %d has a complex layout," - " cannot copy" % idx, errors.ECODE_STATE) - CheckNodeOnline(self, target_node.uuid) CheckNodeNotDrained(self, target_node.uuid) CheckNodeVmCapable(self, target_node.uuid) diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs index c54c75e..93a0a0f 100644 --- a/src/Ganeti/Constants.hs +++ b/src/Ganeti/Constants.hs @@ -1008,12 +1008,19 @@ dtsNotConvertibleFrom = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTDiskless] +-- -- | The set of disk templates that cannot convert to dtsNotConvertibleTo :: FrozenSet String dtsNotConvertibleTo = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTDiskless, DTBlock] +-- | The set of disk templates that supports moving instances +dtsMovableInstance :: FrozenSet String +dtsMovableInstance = + ConstantUtils.mkSet $ + map Types.diskTemplateToRaw [DTPlain, DTFile, DTSharedFile, DTGluster, DTRbd] + -- * Drbd drbdHmacAlg :: String diff --git a/test/py/cmdlib/instance_unittest.py b/test/py/cmdlib/instance_unittest.py index ac2f082..4406be9 100644 --- a/test/py/cmdlib/instance_unittest.py +++ b/test/py/cmdlib/instance_unittest.py @@ -1562,11 +1562,12 @@ class TestLUInstanceMove(CmdlibTestCase): self.ExecOpCodeExpectOpPrereqError(op, "Instance 'missing.inst' not known") def testUncopyableDiskTemplate(self): - inst = self.cfg.AddNewInstance(disk_template=constants.DT_SHARED_FILE) + inst = self.cfg.AddNewInstance(disk_template=constants.DT_BLOCK) op = opcodes.OpInstanceMove(instance_name=inst.name, target_node=self.node.name) self.ExecOpCodeExpectOpPrereqError( - op, "Disk template sharedfile not suitable for copying") + op, "Instance disk 0 has layout blockdev and is" + " not suitable for moving instances") def testAlreadyOnTargetNode(self): inst = self.cfg.AddNewInstance() -- 2.1.0.rc2.206.gedb03e5
