Skip to content

Commit

Permalink
Don't use the local storage object during the start of anaconda
Browse files Browse the repository at this point in the history
Don't initialize and set up the local storage object during the start
of anaconda. Use the Storage module instead.
  • Loading branch information
poncovka committed Feb 16, 2020
1 parent bbe0675 commit ee2cfcf
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions anaconda.py
Expand Up @@ -31,7 +31,7 @@
import pid


def exitHandler(rebootData, storage):
def exitHandler(rebootData):
# Clear the list of watched PIDs.
from pyanaconda.core.process_watchers import WatchProcesses
WatchProcesses.unwatch_all_processes()
Expand All @@ -55,13 +55,12 @@ def exitHandler(rebootData, storage):
if anaconda.payload:
anaconda.payload.unsetup()

# Unmount the filesystems.
if not conf.target.is_hardware:
anaconda.storage.umount_filesystems(swapoff=False)
from pyanaconda.modules.common.task import sync_run_task
storage_proxy = STORAGE.get_proxy()

# Tear down disk images.
if conf.target.is_image:
anaconda.storage.devicetree.teardown_disk_images()
for task_path in storage_proxy.TeardownWithTasks():
task_proxy = STORAGE.get_proxy(task_path)
sync_run_task(task_proxy)

# Clean up the PID file
if pidfile:
Expand All @@ -73,9 +72,16 @@ def exitHandler(rebootData, storage):
from pykickstart.constants import KS_SHUTDOWN, KS_WAIT

if flags.eject or rebootData.eject:
for cdrom in (d for d in storage.devices if d.type == "cdrom"):
if util.get_mount_paths(cdrom.path):
util.dracut_eject(cdrom.path)
from pyanaconda.modules.common.constants.objects import DEVICE_TREE
from pyanaconda.modules.common.structures.storage import DeviceData
device_tree_proxy = STORAGE.get_proxy(DEVICE_TREE)

for device_name in device_tree_proxy.FindOpticalMedia:
device_data = DeviceData.from_structure(
device_tree_proxy.GetDeviceData(device_name)
)
if util.get_mount_paths(device_data.path):
util.dracut_eject(device_data.path)

if flags.kexec:
util.execWithRedirect("systemctl", ["--no-wall", "kexec"])
Expand Down Expand Up @@ -553,9 +559,6 @@ def _earlyExceptionHandler(ty, value, traceback):
# Now that LANG is set, do something with it
localization.setup_locale(os.environ["LANG"], localization_proxy, text_mode=anaconda.tui_mode)

from pyanaconda.storage.initialization import enable_installer_mode, reset_storage
enable_installer_mode()

# Initialize the network now, in case the display needs it
from pyanaconda.network import initialize_network, wait_for_connecting_NM_thread, wait_for_connected_NM

Expand Down Expand Up @@ -651,18 +654,17 @@ def _earlyExceptionHandler(ty, value, traceback):
from pyanaconda.timezone import time_initialize

if not conf.target.is_directory:
from pyanaconda.storage.initialization import reset_storage
threadMgr.add(AnacondaThread(name=constants.THREAD_STORAGE,
target=reset_storage,
args=(anaconda.storage, )))
target=reset_storage))

from pyanaconda.modules.common.constants.services import TIMEZONE
timezone_proxy = TIMEZONE.get_proxy()

if conf.system.can_initialize_system_clock:
threadMgr.add(AnacondaThread(name=constants.THREAD_TIME_INIT,
target=time_initialize,
args=(timezone_proxy,
anaconda.storage)))
args=(timezone_proxy, )))

if flags.rescue_mode:
rescue.start_rescue_mode_ui(anaconda)
Expand All @@ -673,7 +675,7 @@ def _earlyExceptionHandler(ty, value, traceback):
signal.signal(signal.SIGUSR1, lambda signum, frame:
exception.test_exception_handling())
signal.signal(signal.SIGUSR2, lambda signum, frame: anaconda.dumpState())
atexit.register(exitHandler, ksdata.reboot, anaconda.storage)
atexit.register(exitHandler, ksdata.reboot)

from pyanaconda import exception
anaconda.mehConfig = exception.initExceptionHandling(anaconda)
Expand Down Expand Up @@ -731,7 +733,7 @@ def _earlyExceptionHandler(ty, value, traceback):
# Run the tasks.
with check_kickstart_error():
from pyanaconda.modules.storage.snapshot.create import SnapshotCreateTask
SnapshotCreateTask(anaconda.storage, requests, SNAPSHOT_WHEN_PRE_INSTALL).run()
SnapshotCreateTask(None, requests, SNAPSHOT_WHEN_PRE_INSTALL).run()

anaconda.intf.setup(ksdata)
anaconda.intf.run()
Expand Down

0 comments on commit ee2cfcf

Please sign in to comment.