[master 3/13] Allow changing the names of existing devices.
dwlehman
installerbot-noreply at redhat.com
Thu Mar 19 19:59:25 UTC 2015
From: David Lehman <dlehman at redhat.com>
This can happen due to a rename outside of blivet or just an update
while populating the devicetree for dodgy things like md arrays.
---
blivet/devices/dm.py | 4 ----
blivet/devices/storage.py | 9 ++++++---
blivet/populator.py | 4 +---
3 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/blivet/devices/dm.py b/blivet/devices/dm.py
index 25e30cf..e178cec 100644
--- a/blivet/devices/dm.py
+++ b/blivet/devices/dm.py
@@ -139,11 +139,7 @@ def _setName(self, value):
return
log_method_call(self, self.name, status=self.status)
- if self.status:
- raise errors.DeviceError("cannot rename active device", self.name)
-
super(DMDevice, self)._setName(value)
- #self.sysfsPath = "/dev/disk/by-id/dm-name-%s" % self.name
@property
def slave(self):
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 1399ec2..be848ac 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -204,11 +204,14 @@ def _setName(self, value):
if value == self._name:
return
- if self.exists:
- raise errors.DeviceError("Cannot rename existing device.")
-
super(StorageDevice, self)._setName(value)
+ # update our format's path
+ # First, check that self._format has been defined in case this is
+ # running early in the constructor.
+ if hasattr(self, "_format") and self.format.device:
+ self.format.device = self.path
+
def alignTargetSize(self, newsize):
""" Return a proposed target size adjusted for device specifics.
diff --git a/blivet/populator.py b/blivet/populator.py
index 1d75424..8a99466 100644
--- a/blivet/populator.py
+++ b/blivet/populator.py
@@ -417,9 +417,7 @@ def addUdevMDDevice(self, info):
if device:
# update the device instance with the real name in case we had to
# look it up by something other than name
- # XXX bypass the setter since a) the device exists and b) the name
- # must be valid since it is currently in use
- device._name = name
+ device.name = name
else:
# if we get here, we found all of the slave devices and
# something must be wrong -- if all of the slaves are in
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/bf390e6d68cae97eb4619ff26e31b9e3a1028234
More information about the anaconda-patches
mailing list