From a805ec18edf2e55963057adfcb7f2308d88fc8a1 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Sun, 26 Jul 2009 21:26:57 +0200 Subject: [PATCH] Add a objects.Disk.UnsetSize() method This method recursively resets the size of the disk and its children to zero. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/objects.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/objects.py b/lib/objects.py index cc3307dce..947678bec 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -396,6 +396,15 @@ class Disk(ConfigObject): 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. -- GitLab