projects
/
ganeti-local
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix /proc/drbd parsing in presence of gaps
[ganeti-local]
/
lib
/
objects.py
diff --git
a/lib/objects.py
b/lib/objects.py
index
2efc59e
..
947678b
100644
(file)
--- a/
lib/objects.py
+++ b/
lib/objects.py
@@
-153,6
+153,14
@@
class ConfigObject(object):
" _ContainerFromDicts" % c_type)
return ret
" _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())
def __repr__(self):
"""Implement __repr__ for ConfigObjects."""
return repr(self.ToDict())
@@
-179,7
+187,7
@@
class TaggableObject(ConfigObject):
constants.MAX_TAG_LEN)
if not tag:
raise errors.TagError("Tags cannot be empty")
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.TagError("Tag contains invalid characters")
def GetTags(self):
@@
-388,6
+396,15
@@
class Disk(ConfigObject):
raise errors.ProgrammerError("Disk.RecordGrow called for unsupported"
" disk type %s" % self.dev_type)
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.
def SetPhysicalID(self, target_node, nodes_ip):
"""Convert the logical ID to the physical ID.
@@
-494,9
+511,21
@@
class Disk(ConfigObject):
val += ", not visible"
else:
val += ", visible as /dev/%s" % self.iv_name
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
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."""
class Instance(TaggableObject):
"""Config object representing an instance."""
@@
-507,7
+536,7
@@
class Instance(TaggableObject):
"hypervisor",
"hvparams",
"beparams",
"hypervisor",
"hvparams",
"beparams",
- "status",
+ "admin_up",
"nics",
"disks",
"disk_template",
"nics",
"disks",
"disk_template",
@@
-689,6
+718,7
@@
class Node(TaggableObject):
"serial_no",
"master_candidate",
"offline",
"serial_no",
"master_candidate",
"offline",
+ "drained",
]
]
@@
-751,7
+781,7
@@
class Cluster(TaggableObject):
def FillHV(self, instance):
"""Fill an instance's hvparams dict.
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
@param instance: the instance parameter to fill
@rtype: dict
@return: a copy of the instance's hvparams with missing keys filled from
@@
-764,7
+794,7
@@
class Cluster(TaggableObject):
def FillBE(self, instance):
"""Fill an instance's beparams dict.
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
@param instance: the instance parameter to fill
@rtype: dict
@return: a copy of the instance's beparams with missing keys filled from