Skip to content

Commit

Permalink
Add support for passing the new size into StorageDevice.updateSize.
Browse files Browse the repository at this point in the history
This is intended to be used under a very limited set of circumstances,
such as resize of inactive LVs from outside of blivet.
  • Loading branch information
dwlehman committed Feb 1, 2016
1 parent 4f61d82 commit e8363a4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion blivet/devices/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def update_sysfs_path(self):
self.sysfs_path = self.parents[0].sysfs_path
log.debug("%s sysfs_path set to %s", self.name, self.sysfs_path)

def update_size(self):
def update_size(self, newsize=None):
pass

def _post_create(self):
Expand Down
2 changes: 1 addition & 1 deletion blivet/devices/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ def remove(self, member):
if member in self.parents:
self.parents.remove(member)

def update_size(self):
def update_size(self, newsize=None):
pass
4 changes: 2 additions & 2 deletions blivet/devices/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ def size(self):

return size

def update_size(self):
def update_size(self, newsize=None):
# container size is determined by the member disks, so there is nothing
# to update in that case
if self.type != "mdcontainer":
# pylint: disable=bad-super-call
super(ContainerDevice, self).update_size()
super(ContainerDevice, self).update_size(newsize=newsize)

@property
def description(self):
Expand Down
2 changes: 1 addition & 1 deletion blivet/devices/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def destroy(self):
""" Destroy the device. """
log_method_call(self, self.name, status=self.status)

def update_size(self):
def update_size(self, newsize=None):
pass

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion blivet/devices/nodev.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def destroy(self):
log_method_call(self, self.name, status=self.status)
self._pre_destroy()

def update_size(self):
def update_size(self, newsize=None):
pass


Expand Down
21 changes: 18 additions & 3 deletions blivet/devices/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,24 @@ def current_size(self):
self._current_size = self.read_current_size()
return self._current_size

def update_size(self):
""" Update size, current_size, and target_size to actual size. """
self._current_size = Size(0)
def update_size(self, newsize=None):
""" Update size, current_size, and target_size to actual size.
:keyword :class:`~.size.Size` newsize: new size for device
.. note::
Most callers will not pass a new size. It is for special cases
like outside resize of inactive LVs, which precludes updating
the size from /sys.
"""
if newsize is None:
self._currentSize = Size(0)
elif isinstance(newsize, Size):
self._currentSize = newsize
else:
raise ValueError("new size must be an instance of class Size")

new_size = self.current_size
self._size = new_size
self._target_size = new_size # bypass setter checks
Expand Down

0 comments on commit e8363a4

Please sign in to comment.