This patch replaces the 'blockdev_remove' RPC call with the 'RemoveDisks' method, from the currently supported conversions between the LVM-based templates, i.e, plain, drbd.
The 'RemoveDisks' method will also be used from the upcoming disk template conversion mechanism to remove the original block devices of the instance and also for rolling back any modification made in case the conversion operation fails. We use a central method for removing the instance's disks instead of repeatedly calling the 'blockdev_remove' every time we want to remove a set of disks, to save repeated lines of code. Signed-off-by: Dimitris Bliablias <[email protected]> --- lib/cmdlib/instance.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/cmdlib/instance.py b/lib/cmdlib/instance.py index 3218801..7522ccf 100644 --- a/lib/cmdlib/instance.py +++ b/lib/cmdlib/instance.py @@ -3696,7 +3696,6 @@ class LUInstanceSetParams(LogicalUnit): assert len(secondary_nodes) == 1 assert self.instance.disk_template == constants.DT_DRBD8 - pnode_uuid = self.instance.primary_node snode_uuid = secondary_nodes[0] feedback_fn("Converting template to plain") @@ -3736,21 +3735,15 @@ class LUInstanceSetParams(LogicalUnit): ReleaseLocks(self, locking.LEVEL_NODE) feedback_fn("Removing volumes on the secondary node...") - for disk in old_disks: - result = self.rpc.call_blockdev_remove(snode_uuid, (disk, self.instance)) - result.Warn("Could not remove block device %s on node %s," - " continuing anyway" % - (disk.iv_name, self.cfg.GetNodeName(snode_uuid)), - self.LogWarning) + RemoveDisks(self, self.instance, disk_template=constants.DT_DRBD8, + disks=old_disks, target_node_uuid=snode_uuid) feedback_fn("Removing unneeded volumes on the primary node...") + meta_disks = [] for idx, disk in enumerate(old_disks): - meta = disk.children[1] - result = self.rpc.call_blockdev_remove(pnode_uuid, (meta, self.instance)) - result.Warn("Could not remove metadata for disk %d on node %s," - " continuing anyway" % - (idx, self.cfg.GetNodeName(pnode_uuid)), - self.LogWarning) + meta_disks.append(disk.children[1]) + RemoveDisks(self, self.instance, disk_template=constants.DT_DRBD8, + disks=meta_disks) def _HotplugDevice(self, action, dev_type, device, extra, seq): self.LogInfo("Trying to hotplug device...") -- 1.7.10.4
