From 32388e6d2cc05a9b93b28c36f002462bba98c5c4 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 20 Jan 2009 14:20:35 +0000 Subject: [PATCH] Fix adding of disks to an instance The ConfigWriter.AllocateDRBDMinor requires the instance name, not the instance object. The LUSetInstanceParms is passing wrongly the instance object, which can cause breakage. The patch also adds asserts to check for this mismatch in ConfigWriter. Reviewed-by: ultrotter --- lib/cmdlib.py | 2 +- lib/config.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 01ad1fd8d..dc092a5ee 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -5712,7 +5712,7 @@ class LUSetInstanceParams(LogicalUnit): disk_idx_base = len(instance.disks) new_disk = _GenerateDiskTemplate(self, instance.disk_template, - instance, instance.primary_node, + instance.name, instance.primary_node, instance.secondary_nodes, [disk_dict], file_path, diff --git a/lib/config.py b/lib/config.py index 67b449066..2d849f16e 100644 --- a/lib/config.py +++ b/lib/config.py @@ -443,7 +443,13 @@ class ConfigWriter: multiple minors. The result is the list of minors, in the same order as the passed nodes. + @type instance: string + @param instance: the instance for which we allocate minors + """ + assert isinstance(instance, basestring), \ + "Invalid argument passed to AllocateDRBDMinor" + d_map = self._UnlockedComputeDRBDMap() result = [] for nname in nodes: @@ -484,6 +490,8 @@ class ConfigWriter: released """ + assert isinstance(instance, basestring), \ + "Invalid argument passed to ReleaseDRBDMinors" for key, name in self._temporary_drbds.items(): if name == instance: del self._temporary_drbds[key] -- GitLab