" _ContainerFromDicts" % c_type)
return ret
+ def Copy(self):
+ """Makes a deep copy of the current object and its children.
+
+ """
+ dict_form = self.ToDict()
+ clone_obj = self.__class__.FromDict(dict_form)
+ return clone_obj
+
def __repr__(self):
"""Implement __repr__ for ConfigObjects."""
return repr(self.ToDict())
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):
raise errors.ProgrammerError("Disk.RecordGrow called for unsupported"
" disk type %s" % self.dev_type)
+ def UnsetSize(self):
+ """Sets recursively the size to zero for the disk and its children.
+
+ """
+ if self.children:
+ for child in self.children:
+ child.UnsetSize()
+ self.size = 0
+
def SetPhysicalID(self, target_node, nodes_ip):
"""Convert the logical ID to the physical ID.
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):
"serial_no",
"master_candidate",
"offline",
+ "drained",
]
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
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