From: David Lehman <dlehman(a)redhat.com>
See Blivet.write_dasd_conf for an example of how to get
a list of the DASDs.
---
blivet/blivet.py | 22 ++++++---------
blivet/devicetree.py | 58 +++++-----------------------------------
blivet/populator/helpers/disk.py | 3 ---
blivet/populator/populator.py | 9 +++----
4 files changed, 17 insertions(+), 75 deletions(-)
diff --git a/blivet/blivet.py b/blivet/blivet.py
index 710da61..795a775 100644
--- a/blivet/blivet.py
+++ b/blivet/blivet.py
@@ -134,7 +134,6 @@ def __init__(self, ksdata=None):
self.autopart_add_backup_passphrase = False
self.autopart_requests = []
self.edd_dict = {}
- self.dasd = []
self.__luks_devs = {}
self.size_sets = []
@@ -152,8 +151,7 @@ def __init__(self, ksdata=None):
self.devicetree = DeviceTree(conf=self.config,
passphrase=self.encryption_passphrase,
luks_dict=self.__luks_devs,
- iscsi=self.iscsi,
- dasd=self.dasd)
+ iscsi=self.iscsi)
self.fsset = FSSet(self.devicetree)
self.roots = []
self.services = set()
@@ -272,17 +270,11 @@ def reset(self, cleanup_only=False):
self.iscsi.startup()
self.fcoe.startup()
self.zfcp.startup()
- self.dasd = self.devicetree.make_dasd_list(self.dasd, self.devices)
-
- if self.dasd:
- # Reset the internal dasd list (823534)
- self.dasd = []
self.devicetree.reset(conf=self.config,
passphrase=self.encryption_passphrase,
luks_dict=self.__luks_devs,
- iscsi=self.iscsi,
- dasd=self.dasd)
+ iscsi=self.iscsi)
self.devicetree.populate(cleanup_only=cleanup_only)
self.fsset = FSSet(self.devicetree)
self.edd_dict = get_edd_dict(self.partitioned)
@@ -1392,17 +1384,19 @@ def write(self):
self.iscsi.write(get_sysroot(), self)
self.fcoe.write(get_sysroot())
self.zfcp.write(get_sysroot())
- self.write_dasd_conf(self.dasd, get_sysroot())
+ self.write_dasd_conf(get_sysroot())
- def write_dasd_conf(self, disks, root):
+ def write_dasd_conf(self, root):
""" Write /etc/dasd.conf to target system for all DASD devices
configured during installation.
"""
- if not (arch.is_s390() and disks):
+ dasds = self.devicetree.get_devices_by_type("dasd")
+ dasds.sort(key=lambda d: d.name)
+ if not (arch.is_s390() and dasds):
return
with open(os.path.realpath(root + "/etc/dasd.conf"), "w") as
f:
- for dasd in sorted(disks, key=lambda d: d.name):
+ for dasd in dasds:
fields = [dasd.busid] + dasd.get_opts()
f.write("%s\n" % " ".join(fields),)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index fb9b146..bc4db12 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -31,9 +31,9 @@
from .actionlist import ActionList
from .errors import DeviceError, DeviceTreeError, StorageError
from .deviceaction import ActionDestroyDevice, ActionDestroyFormat
-from .devices import BTRFSDevice, DASDDevice, NoDevice, PartitionDevice
+from .devices import BTRFSDevice, NoDevice, PartitionDevice
from .devices import LVMLogicalVolumeDevice, LVMVolumeGroupDevice
-from . import formats, arch
+from . import formats
from .devicelibs import lvm
from . import util
from .populator import PopulatorMixin
@@ -719,45 +719,6 @@ def resolve_device(self, devspec, blkid_tab=None, crypt_tab=None,
options=None):
return device
#
- # DASD
- #
- def make_dasd_list(self, dasds, disks):
- """ Create a list of DASDs recognized by the system
-
- :param list dasds: a list of DASD devices
- :param list disks: a list of disks on the system
- :returns: a list of DASD devices identified on the system
- :rtype: list of :class:
- """
- if not arch.is_s390():
- return
-
- log.info("Generating DASD list....")
- for dev in (disk for disk in disks if disk.type == "dasd"):
- if dev not in dasds:
- dasds.append(dev)
-
- return dasds
-
- def make_unformatted_dasd_list(self, dasds):
- """ Create a list of DASDs which are detected to require dasdfmt.
-
- :param list dasds: a list of DASD devices
- :returns: a list of DASDs which need dasdfmt in order to be used
- :rtype: list of :class:
- """
- if not arch.is_s390():
- return
-
- unformatted = []
-
- for dasd in dasds:
- if blockdev.s390.dasd_needs_format(dasd.busid):
- unformatted.append(dasd)
-
- return unformatted
-
- #
# Conveniences
#
@property
@@ -885,10 +846,6 @@ def hide(self, device):
self._hidden.append(device)
lvm.lvm_cc_addFilterRejectRegexp(device.name)
- if isinstance(device, DASDDevice):
- # pylint: disable=no-member
- self.dasd.remove(device)
-
if device.name not in self.names:
self.names.append(device.name)
@@ -917,9 +874,6 @@ def unhide(self, device):
self._devices.append(hidden)
hidden.add_hook(new=False)
lvm.lvm_cc_removeFilterRejectRegexp(hidden.name)
- if isinstance(device, DASDDevice):
- # pylint: disable=no-member
- self.dasd.append(device)
def _is_ignored_disk(self, disk):
return ((self.ignored_disks and disk.name in self.ignored_disks) or
@@ -943,12 +897,12 @@ def _hide_ignored_disks(self):
class DeviceTree(DeviceTreeBase, PopulatorMixin):
- def __init__(self, conf=None, passphrase=None, luks_dict=None, iscsi=None,
dasd=None):
+ def __init__(self, conf=None, passphrase=None, luks_dict=None, iscsi=None):
DeviceTreeBase.__init__(self, conf=conf)
- PopulatorMixin.__init__(self, passphrase=passphrase, luks_dict=luks_dict,
iscsi=iscsi, dasd=dasd)
+ PopulatorMixin.__init__(self, passphrase=passphrase, luks_dict=luks_dict,
iscsi=iscsi)
# pylint: disable=arguments-differ
- def reset(self, conf=None, passphrase=None, luks_dict=None, iscsi=None, dasd=None):
+ def reset(self, conf=None, passphrase=None, luks_dict=None, iscsi=None):
DeviceTreeBase.reset(self, conf=conf)
PopulatorMixin.reset(self, conf=conf, passphrase=passphrase,
luks_dict=luks_dict,
- iscsi=iscsi, dasd=dasd)
+ iscsi=iscsi)
diff --git a/blivet/populator/helpers/disk.py b/blivet/populator/helpers/disk.py
index fb93721..69045e5 100644
--- a/blivet/populator/helpers/disk.py
+++ b/blivet/populator/helpers/disk.py
@@ -72,9 +72,6 @@ def run(self):
kwargs = self._get_kwargs()
device = self._device_class(name, **kwargs)
- if self._device_class == DASDDevice:
- self._devicetree.dasd.append(device)
-
self._devicetree._add_device(device)
return device
diff --git a/blivet/populator/populator.py b/blivet/populator/populator.py
index 7f2c243..8a0a47b 100644
--- a/blivet/populator/populator.py
+++ b/blivet/populator/populator.py
@@ -63,7 +63,7 @@ def parted_exn_handler(exn_type, exn_options, exn_msg):
class PopulatorMixin(object):
- def __init__(self, conf=None, passphrase=None, luks_dict=None, iscsi=None,
dasd=None):
+ def __init__(self, conf=None, passphrase=None, luks_dict=None, iscsi=None):
"""
:keyword conf: storage discovery configuration
:type conf: :class:`~.StorageDiscoveryConfig`
@@ -72,18 +72,15 @@ def __init__(self, conf=None, passphrase=None, luks_dict=None,
iscsi=None, dasd=
:type luks_dict: dict
:keyword iscsi: ISCSI control object
:type iscsi: :class:`~.iscsi.iscsi`
- :keyword dasd: DASD control object
- :type dasd: :class:`~.dasd.DASD`
"""
- self.reset(conf=conf, passphrase=passphrase, luks_dict=luks_dict, iscsi=iscsi,
dasd=dasd)
+ self.reset(conf=conf, passphrase=passphrase, luks_dict=luks_dict, iscsi=iscsi)
- def reset(self, conf=None, passphrase=None, luks_dict=None, iscsi=None, dasd=None):
+ def reset(self, conf=None, passphrase=None, luks_dict=None, iscsi=None):
# indicates whether or not the tree has been fully populated
self.populated = False
self.iscsi = iscsi
- self.dasd = dasd
self.disk_images = {}
images = getattr(conf, "disk_images", {})
--
To view this commit on github, visit
https://github.com/rhinstaller/blivet/commit/7523d41266849dc9d617c6dc0623...