From 79f3a94ba8a17eed212b51144ac5635d72beced3 Mon Sep 17 00:00:00 2001
From: "Samantha N. Bueno" <sbueno+anaconda@redhat.com>
Date: Tue, 22 Mar 2016 21:48:33 -0400
Subject: [PATCH 2/7] Move StorageDiscoveryConfig from blivet.blivet to
 blivet.osinstall

As this is mostly pertaining to the installer storage configuration,
move this into osinstall.

Since exlusive_disks, ignored_disks, and disk_images were previously moved
from StorageDiscoveryConfig class to Blivet class, make requisite changes to
devicetree and populaor class which rely on those attributes.

Namely, don't pass in the entire storage configuration anymore; just pass in
the three attrs we moved into Blivet class (exclusive_disks, ignored_disks, and
disk_images).
---
 blivet/blivet.py              | 34 +---------------------------------
 blivet/devicetree.py          | 22 ++++++++++++----------
 blivet/osinstall.py           | 30 ++++++++++++++++++++++++++++++
 blivet/populator/populator.py | 11 +++++------
 4 files changed, 48 insertions(+), 49 deletions(-)

diff --git a/blivet/blivet.py b/blivet/blivet.py
index aefb410..97fbd68 100644
--- a/blivet/blivet.py
+++ b/blivet/blivet.py
@@ -46,7 +46,7 @@ from .formats import get_default_filesystem_type
 from .flags import flags
 from .platform import platform as _platform
 from .formats import get_format
-from .osinstall import FSSet, find_existing_installations
+from .osinstall import FSSet, StorageDiscoveryConfig, find_existing_installations
 from . import arch
 from .iscsi import iscsi
 from .fcoe import fcoe
@@ -71,38 +71,6 @@ def empty_device(device):
 
     return empty
 
-
-class StorageDiscoveryConfig(object):
-
-    """ Class to encapsulate various detection/initialization parameters. """
-
-    def __init__(self):
-        # storage configuration variables
-        self.ignore_disk_interactive = False
-        self.clear_part_type = None
-        self.clear_part_disks = []
-        self.clear_part_devices = []
-        self.initialize_disks = False
-        self.protected_dev_specs = []
-        self.zero_mbr = False
-
-        # Whether clear_partitions removes scheduled/non-existent devices and
-        # disklabels depends on this flag.
-        self.clear_non_existent = False
-
-    def update(self, ksdata):
-        """ Update configuration from ksdata source.
-
-            :param ksdata: kickstart data used as data source
-            :type ksdata: :class:`pykickstart.Handler`
-        """
-        self.clear_part_type = ksdata.clearpart.type
-        self.clear_part_disks = ksdata.clearpart.drives[:]
-        self.clear_part_devices = ksdata.clearpart.devices[:]
-        self.initialize_disks = ksdata.clearpart.initAll
-        self.zero_mbr = ksdata.zerombr.zerombr
-
-
 class Blivet(object, metaclass=SynchronizedMeta):
 
     """ Top-level class for managing storage configuration. """
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index a6ec219..d5b252f 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -69,14 +69,16 @@ class DeviceTreeBase(object, metaclass=SynchronizedMeta):
         :class:`~.deviceaction.DeviceAction` instances can only be registered
         for leaf devices, except for resize actions.
     """
-    def __init__(self, conf=None):
+    def __init__(self, ignored_disks=None, exclusive_disks=None):
         """
-            :keyword conf: storage discovery configuration
-            :type conf: :class:`~.StorageDiscoveryConfig`
+            :keyword ignored_disks: storage discovery configuration
+            :type ignored_disks: :class:`~.StorageDiscoveryConfig`
+            :keyword exclusive_disks: storage discovery configuration
+            :type exclusive_disks: :class:`~.StorageDiscoveryConfig`
         """
-        self.reset(conf)
+        self.reset(ignored_disks, exclusive_disks)
 
-    def reset(self, conf=None):
+    def reset(self, ignored_disks=None, exclusive_disks=None):
         """ Reset the instance to its initial state. """
         # internal data members
         self._devices = []
@@ -90,8 +92,8 @@ class DeviceTreeBase(object, metaclass=SynchronizedMeta):
 
         lvm.lvm_cc_resetFilter()
 
-        self.exclusive_disks = getattr(conf, "exclusive_disks", [])
-        self.ignored_disks = getattr(conf, "ignored_disks", [])
+        self.exclusive_disks= exclusive_disks
+        self.ignored_disks = ignored_disks
 
         self.edd_dict = {}
 
@@ -882,9 +884,9 @@ class DeviceTreeBase(object, metaclass=SynchronizedMeta):
 
 
 class DeviceTree(DeviceTreeBase, PopulatorMixin, EventHandlerMixin):
-    def __init__(self, conf=None, passphrase=None, luks_dict=None):
-        DeviceTreeBase.__init__(self, conf=conf)
-        PopulatorMixin.__init__(self, conf=conf, passphrase=passphrase, luks_dict=luks_dict)
+    def __init__(self, passphrase=None, luks_dict=None, ignored_disks=None, exclusive_disks=None, disk_images=None):
+        DeviceTreeBase.__init__(self, ignored_disks=ignored_disks, exclusive_disks=exclusive_disks)
+        PopulatorMixin.__init__(self, passphrase=passphrase, luks_dict=luks_dict, disk_images=disk_images)
         EventHandlerMixin.__init__(self)
 
     # pylint: disable=arguments-differ
diff --git a/blivet/osinstall.py b/blivet/osinstall.py
index 96fc4a5..936945b 100644
--- a/blivet/osinstall.py
+++ b/blivet/osinstall.py
@@ -277,6 +277,36 @@ def _find_existing_installations(devicetree):
 
     return roots
 
+class StorageDiscoveryConfig(object):
+
+    """ Class to encapsulate various detection/initialization parameters. """
+
+    def __init__(self):
+        # storage configuration variables
+        self.ignore_disk_interactive = False
+        self.clear_part_type = None
+        self.clear_part_disks = []
+        self.clear_part_devices = []
+        self.initialize_disks = False
+        self.protected_dev_specs = []
+        self.zero_mbr = False
+
+        # Whether clear_partitions removes scheduled/non-existent devices and
+        # disklabels depends on this flag.
+        self.clear_non_existent = False
+
+    def update(self, ksdata):
+        """ Update configuration from ksdata source.
+
+            :param ksdata: kickstart data used as data source
+            :type ksdata: :class:`pykickstart.Handler`
+        """
+        self.clear_part_type = ksdata.clearpart.type
+        self.clear_part_disks = ksdata.clearpart.drives[:]
+        self.clear_part_devices = ksdata.clearpart.devices[:]
+        self.initialize_disks = ksdata.clearpart.init_all
+        self.zero_mbr = ksdata.zerombr.zerombr
+
 
 class FSSet(object):
 
diff --git a/blivet/populator/populator.py b/blivet/populator/populator.py
index 816c226..f141f1d 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, metaclass=SynchronizedMeta):
-    def __init__(self, conf=None, passphrase=None, luks_dict=None):
+    def __init__(self, passphrase=None, luks_dict=None, disk_images=None):
         """
             :keyword conf: storage discovery configuration
             :type conf: :class:`~.StorageDiscoveryConfig`
@@ -72,14 +72,13 @@ class PopulatorMixin(object, metaclass=SynchronizedMeta):
             :type luks_dict: dict
 
         """
-        self.reset(conf=conf, passphrase=passphrase, luks_dict=luks_dict)
+        self.reset(passphrase=passphrase, luks_dict=luks_dict, disk_images=disk_images)
 
-    def reset(self, conf=None, passphrase=None, luks_dict=None):
+    def reset(self, passphrase=None, luks_dict=None, disk_images=None):
         self.disk_images = {}
-        images = getattr(conf, "disk_images", {})
-        if images:
+        if disk_images:
             # this will overwrite self.exclusive_disks
-            self.set_disk_images(images)
+            self.set_disk_images(disk_images)
 
         # protected device specs as provided by the user
         self.protected_dev_specs = getattr(conf, "protected_dev_specs", [])
-- 
2.4.3

