[master 7/11] Allow changing the names of existing devices.

dwlehman installerbot-noreply at redhat.com
Tue Mar 17 20:07:34 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 | 7 ++++---
 blivet/populator.py       | 4 +---
 3 files changed, 5 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..edc42a5 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -204,11 +204,12 @@ 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
+        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/d1dd22597a1b87e577f747ef2bb5cc75f6a1d48e


More information about the anaconda-patches mailing list