From d1dd22597a1b87e577f747ef2bb5cc75f6a1d48e Mon Sep 17 00:00:00 2001 From: David Lehman Date: Wed, 5 Nov 2014 17:41:04 -0600 Subject: [PATCH] Allow changing the names of existing devices. 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 25e30cf25..e178cec63 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 1399ec2cd..edc42a574 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 1d754246e..8a9946631 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