summaryrefslogtreecommitdiffstats
path: root/storage/__init__.py
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2009-06-30 17:27:10 -0500
committerDavid Lehman <dlehman@redhat.com>2009-07-01 12:53:25 -0500
commitb7a5272ec3164a48cf3546acb78a14c601c2fddf (patch)
treef197e7688fcfb3bf47d6d6d4515c8984e224c69c /storage/__init__.py
parentc44cd82d9744303aad2e88371a41e532433478fa (diff)
downloadanaconda-b7a5272ec3164a48cf3546acb78a14c601c2fddf.tar.gz
anaconda-b7a5272ec3164a48cf3546acb78a14c601c2fddf.tar.xz
anaconda-b7a5272ec3164a48cf3546acb78a14c601c2fddf.zip
Rework tracking of devices containing installation media. (#497087)
In storage.Storage we keep the device specifications as provided to us. In the devicetree, during population, we use udev to resolve the user- provided specs to device names. As we create StorageDevice instances for the devices, we set a new attribute ("protected") as appropriate. Once the DeviceTree is populated, we use the devices' protected attribute to determine whether or not they contain installation media. This way we can track protected devices even when their names change.
Diffstat (limited to 'storage/__init__.py')
-rw-r--r--storage/__init__.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/storage/__init__.py b/storage/__init__.py
index aed4f03c7..358b8088e 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -69,26 +69,15 @@ def storageInitialize(anaconda):
if os.path.exists("/dev/live") and \
stat.S_ISBLK(os.stat("/dev/live")[stat.ST_MODE]):
target = os.readlink("/dev/live")
- storage.protectedPartitions = [target]
+ storage.protectedDevSpecs = [target]
storage.reset()
elif anaconda.methodstr and anaconda.methodstr.startswith("hd:"):
method = anaconda.methodstr[3:]
devspec = method.split(":", 3)[0]
-
- for entry in udev_get_block_devices():
- if devspec.startswith("LABEL=") and udev_device_get_label(entry) == devspec[6:]:
- storage.protectedPartitions = [udev_device_get_name(entry)]
- break
- elif devspec.startswith("UUID=") and udev_device_get_uuid(entry) == devspec[5:]:
- storage.protectedPartitions = [udev_device_get_name(entry)]
- break
- elif udev_device_get_name(entry) == devicePathToName(devspec):
- storage.protectedPartitions = [udev_device_get_name(entry)]
- break
-
+ storage.protectedDevSpecs.append(devspec)
storage.reset()
- if not storage.protectedPartitions or not storage.devicetree.getDeviceByName(storage.protectedPartitions[0]):
+ if not storage.protectedDevices:
if anaconda.id.getUpgrade():
return
else:
@@ -209,7 +198,7 @@ class Storage(object):
self.encryptionRetrofit = False
self.reinitializeDisks = False
self.zeroMbr = None
- self.protectedPartitions = []
+ self.protectedDevSpecs = []
self.autoPartitionRequests = []
self.__luksDevs = {}
@@ -228,7 +217,7 @@ class Storage(object):
type=self.clearPartType,
clear=self.clearPartDisks,
reinitializeDisks=self.reinitializeDisks,
- protected=self.protectedPartitions,
+ protected=self.protectedDevSpecs,
zeroMbr=self.zeroMbr,
passphrase=self.encryptionPassphrase,
luksDict=self.__luksDevs)
@@ -292,7 +281,7 @@ class Storage(object):
type=clearPartType,
clear=self.clearPartDisks,
reinitializeDisks=self.reinitializeDisks,
- protected=self.protectedPartitions,
+ protected=self.protectedDevSpecs,
zeroMbr=self.zeroMbr,
passphrase=self.encryptionPassphrase,
luksDict=self.__luksDevs)
@@ -449,6 +438,13 @@ class Storage(object):
swaps.sort(key=lambda d: d.name)
return swaps
+ @property
+ def protectedDevices(self):
+ devices = self.devicetree.devices.values()
+ protected = [d for d in devices if d.protected]
+ protected.sort(key=lambda d: d.name)
+ return protected
+
def exceptionDisks(self):
""" Return a list of removable devices to save exceptions to.