Check for running instances when disabling templates
authorHelga Velroyen <helgav@google.com>
Wed, 9 Oct 2013 09:24:03 +0000 (11:24 +0200)
committerHelga Velroyen <helgav@google.com>
Fri, 11 Oct 2013 11:13:35 +0000 (13:13 +0200)
This patch introduces a function to be used in
'gnt-cluster modify' when disabling a couple of disk
templates. It checks whether there are still instances
running that use these templates.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

lib/cmdlib/cluster.py

index a76fabe..8d527ba 100644 (file)
@@ -916,6 +916,21 @@ class LUClusterSetParams(LogicalUnit):
             raise errors.OpPrereqError("Cannot enable DRBD without a"
                                        " DRBD usermode helper set.")
 
+  def _CheckInstancesOfDisabledDiskTemplates(
+      self, disabled_disk_templates):
+    """Check whether we try to a disk template that is in use.
+
+    @type disabled_disk_templates: list of string
+    @param disabled_disk_templates: list of disk templates that are going to
+      be disabled by this operation
+
+    """
+    for disk_template in disabled_disk_templates:
+      if self.cfg.HasAnyDiskOfType(disk_template):
+        raise errors.OpPrereqError(
+            "Cannot disable disk template '%s', because there is at least one"
+            " instance using it." % disk_template)
+
   def CheckPrereq(self):
     """Check prerequisites.