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 19, 2015
1 parent f412046 commit bf390e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 0 additions & 4 deletions blivet/devices/dm.py
Original file line number Diff line number Diff line change
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
9 changes: 6 additions & 3 deletions blivet/devices/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions blivet/populator.py
Original file line number Diff line number Diff line change
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 bf390e6

Please sign in to comment.