Modify two mirror-device related rpc calls
[ganeti-local] / lib / cli.py
index 08a9064..d1b6925 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#
 #
 
 # Copyright (C) 2006, 2007 Google Inc.
@@ -60,7 +60,7 @@ def _ExtractTagsObject(opts, args):
     retval = kind, kind
   elif kind == constants.TAG_NODE or kind == constants.TAG_INSTANCE:
     if not args:
-      raise errors.OpPrereq("no arguments passed to the command")
+      raise errors.OpPrereqError("no arguments passed to the command")
     name = args.pop(0)
     retval = kind, name
   else:
@@ -311,7 +311,7 @@ def AskUser(text, choices=None):
     new_text.append(textwrap.fill(line, 70, replace_whitespace=False))
   text = "\n".join(new_text)
   try:
-    f = file("/dev/tty", "r+")
+    f = file("/dev/tty", "a+")
   except IOError:
     return answer
   try:
@@ -479,6 +479,9 @@ def GenerateTable(headers, fields, separator, data,
 
   format_fields = []
   for field in fields:
+    if headers and field not in headers:
+      raise errors.ProgrammerError("Missing header description for field '%s'"
+                                   % field)
     if separator is not None:
       format_fields.append("%s")
     elif field in numfields:
@@ -501,6 +504,7 @@ def GenerateTable(headers, fields, separator, data,
           pass
         else:
           val = row[idx] = utils.FormatUnit(val)
+      val = row[idx] = str(val)
       if separator is None:
         mlens[idx] = max(mlens[idx], len(val))