From 8901997e4393d4020af3004513f0cea54ea6b79d Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 23 Jan 2009 09:13:44 +0000
Subject: [PATCH] A couple of small fixes to iallocator

This removes some constraints:
  - only two disks supported, this is no longer true as the underlying
    functions can now compute size for a variable number of disks
  - error when the hypervisor was not being passed
  - typo error

Reviewed-by: imsnah
---
 lib/cmdlib.py     | 6 +-----
 scripts/gnt-debug | 2 +-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 9ba28e988..7da0f87c6 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -6472,8 +6472,6 @@ class IAllocator(object):
 
     """
     data = self.in_data
-    if len(self.disks) != 2:
-      raise errors.OpExecError("Only two-disk configurations supported")
 
     disk_space = _ComputeDiskSize(self.disk_template, self.disks)
 
@@ -6630,8 +6628,6 @@ class LUTestAllocator(NoHooksLU):
                                      " 'nics' parameter")
       if not isinstance(self.op.disks, list):
         raise errors.OpPrereqError("Invalid parameter 'disks'")
-      if len(self.op.disks) != 2:
-        raise errors.OpPrereqError("Only two-disk configurations supported")
       for row in self.op.disks:
         if (not isinstance(row, dict) or
             "size" not in row or
@@ -6640,7 +6636,7 @@ class LUTestAllocator(NoHooksLU):
             row["mode"] not in ['r', 'w']):
           raise errors.OpPrereqError("Invalid contents of the"
                                      " 'disks' parameter")
-      if self.op.hypervisor is None:
+      if not hasattr(self.op, "hypervisor") or self.op.hypervisor is None:
         self.op.hypervisor = self.cfg.GetHypervisorType()
     elif self.op.mode == constants.IALLOCATOR_MODE_RELOC:
       if not hasattr(self.op, "name"):
diff --git a/scripts/gnt-debug b/scripts/gnt-debug
index ed2a3ae38..ff7e01b30 100755
--- a/scripts/gnt-debug
+++ b/scripts/gnt-debug
@@ -156,7 +156,7 @@ commands = {
                  make_option("-m", "--mode", default="relocate",
                              choices=["relocate", "allocate"],
                              help="Request mode, either allocate or"
-                             "relocate"),
+                             " relocate"),
                  cli_option("--mem", default=128, type="unit",
                             help="Memory size for the instance (MiB)"),
                  make_option("--disks", default="4096,4096",
-- 
GitLab