From 729ac1ef9458bf2a63586956b00494c6234a031c Mon Sep 17 00:00:00 2001
From: "Samantha N. Bueno" <sbueno+anaconda@redhat.com>
Date: Thu, 24 Mar 2016 00:46:08 -0400
Subject: [PATCH 7/7] Get rid of blivet.blivet dependency on
 blivet.osinstall.find_existing_installations

Now nothing in blivet.blivet imports from osinstall.
---
 blivet/blivet.py    | 59 -----------------------------------------------------
 blivet/osinstall.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 52 insertions(+), 60 deletions(-)

diff --git a/blivet/blivet.py b/blivet/blivet.py
index bc5754f..1ed6bdc 100644
--- a/blivet/blivet.py
+++ b/blivet/blivet.py
@@ -36,7 +36,6 @@ from .devices import LVMLogicalVolumeDevice, LVMVolumeGroupDevice
 from .devices import MDRaidArrayDevice, PartitionDevice, TmpFSDevice, device_path_to_name
 from .deviceaction import ActionCreateDevice, ActionCreateFormat, ActionDestroyDevice
 from .deviceaction import ActionDestroyFormat, ActionResizeDevice, ActionResizeFormat
-from .devicelibs.edd import get_edd_dict
 from .devicelibs.btrfs import MAIN_VOLUME_ID
 from .devicelibs.crypto import LUKS_METADATA_SIZE
 from .errors import StorageError
@@ -46,11 +45,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 find_existing_installations
 from . import arch
-from .iscsi import iscsi
-from .fcoe import fcoe
-from .zfcp import zfcp
 from . import devicefactory
 from . import get_bootloader, get_sysroot, short_product_name, __version__
 from .threads import SynchronizedMeta
@@ -205,55 +200,6 @@ class Blivet(object, metaclass=SynchronizedMeta):
         except Exception:  # pylint: disable=broad-except
             log_exception_info(log.error, "failure tearing down device tree")
 
-    def reset(self, cleanup_only=False):
-        """ Reset storage configuration to reflect actual system state.
-
-            This will cancel any queued actions and rescan from scratch but not
-            clobber user-obtained information like passphrases, iscsi config, &c
-
-            :keyword cleanup_only: prepare the tree only to deactivate devices
-            :type cleanup_only: bool
-
-            See :meth:`devicetree.Devicetree.populate` for more information
-            about the cleanup_only keyword argument.
-        """
-        log.info("resetting Blivet (version %s) instance %s", __version__, self)
-        if flags.installer_mode:
-            # save passphrases for luks devices so we don't have to reprompt
-            self.encryption_passphrase = None
-            for device in self.devices:
-                if device.format.type == "luks" and device.format.exists:
-                    self.save_passphrase(device)
-
-        if flags.installer_mode and not flags.image_install:
-            iscsi.startup()
-            fcoe.startup()
-            zfcp.startup()
-
-        self.devicetree.reset(passphrase=self.encryption_passphrase,
-                              luks_dict=self.__luks_devs,
-                              ignored_disks=self.ignored_disks,
-                              exclusive_disks=self.exclusive_disks,
-                              disk_images=self.disk_images)
-        self.devicetree.populate(cleanup_only=cleanup_only)
-        #self.fsset = FSSet(self.devicetree)
-        self.edd_dict = get_edd_dict(self.partitioned)
-        self.devicetree.edd_dict = self.edd_dict
-        if self.bootloader:
-            # clear out bootloader attributes that refer to devices that are
-            # no longer in the tree
-            self.bootloader.reset()
-
-        self.roots = []
-        if flags.installer_mode:
-            self.roots = find_existing_installations(self.devicetree)
-            self.dump_state("initial")
-
-        if not flags.installer_mode:
-            self.devicetree.handle_nodev_filesystems()
-
-        self.update_bootloader_disk_list()
-
     @property
     def devices(self):
         """ A list of all the devices in the device tree. """
@@ -1129,11 +1075,6 @@ class Blivet(object, metaclass=SynchronizedMeta):
         if not os.path.isdir("%s/etc" % get_sysroot()):
             os.mkdir("%s/etc" % get_sysroot())
 
-        #self.fsset.write()
-        #self.make_mtab()
-        iscsi.write(get_sysroot(), self)
-        fcoe.write(get_sysroot())
-        zfcp.write(get_sysroot())
         self.write_dasd_conf(get_sysroot())
 
     def write_dasd_conf(self, root):
diff --git a/blivet/osinstall.py b/blivet/osinstall.py
index 766005a..e617583 100644
--- a/blivet/osinstall.py
+++ b/blivet/osinstall.py
@@ -38,10 +38,14 @@ from . import get_sysroot, get_target_physical_root, error_handler, ERROR_RAISE
 from .blivet import Blivet
 from .storage_log import log_exception_info
 from .devices import FileDevice, NFSDevice, NoDevice, OpticalDevice, NetworkStorageDevice, DirectoryDevice, MDRaidArrayDevice, BTRFSSubVolumeDevice, PartitionDevice, TmpFSDevice, LVMLogicalVolumeDevice, LVMVolumeGroupDevice, MDRaidArrayDevice, BTRFSDevice
+from .devicelibs.edd import get_edd_dict
 from .errors import FSTabTypeMismatchError, UnrecognizedFSTabEntryError, StorageError, FSResizeError, FormatResizeError, UnknownSourceDeviceError
 from .formats import get_device_format_class
 from .formats import get_format
 from .flags import flags
+from .iscsi import iscsi
+from .fcoe import fcoe
+from .zfcp import zfcp
 from .platform import platform as _platform
 from .platform import EFI
 from .size import Size
@@ -1106,13 +1110,57 @@ class InstallerStorageConfig(Blivet):
         self.config = StorageDiscoveryConfig()
 
     def reset(self, cleanup_only=False):
-        Blivet.reset(self, cleanup_only)
+        """ Reset storage configuration to reflect actual system state.
 
+            This will cancel any queued actions and rescan from scratch but not
+            clobber user-obtained information like passphrases, iscsi config, &c
+
+            :keyword cleanup_only: prepare the tree only to deactivate devices
+            :type cleanup_only: bool
+
+            See :meth:`devicetree.Devicetree.populate` for more information
+            about the cleanup_only keyword argument.
+        """
+        log.info("resetting Blivet (version %s) instance %s", __version__, self)
+        if flags.installer_mode:
+            # save passphrases for luks devices so we don't have to reprompt
+            self.encryption_passphrase = None 
+            for device in self.devices:
+                if device.format.type == "luks" and device.format.exists:
+                    self.save_passphrase(device)
+
+        if flags.installer_mode and not flags.image_install:
+            iscsi.startup()
+            fcoe.startup()
+            zfcp.startup()
+
+        self.devicetree.reset(passphrase=self.encryption_passphrase,
+                              luks_dict=self.__luks_devs,
+                              ignored_disks=self.ignored_disks,
+                              exclusive_disks=self.exclusive_disks,
+                              disk_images=self.disk_images)
+        self.devicetree.populate(cleanup_only=cleanup_only)
         self.fsset = FSSet(self.devicetree)
+        self.edd_dict = get_edd_dict(self.partitioned)
+        self.devicetree.edd_dict = self.edd_dict
+        if self.bootloader:
+            # clear out bootloader attributes that refer to devices that are
+            # no longer in the tree
+            self.bootloader.reset()
 
         if self.ksdata:
             self.config.updates(self.ksdata)
 
+        self.roots = [] 
+        if flags.installer_mode:
+            self.roots = find_existing_installations(self.devicetree)
+            self.dump_state("initial")
+
+        if not flags.installer_mode:
+            self.devicetree.handle_nodev_filesystems()
+
+        self.update_bootloader_disk_list()
+
     def get_free_space(self, disks=None, clear_part_type=None):
         Blivet.get_free_space(self, disks)
 
@@ -1124,6 +1172,9 @@ class InstallerStorageConfig(Blivet):
 
         self.fsset.write()
         self.make_mtab()
+        iscsi.write(get_sysroot(), self)
+        fcoe.write(get_sysroot())
+        zfcp.write(get_sysroot())
 
     @property
     def boot_device(self):
-- 
2.4.3

