gnt-debug, opcodes: Use constants for iallocator
authorMichael Hanselmann <hansmi@google.com>
Thu, 12 May 2011 13:40:58 +0000 (15:40 +0200)
committerMichael Hanselmann <hansmi@google.com>
Thu, 12 May 2011 16:38:08 +0000 (18:38 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/client/gnt_debug.py
lib/opcodes.py

index e50eb0b..3e7a4f4 100644 (file)
@@ -129,8 +129,10 @@ def TestAllocator(opts, args):
 
   """
   try:
-    disks = [{"size": utils.ParseUnit(val), "mode": 'w'}
-             for val in opts.disks.split(",")]
+    disks = [{
+      constants.IDISK_SIZE: utils.ParseUnit(val),
+      constants.IDISK_MODE: constants.DISK_RDWR,
+      } for val in opts.disks.split(",")]
   except errors.UnitParseError, err:
     ToStderr("Invalid disks parameter '%s': %s", opts.disks, err)
     return 1
@@ -142,7 +144,12 @@ def TestAllocator(opts, args):
     for i in range(3):
       if row[i] == '':
         row[i] = None
-  nic_dict = [{"mac": v[0], "ip": v[1], "bridge": v[2]} for v in nics]
+  nic_dict = [{
+    constants.INIC_MAC: v[0],
+    constants.INIC_IP: v[1],
+    # The iallocator interface defines a "bridge" item
+    "bridge": v[2],
+    } for v in nics]
 
   if opts.tags is None:
     opts.tags = []
index 191a743..698fb45 100644 (file)
@@ -1418,7 +1418,7 @@ class OpTestAllocator(OpCode):
     ("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES), None),
     ("name", ht.NoDefault, ht.TNonEmptyString, None),
     ("nics", ht.NoDefault, ht.TOr(ht.TNone, ht.TListOf(
-     ht.TDictOf(ht.TElemOf(["mac", "ip", "bridge"]),
+     ht.TDictOf(ht.TElemOf([constants.INIC_MAC, constants.INIC_IP, "bridge"]),
                 ht.TOr(ht.TNone, ht.TNonEmptyString)))), None),
     ("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList), None),
     ("hypervisor", None, ht.TMaybeString, None),