From: David Lehman <dlehman(a)redhat.com>
This is intended to be used under a very limited set of circumstances,
such as resize of inactive LVs from outside of blivet.
---
blivet/devices/btrfs.py | 2 +-
blivet/devices/container.py | 2 +-
blivet/devices/md.py | 4 ++--
blivet/devices/nfs.py | 2 +-
blivet/devices/nodev.py | 2 +-
blivet/devices/storage.py | 21 ++++++++++++++++++---
6 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
index e2f6ee1..b50ea97 100644
--- a/blivet/devices/btrfs.py
+++ b/blivet/devices/btrfs.py
@@ -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):
diff --git a/blivet/devices/container.py b/blivet/devices/container.py
index 56ba301..a2419f2 100644
--- a/blivet/devices/container.py
+++ b/blivet/devices/container.py
@@ -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
diff --git a/blivet/devices/md.py b/blivet/devices/md.py
index 3045de7..7bc2531 100644
--- a/blivet/devices/md.py
+++ b/blivet/devices/md.py
@@ -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):
diff --git a/blivet/devices/nfs.py b/blivet/devices/nfs.py
index 3143d7c..c5e3891 100644
--- a/blivet/devices/nfs.py
+++ b/blivet/devices/nfs.py
@@ -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
diff --git a/blivet/devices/nodev.py b/blivet/devices/nodev.py
index 099bf42..f612925 100644
--- a/blivet/devices/nodev.py
+++ b/blivet/devices/nodev.py
@@ -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
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 5b2a3fa..39cf18d 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -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
--
To view this commit on github, visit
https://github.com/rhinstaller/blivet/commit/e8363a4b345130bb04b713245966...