Commit 1ae08cbd authored by Hrvoje Ribicic's avatar Hrvoje Ribicic
Browse files

Allow plain/DRBD conversions regardless of lack of disks



Because of trivial issues, it was impossible to use standard mechanisms
to convert a diskless plain instance to DRBD and vice versa. This
patch fixes that with a mechanism which will work until later versions,
where instances without disks organically take on the diskless
template.
Signed-off-by: default avatarHrvoje Ribicic <riba@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent a3bea125
......@@ -3271,11 +3271,16 @@ class LUInstanceSetParams(LogicalUnit):
"""Converts an instance from drbd to plain.
"""
assert len(self.instance.secondary_nodes) == 1
assert self.instance.disk_template == constants.DT_DRBD8
assert len(self.instance.secondary_nodes) == 1 or not self.instance.disks
pnode_uuid = self.instance.primary_node
snode_uuid = self.instance.secondary_nodes[0]
# it will not be possible to calculate the snode_uuid later
snode_uuid = None
if self.instance.secondary_nodes:
snode_uuid = self.instance.secondary_nodes[0]
feedback_fn("Converting template to plain")
old_disks = AnnotateDiskParams(self.instance, self.instance.disks, self.cfg)
......
......@@ -2336,6 +2336,30 @@ class TestLUInstanceSetParams(CmdlibTestCase):
disk_template=constants.DT_PLAIN)
self.ExecOpCode(op)
def testConvertDisklessDRBDToPlain(self):
self.cfg.SetIPolicyField(
constants.ISPECS_MIN, constants.ISPEC_DISK_COUNT, 0)
self.inst.disks = []
self.inst.disk_template = constants.DT_DRBD8
op = self.CopyOpCode(self.op,
disk_template=constants.DT_PLAIN)
self.ExecOpCode(op)
self.assertEqual(self.inst.disk_template, constants.DT_PLAIN)
def testConvertDisklessPlainToDRBD(self):
self.cfg.SetIPolicyField(
constants.ISPECS_MIN, constants.ISPEC_DISK_COUNT, 0)
self.inst.disks = []
self.inst.disk_template = constants.DT_PLAIN
op = self.CopyOpCode(self.op,
disk_template=constants.DT_DRBD8,
remote_node=self.snode.name)
self.ExecOpCode(op)
self.assertEqual(self.inst.disk_template, constants.DT_DRBD8)
class TestLUInstanceChangeGroup(CmdlibTestCase):
def setUp(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment