Commit acec9d51 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add method to update a disk object size

This patch adds a method that implements updating of a disk
(object.Disk) size, together with its children.

While this will not track the exact disk size, it allows at least an
approximate size to be recorded in the configuration (and queried).

Reviewed-by: imsnah
parent 4c8ba8b3
......@@ -372,6 +372,24 @@ class Disk(ConfigObject):
# be different)
return result
def RecordGrow(self, amount):
"""Update the size of this disk after growth.
This method recurses over the disks's children and updates their
size correspondigly. The method needs to be kept in sync with the
actual algorithms from bdev.
if self.dev_type == constants.LD_LV:
self.size += amount
elif self.dev_type == constants.LD_DRBD8:
if self.children:
self.size += amount
raise errors.ProgrammerError("Disk.RecordGrow called for unsupported"
" disk type %s" % self.dev_type)
def ToDict(self):
"""Disk-specific conversion to standard python types.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment