class EFI(Platform): _boot_stage1_format_types = ["efi"] _boot_stage1_device_types = ["partition", "mdarray"] _boot_stage1_mountpoints = ["/boot/efi"] _boot_stage1_raid_levels = [raid.RAID1] _boot_stage1_raid_metadata = ["1.0"] _boot_efi_description = N_("EFI System Partition") _boot_descriptions = {"partition": _boot_efi_description, "mdarray": Platform._boot_raid_description} # XXX hpfs, if reported by blkid/udev, will end up with a type of None _non_linux_format_types = ["vfat", "ntfs", "hpfs"] _boot_stage1_missing_error = N_("For a UEFI installation, you must include " "an EFI System Partition on a GPT-formatted " "disk, mounted at /boot/efi.") def set_platform_bootloader_reqs(self): ret = Platform.set_platform_bootloader_reqs(self) ret.append(PartSpec(mountpoint="/boot/efi", fstype="efi", size=Size("20MiB"), max_size=Size("200MiB"), grow=True)) return ret
def __init__(self, data, storage, payload): NormalTUISpoke.__init__(self, data, storage, payload) self.title = N_("Network configuration") self._network_module = NETWORK.get_proxy() self.nm_client = network.get_nm_client() if not self.nm_client and conf.system.provides_system_bus: self.nm_client = NM.Client.new(None) self._container = None self.hostname = self._network_module.Hostname self.editable_configurations = [] self.errors = [] self._apply = False
def setup(self, storage, ksdata, payload): """This method calls setup on all the registered addons.""" # filter out placeholders (should be imported now) d = {} for k, v in self.__dict__.items(): if not v.name == PLACEHOLDER_NAME: d[k] = v else: log.warning("Removing placeholder for addon %s. Addon wasn't imported!", k) self.__dict__ = d for v in self.__dict__.values(): if hasattr(v, "setup"): progress_message(N_("Setting up %s addon") % v.name) v.setup(storage, ksdata, payload)
class MacEFI(EFI): _boot_stage1_format_types = ["macefi"] _boot_efi_description = N_("Apple EFI Boot Partition") _non_linux_format_types = ["macefi"] _packages = ["mactel-boot"] def set_platform_bootloader_reqs(self): ret = super().set_platform_bootloader_reqs() ret.append( PartSpec(mountpoint="/boot/efi", fstype="macefi", size=Size("20MiB"), max_size=Size("200MiB"), grow=True)) return ret
def execute(self, storage, ksdata, instClass, users, payload): """This method calls execute on all the registered addons.""" for v in self.__dict__.values(): if hasattr(v, "execute"): progress_message(N_("Executing %s addon") % v.name) if v.execute.__code__.co_argcount == 6: v.execute(storage, ksdata, instClass, users, payload) else: v.execute(storage, ksdata, instClass, users) log.warning( "Addon %s is using deprecated method signature", v.name) log.warning( "Use execute(storage, ksdata, instClass, users, payload) instead" )
def __init__(self, data, storage, payload, instclass, error): NormalTUISpoke.__init__(self, data, storage, payload, instclass) SourceSwitchHandler.__init__(self) self.title = N_("Specify Repo Options") self._container = None self._error = error nfs = self.data.method self._nfs_opts = "" self._nfs_server = "" if nfs.method == "nfs" and (nfs.server and nfs.dir): self._nfs_server = "%s:%s" % (nfs.server, nfs.dir) self._nfs_opts = nfs.opts
def __init__(self, data, storage, payload): super().__init__(data, storage, payload) self.title = N_("Software selection") self._container = None self.errors = [] self._tx_id = None # Get the packages configuration. self._selection = self.payload.get_packages_data() # are we taking values (package list) from a kickstart file? self._kickstarted = flags.automatedInstall and self.payload.proxy.PackagesKickstarted # Register event listeners to update our status on payload events payloadMgr.add_listener(PayloadState.STARTED, self._payload_start) payloadMgr.add_listener(PayloadState.ERROR, self._payload_error)
def __init__(self, data, storage, payload, instclass): super().__init__(data, storage, payload, instclass) self.title = N_("Partition Scheme Options") self._container = None self.part_schemes = OrderedDict() self._auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING) pre_select = self._auto_part_proxy.Type if pre_select == AUTOPART_TYPE_DEFAULT: pre_select = DEFAULT_AUTOPART_TYPE for item in AUTOPART_CHOICES: self.part_schemes[item[0]] = item[1] if item[1] == pre_select: self._selected_scheme_value = item[1]
def __init__(self, *args, **kwargs): StandaloneTUISpoke.__init__(self, *args, **kwargs) self.title = N_("Warnings") self.initialize_start() self._message = _("This hardware (or a combination thereof) is not " "supported by Red Hat. For more information on " "supported hardware, please refer to " "http://www.redhat.com/hardware.") # Does anything need to be displayed? # pylint: disable=no-member self._unsupported = productName.startswith("Red Hat ") and \ is_unsupported_hw() and \ not self.data.unsupportedhardware.unsupported_hardware self.initialize_done()
def __init__(self, data, storage, payload, instclass): NormalTUISpoke.__init__(self, data, storage, payload, instclass) self.initialize_start() self.title = N_("Root password") self.input_required = False self._policy = self.data.anaconda.pwpolicy.get_policy("root", fallback_to_default=True) self._password = None self._users_module = USERS.get_observer() self._users_module.connect() self._services_module = SERVICES.get_observer() self._services_module.connect() self.initialize_done()
def __init__(self, data, storage, payload, storage_module, partitioning): super().__init__(data, storage, payload) self.title = N_("Partitioning Options") self._container = None # Choose the partitioning method. self._storage_module = storage_module self._partitioning = partitioning self._orig_part_method = self._partitioning.PartitioningMethod self._part_method = self._orig_part_method # Choose the initialization mode. self._disk_init_proxy = STORAGE.get_proxy(DISK_INITIALIZATION) self._orig_init_mode = self._disk_init_proxy.InitializationMode self._init_mode = self._get_init_mode() self._init_mode_list = sorted(INIT_MODES.keys())
def __init__(self, data, storage, payload, instclass): super().__init__(data, storage, payload, instclass) self.title = N_("Partitioning Options") self._container = None self.parttypelist = sorted(PARTTYPES.keys()) # remember the original values so that we can detect a change self._orig_clearpart_type = self.data.clearpart.type self._orig_mount_assign = len(self.data.mount.dataList()) != 0 # default to mount point assignment if it is already (partially) # configured self._do_mount_assign = self._orig_mount_assign if not self._do_mount_assign: self.clearPartType = self.data.clearpart.type or CLEARPART_TYPE_ALL else: self.clearPartType = CLEARPART_TYPE_NONE
def __init__(self, data, storage, payload, network_module, iface, connection): super().__init__(data, storage, payload) self.title = N_("Device configuration") self._network_module = network_module self._container = None self._connection = connection self._iface = iface self._connection_uuid = connection.get_uuid() self.errors = [] self.apply_configuration = False self._data = WiredTUIConfigurationData() self._data.set_from_connection(self._connection) log.debug("Configure iface %s: connection %s -> %s", self._iface, self._connection_uuid, self._data)
class SpokeCategory(object): """A SpokeCategory is an object used to group multiple related Spokes together on a hub. It consists of a title displayed above, and then a two-column grid of SpokeSelectors. Each SpokeSelector is associated with a Spoke subclass. A SpokeCategory will only display those Spokes with a matching category attribute. Class attributes: sortOrder -- A number indicating the order in which this Category will be displayed. A lower number indicates display higher up in the Hub. title -- The title of this SpokeCategory, to be displayed above the grid. """ sortOrder = 1000 title = N_("DEFAULT TITLE")
def __init__(self, data, storage, payload, instclass): NormalTUISpoke.__init__(self, data, storage, payload, instclass) self.title = N_("Language settings") self.initialize_start() self._container = None self._langs = [localization.get_english_name(lang) for lang in localization.get_available_translations()] self._langs_and_locales = dict((localization.get_english_name(lang), lang) for lang in localization.get_available_translations()) self._locales = dict((lang, localization.get_language_locales(lang)) for lang in self._langs_and_locales.values()) self._l12_module = LOCALIZATION.get_observer() self._l12_module.connect() self._selected = self._l12_module.proxy.Language self.initialize_done()
def __init__(self, data, storage, payload): super().__init__(data, storage, payload) self.title = N_("Partition Scheme Options") self._container = None self.part_schemes = OrderedDict() self._auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING) pre_select = self._auto_part_proxy.Type supported_choices = get_supported_autopart_choices() if supported_choices: # Fallback value (eg when default is not supported) self._selected_scheme_value = supported_choices[0][1] for item in supported_choices: self.part_schemes[item[0]] = item[1] if item[1] == pre_select: self._selected_scheme_value = item[1]
def __init__(self, data, storage, payload, instclass): super().__init__(data, storage, payload, instclass) self.title = N_("Partitioning Options") self._container = None self.parttypelist = sorted(PARTTYPES.keys()) # remember the original values so that we can detect a change self._disk_init_proxy = STORAGE.get_proxy(DISK_INITIALIZATION) self._orig_clearpart_type = self._disk_init_proxy.InitializationMode self._orig_mount_assign = len(self.data.mount.dataList()) != 0 # default to mount point assignment if it is already (partially) # configured self._do_mount_assign = self._orig_mount_assign if not self._do_mount_assign: self.clearPartType = self._disk_init_proxy.InitializationMode else: self.clearPartType = CLEAR_PARTITIONS_NONE
def __init__(self, data, storage, payload, instclass): super().__init__(data, storage, payload, instclass) self.title = N_("Timezone settings") self._container = None # it's stupid to call get_all_regions_and_timezones twice, but regions # needs to be unsorted in order to display in the same order as the GUI # so whatever self._regions = list(timezone.get_all_regions_and_timezones().keys()) self._timezones = dict((k, sorted(v)) for k, v in timezone.get_all_regions_and_timezones().items()) self._lower_regions = [r.lower() for r in self._regions] self._zones = ["%s/%s" % (region, z) for region in self._timezones for z in self._timezones[region]] # for lowercase lookup self._lower_zones = [z.lower().replace("_", " ") for region in self._timezones for z in self._timezones[region]] self._selection = "" self._timezone_module = TIMEZONE.get_observer() self._timezone_module.connect()
def __init__(self, data, storage, payload): super().__init__(data, storage, payload) self.title = N_("Installation Destination") self._container = None self._ready = False self._select_all = False self._storage_module = STORAGE.get_proxy() self._device_tree = STORAGE.get_proxy(DEVICE_TREE) self._bootloader_module = STORAGE.get_proxy(BOOTLOADER) self._disk_init_module = STORAGE.get_proxy(DISK_INITIALIZATION) self._disk_select_module = STORAGE.get_proxy(DISK_SELECTION) self._available_disks = [] self._selected_disks = [] self._partitioning = find_partitioning() self.errors = [] self.warnings = []
def __init__(self, data, storage, payload, iface, connection): super().__init__(data, storage, payload) self.title = N_("Device configuration") self._container = None self._connection = connection self._iface = iface self._connection_uuid = connection.get_uuid() self.errors = [] self.apply_configuration = False self._data = WiredTUIConfigurationData() self._data.set_from_connection(self._connection) # ONBOOT workaround - changing autoconnect connection value would # activate the device self._data.onboot = self._get_onboot(self._connection_uuid) log.debug("Configure iface %s: connection %s -> %s", self._iface, self._connection_uuid, self._data)
def __init__(self, data, storage, payload): FirstbootSpokeMixIn.__init__(self) NormalTUISpoke.__init__(self, data, storage, payload) self.initialize_start() # connect to the Users DBus module self._users_module = USERS.get_proxy() self.title = N_("User creation") self._container = None # was user creation requested by the Users DBus module # - at the moment this basically means user creation was # requested via kickstart # - note that this does not currently update when user # list is changed via DBus self._user_requested = False self._user_cleared = False # should a user be created ? self._create_user = False self._user_list = get_user_list(self._users_module, add_default=True) # if user has a name, it's an actual user that has been requested, # rather than a default user added by us if self.user.name: self._user_requested = True self._create_user = True self._use_password = self.user.is_crypted or self.user.password self._groups = "" self._is_admin = False self._policy = self.data.anaconda.pwpolicy.get_policy( "user", fallback_to_default=True) self.errors = [] self._users_module = USERS.get_proxy() self.initialize_done()
def install(self): progress_message(N_('Starting package installation process')) # Get the packages configuration and selection data. configuration = self.get_packages_configuration() selection = self.get_packages_selection() # Add the rpm macros to the global transaction environment task = SetRPMMacrosTask(configuration) task.run() try: # Resolve packages. task = ResolvePackagesTask(self._dnf_manager, selection) task.run() except NonCriticalInstallationError as e: # FIXME: This is a temporary workaround. # Allow users to handle the error. If they don't want # to continue with the installation, raise a different # exception to make sure that we will not run the error # handler again. if error_handler.cb(e) == ERROR_RAISE: raise InstallationError(str(e)) from e # Set up the download location. task = PrepareDownloadLocationTask(self._dnf_manager) task.run() # Download the packages. task = DownloadPackagesTask(self._dnf_manager) task.progress_changed_signal.connect(self._progress_cb) task.run() # Install the packages. task = InstallPackagesTask(self._dnf_manager) task.progress_changed_signal.connect(self._progress_cb) task.run() # Clean up the download location. task = CleanUpDownloadLocationTask(self._dnf_manager) task.run()
def __init__(self, data, storage, payload, partitioning): super().__init__(data, storage, payload) self.title = N_("Partition Scheme Options") self._container = None self._part_schemes = OrderedDict() self._partitioning = partitioning self._request = PartitioningRequest.from_structure( self._partitioning.Request) supported_choices = get_supported_autopart_choices() if supported_choices: # Fallback value (eg when default is not supported) self._selected_scheme_value = supported_choices[0][1] selected_choice = self._request.partitioning_scheme for item in supported_choices: self._part_schemes[item[0]] = item[1] if item[1] == selected_choice: self._selected_scheme_value = item[1]
def __init__(self, data, storage, payload, instclass): super().__init__(data, storage, payload, instclass) self.title = N_("Installation Destination") self._ready = False self._container = None self.selected_disks = self.data.ignoredisk.onlyuse[:] self.select_all = False self.autopart = None # This list gets set up once in initialize and should not be modified # except perhaps to add advanced devices. It will remain the full list # of disks that can be included in the install. self.disks = [] self.errors = [] self.warnings = [] if not flags.automatedInstall: # default to using autopart for interactive installs self.data.autopart.autopart = True
def __init__(self, data, storage, payload): super().__init__(data, storage, payload) self.title = N_("Software selection") self._container = None self.errors = [] self._tx_id = None self._selected_environment = None self.environment = None self._addons_selection = set() self.addons = set() # for detecting later whether any changes have been made self._orig_env = None self._orig_addons = set() # are we taking values (package list) from a kickstart file? self._kickstarted = flags.automatedInstall and self.data.packages.seen # Register event listeners to update our status on payload events payloadMgr.add_listener(PayloadState.STARTED, self._payload_start) payloadMgr.add_listener(PayloadState.FINISHED, self._payload_finished) payloadMgr.add_listener(PayloadState.ERROR, self._payload_error)
def __init__(self, data, storage, payload): super().__init__(data, storage, payload) self.title = N_("Partitioning Options") self._container = None self.parttypelist = sorted(PARTTYPES.keys()) # remember the original values so that we can detect a change self._disk_init_proxy = STORAGE.get_proxy(DISK_INITIALIZATION) self._orig_clearpart_type = self._disk_init_proxy.InitializationMode self._manual_part_proxy = STORAGE.get_proxy(MANUAL_PARTITIONING) self._orig_mount_assign = self._manual_part_proxy.Enabled # Create the auto partitioning proxy self._auto_part_proxy = STORAGE.get_proxy(AUTO_PARTITIONING) # default to mount point assignment if it is already (partially) # configured self._do_mount_assign = self._orig_mount_assign if not self._do_mount_assign: self.clearPartType = self._disk_init_proxy.InitializationMode else: self.clearPartType = CLEAR_PARTITIONS_NONE
def __init__(self, data, storage, payload, storage_module, partitioning): super().__init__(data, storage, payload) self.title = N_("Partitioning Options") self._container = None # Choose the initialization mode. self._disk_init_proxy = STORAGE.get_proxy(DISK_INITIALIZATION) self._orig_init_mode = self._disk_init_proxy.InitializationMode self._init_mode = self._orig_init_mode self._init_mode_list = sorted(INIT_MODES.keys()) if self._init_mode == CLEAR_PARTITIONS_DEFAULT: self._init_mode = CLEAR_PARTITIONS_ALL # Choose the partitioning method. self._storage_module = storage_module self._partitioning = partitioning self._orig_part_method = self._partitioning.PartitioningMethod self._part_method = self._orig_part_method if self._part_method == PARTITIONING_METHOD_MANUAL: self._init_mode = CLEAR_PARTITIONS_NONE
def doConfiguration(storage, payload, ksdata): """Configure the installed system.""" configuration_queue = TaskQueue("Configuration queue") # connect progress reporting configuration_queue.queue_started.connect( lambda x: progress_message(x.status_message)) configuration_queue.task_completed.connect(lambda x: progress_step(x.name)) # schedule the execute methods of ksdata that require an installed system to be present os_config = TaskQueue("Installed system configuration", N_("Configuring installed system")) os_config.append(Task("Configure authselect", ksdata.authselect.execute)) os_config.append(Task("Configure SELinux", ksdata.selinux.execute)) os_config.append( Task("Configure first boot tasks", ksdata.firstboot.execute)) os_config.append(Task("Configure services", ksdata.services.execute)) os_config.append(Task("Configure keyboard", ksdata.keyboard.execute)) os_config.append(Task("Configure timezone", ksdata.timezone.execute)) os_config.append(Task("Configure language", ksdata.lang.execute)) os_config.append(Task("Configure firewall", ksdata.firewall.execute)) os_config.append(Task("Configure X", ksdata.xconfig.execute)) configuration_queue.append(os_config) # schedule network configuration (if required) if conf.system.provides_network_config: network_config = TaskQueue("Network configuration", N_("Writing network configuration")) network_config.append( Task("Network configuration", ksdata.network.execute, (payload, ))) configuration_queue.append(network_config) # creating users and groups requires some pre-configuration. u = Users() user_config = TaskQueue("User creation", N_("Creating users")) user_config.append( Task("Configure root", ksdata.rootpw.execute, (storage, ksdata, u))) user_config.append( Task("Configure user groups", ksdata.group.execute, (storage, ksdata, u))) user_config.append( Task("Configure user", ksdata.user.execute, (storage, ksdata, u))) user_config.append( Task("Configure SSH key", ksdata.sshkey.execute, (storage, ksdata, u))) configuration_queue.append(user_config) # Anaconda addon configuration addon_config = TaskQueue("Anaconda addon configuration", N_("Configuring addons")) addon_config.append( Task("Configure Anaconda addons", ksdata.addons.execute, (storage, ksdata, u, payload))) configuration_queue.append(addon_config) # Initramfs generation generate_initramfs = TaskQueue("Initramfs generation", N_("Generating initramfs")) generate_initramfs.append( Task("Generate initramfs", payload.recreate_initrds)) # This works around 2 problems, /boot on BTRFS and BTRFS installations where the initrd is # recreated after the first writeBootLoader call. This reruns it after the new initrd has # been created, fixing the kernel root and subvol args and adding the missing initrd entry. boot_on_btrfs = isinstance(storage.mountpoints.get("/"), BTRFSDevice) bootloader_proxy = STORAGE.get_proxy(BOOTLOADER) bootloader_enabled = bootloader_proxy.BootloaderMode != BOOTLOADER_DISABLED if isinstance(payload, LiveImagePayload) and boot_on_btrfs and bootloader_enabled: generate_initramfs.append( Task("Write BTRFS bootloader fix", write_boot_loader, (storage, payload))) # Invoking zipl should be the last thing done on a s390x installation (see #1652727). if arch.is_s390() and not conf.target.is_directory and bootloader_enabled: generate_initramfs.append( Task("Rerun zipl", lambda: util.execInSysroot("zipl", []))) configuration_queue.append(generate_initramfs) # join a realm (if required) if ksdata.realm.discovered: join_realm = TaskQueue( "Realm join", N_("Joining realm: %s") % ksdata.realm.discovered) join_realm.append(Task("Join a realm", ksdata.realm.execute)) configuration_queue.append(join_realm) post_scripts = TaskQueue("Post installation scripts", N_("Running post-installation scripts")) post_scripts.append( Task("Run post installation scripts", runPostScripts, (ksdata.scripts, ))) configuration_queue.append(post_scripts) # setup kexec reboot if requested if flags.flags.kexec: kexec_setup = TaskQueue("Kexec setup", N_("Setting up kexec")) kexec_setup.append(Task("Setup kexec", setup_kexec)) configuration_queue.append(kexec_setup) # write anaconda related configs & kickstarts write_configs = TaskQueue("Write configs and kickstarts", N_("Storing configuration files and kickstarts")) # Write the kickstart file to the installed system (or, copy the input # kickstart file over if one exists). if flags.flags.nosave_output_ks: # don't write the kickstart file to the installed system if this has # been disabled by the nosave option log.warning( "Writing of the output kickstart to installed system has been disabled" " by the nosave option.") else: # write anaconda related configs & kickstarts write_configs.append(Task("Store kickstarts", _writeKS, (ksdata, ))) # Write out the user interaction config file. # # But make sure it's not written out in the image and directory installation mode, # as that might result in spokes being inadvertently hidden when the actual installation # starts from the generate image or directory contents. if conf.target.is_image: log.info( "Not writing out user interaction config file due to image install mode." ) elif conf.target.is_directory: log.info( "Not writing out user interaction config file due to directory install mode." ) else: write_configs.append( Task("Store user interaction config", screen_access.sam.write_out_config_file)) # only add write_configs to the main queue if we actually store some kickstarts/configs if write_configs.task_count: configuration_queue.append(write_configs) # notify progress tracking about the number of steps progress_init(configuration_queue.task_count) # log contents of the main task queue log.info(configuration_queue.summary) # log tasks and queues when they are started # - note that we are using generators to add the counter queue_counter = util.item_counter(configuration_queue.queue_count) task_started_counter = util.item_counter(configuration_queue.task_count) task_completed_counter = util.item_counter(configuration_queue.task_count) configuration_queue.queue_started.connect(lambda x: log.info( "Queue started: %s (%s)", x.name, next(queue_counter))) configuration_queue.task_started.connect(lambda x: log.info( "Task started: %s (%s)", x.name, next(task_started_counter))) configuration_queue.task_completed.connect( lambda x: log.debug("Task completed: %s (%s) (%1.1f s)", x.name, next(task_completed_counter), x.elapsed_time)) # start the task queue configuration_queue.start() # done progress_complete()
def doInstall(storage, payload, ksdata): """Perform an installation. This method takes the ksdata as prepared by the UI (the first hub, in graphical mode) and applies it to the disk. The two main tasks for this are putting filesystems onto disks and installing packages onto those filesystems. """ bootloader_proxy = STORAGE.get_proxy(BOOTLOADER) bootloader_enabled = bootloader_proxy.BootloaderMode != BOOTLOADER_DISABLED can_install_bootloader = not conf.target.is_directory and bootloader_enabled installation_queue = TaskQueue("Installation queue") # connect progress reporting installation_queue.queue_started.connect( lambda x: progress_message(x.status_message)) installation_queue.task_completed.connect(lambda x: progress_step(x.name)) # This should be the only thread running, wait for the others to finish if not. if threadMgr.running > 1: # it could be that the threads finish execution before the task is executed, # but that should not cause any issues def wait_for_all_treads(): for message in ("Thread %s is running" % n for n in threadMgr.names): log.debug(message) threadMgr.wait_all() # Use a queue with a single task as only TaskQueues have the status_message # property used for setting the progress status in the UI. wait_for_threads = TaskQueue( "Wait for threads to finish", N_("Waiting for %s threads to finish") % (threadMgr.running - 1)) wait_for_threads.append( Task("Wait for all threads to finish", wait_for_all_treads)) installation_queue.append(wait_for_threads) # Save system time to HW clock. # - this used to be before waiting on threads, but I don't think that's needed if conf.system.can_set_hardware_clock: # lets just do this as a top-level task - no save_hwclock = Task("Save system time to HW clock", timezone.save_hw_clock) installation_queue.append(save_hwclock) # setup the installation environment setup_environment = TaskQueue( "Installation environment setup", N_("Setting up the installation environment")) setup_environment.append( Task("Setup addons", ksdata.addons.setup, (storage, ksdata, payload))) installation_queue.append(setup_environment) # Do partitioning. # Depending on current payload the storage might be apparently configured # either before or after package/payload installation. # So let's have two task queues - early storage & late storage. early_storage = TaskQueue("Early storage configuration", N_("Configuring storage")) # put custom storage info into ksdata early_storage.append( Task("Insert custom storage to ksdata", task=update_storage_ksdata, task_args=(storage, ksdata))) # callbacks for blivet message_clbk = lambda clbk_data: progress_message(clbk_data.msg) entropy_wait_clbk = lambda clbk_data: wait_for_entropy( clbk_data.msg, clbk_data.min_entropy, ksdata) callbacks_reg = callbacks.create_new_callbacks_register( create_format_pre=message_clbk, resize_format_pre=message_clbk, wait_for_entropy=entropy_wait_clbk) if not conf.target.is_directory: early_storage.append( Task("Activate filesystems", task=turn_on_filesystems, task_args=(storage, ), task_kwargs={"callbacks": callbacks_reg})) early_storage.append( Task("Mount filesystems", task=storage.mount_filesystems)) if payload.needs_storage_configuration and not conf.target.is_directory: early_storage.append( Task("Write early storage", task=write_storage_configuration, task_args=(storage, ))) installation_queue.append(early_storage) # Run %pre-install scripts with the filesystem mounted and no packages pre_install_scripts = TaskQueue("Pre-install scripts", N_("Running pre-installation scripts")) pre_install_scripts.append( Task("Run %pre-install scripts", runPreInstallScripts, (ksdata.scripts, ))) installation_queue.append(pre_install_scripts) # Do packaging. # Discover information about realms to join to determine the need for additional packages. realm_discover = TaskQueue("Realm discover", N_("Discovering realm to join")) realm_discover.append(Task("Discover realm to join", ksdata.realm.setup)) installation_queue.append(realm_discover) # Check for other possibly needed additional packages. pre_install = TaskQueue("Pre install tasks", N_("Running pre-installation tasks")) pre_install.append(Task("Setup authselect", ksdata.authselect.setup)) pre_install.append(Task("Setup firewall", ksdata.firewall.setup)) pre_install.append(Task("Setup network", ksdata.network.setup)) # Setup timezone and add chrony as package if timezone was set in KS # and "-chrony" wasn't in packages section and/or --nontp wasn't set. pre_install.append( Task("Setup timezone", ksdata.timezone.setup, (ksdata, ))) # make name resolution work for rpm scripts in chroot if conf.system.provides_resolver_config: # we use a custom Task subclass as the sysroot path has to be resolved # only when the task is actually started, not at task creation time pre_install.append(WriteResolvConfTask("Copy resolv.conf to sysroot")) def run_pre_install(): """This means to gather what additional packages (if any) are needed & executing payload.pre_install().""" # anaconda requires storage packages in order to make sure the target # system is bootable and configurable, and some other packages in order # to finish setting up the system. payload.requirements.add_packages(storage.packages, reason="storage") payload.requirements.add_packages(ksdata.realm.packages, reason="realm") payload.requirements.add_packages(ksdata.authselect.packages, reason="authselect") payload.requirements.add_packages(ksdata.firewall.packages, reason="firewall") payload.requirements.add_packages(ksdata.network.packages, reason="network") payload.requirements.add_packages(ksdata.timezone.packages, reason="ntp", strong=False) if can_install_bootloader: payload.requirements.add_packages(storage.bootloader.packages, reason="bootloader") payload.requirements.add_groups(payload.language_groups(), reason="language groups") payload.requirements.add_packages(payload.langpacks(), reason="langpacks", strong=False) payload.pre_install() pre_install.append( Task("Find additional packages & run pre_install()", run_pre_install)) installation_queue.append(pre_install) payload_install = TaskQueue("Payload installation", N_("Installing.")) payload_install.append(Task("Install the payload", payload.install)) installation_queue.append(payload_install) # for some payloads storage is configured after the payload is installed if not payload.needs_storage_configuration: late_storage = TaskQueue("Late storage configuration", N_("Configuring storage")) late_storage.append( Task("Prepare mount targets", task=payload.prepare_mount_targets, task_args=(storage, ))) if not conf.target.is_directory: late_storage.append( Task("Write late storage", task=write_storage_configuration, task_args=(storage, ))) installation_queue.append(late_storage) # Do bootloader. if can_install_bootloader: bootloader_install = TaskQueue("Bootloader installation", N_("Installing boot loader")) bootloader_install.append( Task("Install bootloader", write_boot_loader, (storage, payload))) installation_queue.append(bootloader_install) post_install = TaskQueue("Post-installation setup tasks", (N_("Performing post-installation setup tasks"))) post_install.append( Task("Run post-installation setup tasks", payload.post_install)) installation_queue.append(post_install) # Create snapshot snapshot_proxy = STORAGE.get_proxy(SNAPSHOT) if snapshot_proxy.IsRequested(SNAPSHOT_WHEN_POST_INSTALL): snapshot_creation = TaskQueue("Creating post installation snapshots", N_("Creating snapshots")) snapshot_requests = ksdata.snapshot.get_requests( SNAPSHOT_WHEN_POST_INSTALL) snapshot_task = SnapshotCreateTask(storage, snapshot_requests, SNAPSHOT_WHEN_POST_INSTALL) snapshot_creation.append( Task("Create post-install snapshots", snapshot_task.run)) installation_queue.append(snapshot_creation) # notify progress tracking about the number of steps progress_init(installation_queue.task_count) # log contents of the main task queue log.info(installation_queue.summary) # log tasks and queues when they are started # - note that we are using generators to add the counter queue_counter = util.item_counter(installation_queue.queue_count) task_started_counter = util.item_counter(installation_queue.task_count) task_completed_counter = util.item_counter(installation_queue.task_count) installation_queue.queue_started.connect(lambda x: log.info( "Queue started: %s (%s)", x.name, next(queue_counter))) installation_queue.task_started.connect(lambda x: log.info( "Task started: %s (%s)", x.name, next(task_started_counter))) installation_queue.task_completed.connect( lambda x: log.debug("Task completed: %s (%s) (%1.1f s)", x.name, next(task_completed_counter), x.elapsed_time)) # start the task queue installation_queue.start() # done progress_complete()
class Platform(object): """Platform A class containing platform-specific information and methods for use during installation. The intent is to eventually encapsulate all the architecture quirks in one place to avoid lots of platform checks throughout anaconda.""" _packages = [] # requirements for bootloader stage1 devices _boot_stage1_device_types = [] _boot_stage1_format_types = [] _boot_stage1_mountpoints = [] _boot_stage1_max_end = None _boot_stage1_raid_levels = [] _boot_stage1_raid_metadata = [] _boot_stage1_raid_member_types = [] _boot_stage1_description = N_("boot loader device") _boot_stage1_missing_error = "" _boot_raid_description = N_("RAID Device") _boot_partition_description = N_("First sector of boot partition") _boot_descriptions = {} _non_linux_format_types = [] def __init__(self): """Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.""" self.update_from_flags() def update_from_flags(self): if conf.storage.gpt: disklabel_class = get_device_format_class("disklabel") disklabel_types = disklabel_class.get_platform_label_types() if "gpt" not in disklabel_types: log.warning( "GPT is not a supported disklabel on this platform. Using default " "disklabel %s instead.", disklabel_types[0]) else: disklabel_class.set_default_label_type("gpt") def __call__(self): return self @property def boot_stage1_constraint_dict(self): d = { "device_types": self._boot_stage1_device_types, "format_types": self._boot_stage1_format_types, "mountpoints": self._boot_stage1_mountpoints, "max_end": self._boot_stage1_max_end, "raid_levels": self._boot_stage1_raid_levels, "raid_metadata": self._boot_stage1_raid_metadata, "raid_member_types": self._boot_stage1_raid_member_types, "descriptions": dict((k, _(v)) for k, v in self._boot_descriptions.items()) } return d @property def packages(self): _packages = self._packages return _packages def set_platform_bootloader_reqs(self): """Return the required platform-specific bootloader partition information. These are typically partitions that do not get mounted, like biosboot or prepboot, but may also include the /boot/efi partition.""" return [] def set_platform_boot_partition(self): """Return the default /boot partition for this platform.""" return [PartSpec(mountpoint="/boot", size=Size("1GiB"))] def set_default_partitioning(self): """Return the default platform-specific partitioning information.""" return self.set_platform_bootloader_reqs( ) + self.set_platform_boot_partition() @property def stage1_missing_error(self): """A platform-specific error message to be shown if stage1 target selection fails.""" return self._boot_stage1_missing_error