Skip to content

Commit

Permalink
Allow changing the names of existing devices.
Browse files Browse the repository at this point in the history
This can happen due to a rename outside of blivet or just an update
while populating the devicetree for dodgy things like md arrays.
  • Loading branch information
dwlehman committed Mar 17, 2015
1 parent 25d876d commit d1dd225
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
4 changes: 0 additions & 4 deletions blivet/devices/dm.py
Expand Up @@ -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):
Expand Down
7 changes: 4 additions & 3 deletions blivet/devices/storage.py
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions blivet/populator.py
Expand Up @@ -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
Expand Down

0 comments on commit d1dd225

Please sign in to comment.