backend.DemoteFromMC: don't fail for missing files
[ganeti-local] / lib / objects.py
index 2efc59e..8106287 100644 (file)
@@ -179,7 +179,7 @@ class TaggableObject(ConfigObject):
                             constants.MAX_TAG_LEN)
     if not tag:
       raise errors.TagError("Tags cannot be empty")
-    if not re.match("^[ \w.+*/:-]+$", tag):
+    if not re.match("^[\w.+*/:-]+$", tag):
       raise errors.TagError("Tag contains invalid characters")
 
   def GetTags(self):
@@ -494,9 +494,21 @@ class Disk(ConfigObject):
       val += ", not visible"
     else:
       val += ", visible as /dev/%s" % self.iv_name
-    val += ", size=%dm)>" % self.size
+    if isinstance(self.size, int):
+      val += ", size=%dm)>" % self.size
+    else:
+      val += ", size='%s')>" % (self.size,)
     return val
 
+  def Verify(self):
+    """Checks that this disk is correctly configured.
+
+    """
+    errors = []
+    if self.mode not in constants.DISK_ACCESS_SET:
+      errors.append("Disk access mode '%s' is invalid" % (self.mode, ))
+    return errors
+
 
 class Instance(TaggableObject):
   """Config object representing an instance."""
@@ -507,7 +519,7 @@ class Instance(TaggableObject):
     "hypervisor",
     "hvparams",
     "beparams",
-    "status",
+    "admin_up",
     "nics",
     "disks",
     "disk_template",
@@ -689,6 +701,7 @@ class Node(TaggableObject):
     "serial_no",
     "master_candidate",
     "offline",
+    "drained",
     ]
 
 
@@ -751,7 +764,7 @@ class Cluster(TaggableObject):
   def FillHV(self, instance):
     """Fill an instance's hvparams dict.
 
-    @type instance: object
+    @type instance: L{objects.Instance}
     @param instance: the instance parameter to fill
     @rtype: dict
     @return: a copy of the instance's hvparams with missing keys filled from
@@ -764,7 +777,7 @@ class Cluster(TaggableObject):
   def FillBE(self, instance):
     """Fill an instance's beparams dict.
 
-    @type instance: object
+    @type instance: L{objects.Instance}
     @param instance: the instance parameter to fill
     @rtype: dict
     @return: a copy of the instance's beparams with missing keys filled from