def _get_initialization_config(self): """Get the initialization config. FIXME: This is a temporary method. """ config = DiskInitializationConfig() # Update the config. disk_init_proxy = STORAGE.get_proxy(DISK_INITIALIZATION) config.initialization_mode = disk_init_proxy.InitializationMode config.drives_to_clear = disk_init_proxy.DrivesToClear config.devices_to_clear = disk_init_proxy.DevicesToClear config.initialize_labels = disk_init_proxy.InitializeLabelsEnabled config.format_unrecognized = disk_init_proxy.FormatUnrecognizedEnabled config.clear_non_existent = False # Update the disk label. disk_label = disk_init_proxy.DefaultDiskLabel if disk_label and not DiskLabel.set_default_label_type(disk_label): log.warning("%s is not a supported disklabel type on this platform. " "Using default disklabel %s instead.", disk_label, DiskLabel.get_platform_label_types()[0]) return config
def _get_initialization_config(self): """Get the initialization config. FIXME: This is a temporary method. """ config = DiskInitializationConfig() # Update the config. disk_init_proxy = STORAGE.get_proxy(DISK_INITIALIZATION) config.initialization_mode = disk_init_proxy.InitializationMode config.drives_to_clear = disk_init_proxy.DrivesToClear config.devices_to_clear = disk_init_proxy.DevicesToClear config.initialize_labels = disk_init_proxy.InitializeLabelsEnabled config.format_unrecognized = disk_init_proxy.FormatUnrecognizedEnabled config.clear_non_existent = False # Update the disk label. disk_label = disk_init_proxy.DefaultDiskLabel if disk_label and not DiskLabel.set_default_label_type(disk_label): log.warning( "%s is not a supported disklabel type on this platform. " "Using default disklabel %s instead.", disk_label, DiskLabel.get_platform_label_types()[0]) return config
def _clear_partitions(self, storage): """Clear partitions. :param storage: an instance of Blivet """ disk_init_proxy = STORAGE.get_proxy(DISK_INITIALIZATION) storage.config.clear_part_type = disk_init_proxy.InitializationMode storage.config.clear_part_disks = disk_init_proxy.DrivesToClear storage.config.clear_part_devices = disk_init_proxy.DevicesToClear storage.config.initialize_disks = disk_init_proxy.InitializeLabelsEnabled disk_label = disk_init_proxy.DefaultDiskLabel if disk_label and not DiskLabel.set_default_label_type(disk_label): log.warning( "%s is not a supported disklabel type on this platform. " "Using default disklabel %s instead.", disk_label, DiskLabel.get_platform_label_types()[0]) storage.clear_partitions() # Check the usable disks. if not any(d for d in storage.disks if not d.format.hidden and not d.protected): raise NoDisksError("No usable disks.")
def parse(self, args): """Parse the command. Do any glob expansion now, since we need to have the real list of disks available before the execute methods run. """ retval = super().parse(args) # Set the default type. if self.type is None: self.type = CLEARPART_TYPE_NONE # Check the disk label. if self.disklabel and self.disklabel not in DiskLabel.get_platform_label_types(): raise KickstartParseError(_("Disklabel \"{}\" given in clearpart command is not " "supported on this platform.").format(self.disklabel), lineno=self.lineno) # Get the disks names to clear. self.drives = get_device_names(self.drives, disks_only=True, lineno=self.lineno, msg=_("Disk \"{}\" given in clearpart command does " "not exist.")) # Get the devices names to clear. self.devices = get_device_names(self.devices, disks_only=False, lineno=self.lineno, msg=_("Device \"{}\" given in clearpart device list " "does not exist.")) return retval
def _skip_unsupported_disk_labels(self, disks): """Get a list of disks with supported disk labels. Skip initialized disks with disk labels that are not supported on this platform. :param disks: a list of disks :return: a list of disks with supported disk labels """ label_types = set(DiskLabel.get_platform_label_types()) def is_supported(disk): if disk.format.type is None: return True return disk.format.type == "disklabel" \ and disk.format.label_type in label_types return list(filter(is_supported, disks))
def __init__(self, parent_window): """ :param parent_window: parent window :type parent_window: Gtk.Window """ builder = Gtk.Builder() builder.set_translation_domain("blivet-gui") builder.add_from_file(locate_ui_file('add_disklabel_dialog.ui')) self.dialog = builder.get_object("dialog") self.pttype_combo = builder.get_object("pttype_combo") self.dialog.set_transient_for(parent_window) for disklabel in DiskLabel.get_platform_label_types(): self.pttype_combo.append_text(disklabel) self.pttype_combo.set_active(0) self.dialog.show_all()
def disklabel_types(self): return DiskLabel.get_platform_label_types()