def reset(self, dummy=None): '''Reset ui_obj to value found from Target Discovery. Meaningful only for editable DiskWindows ''' if not self.editable: return doc = InstallEngine.get_instance().doc # "reset" the desired target reset_obj = None if isinstance(self.ui_obj, UIDisk): reset_obj = (self.tc.reset_layout(disk=self.ui_obj.doc_obj))[0] else: # reset the partition by removing the modified Partition, and # resetting it with the partition found during target discovery. discovered_obj = self.ui_obj.discovered_doc_obj desired_disk = get_desired_target_disk(doc) desired_part = get_solaris_partition(doc) desired_disk.delete_partition(desired_part) part_copy = deepcopy(discovered_obj) desired_disk.insert_children(part_copy) # get the updated reference reset_obj = get_solaris_partition(doc) dump_doc("After doing reset") self.set_disk_info(disk_info=reset_obj) self.activate_solaris_data()
def get_disk_summary(self): '''Return a string summary of the disk selection''' doc = InstallEngine.get_instance().doc disk = get_desired_target_disk(doc) disk_string = list() disk_size_str = locale.format("%.1f", disk.disk_prop.dev_size.get(Size.gb_units)) + LOCALIZED_GB locale_disk_str = _("Disk: ") + disk_size_str + " " + \ str(disk.disk_prop.dev_type) disk_string.append(locale_disk_str) if not disk.whole_disk: if disk.label != "VTOC": part_data = get_solaris_gpt_partition(doc) if part_data is not None: type_str = str(part_data.part_type) else: part_data = get_solaris_partition(doc) if part_data is not None: type_str = str(libdiskmgt_const.PARTITION_ID_MAP[ part_data.part_type]) if part_data is not None: part_size_str = locale.format("%.1f", part_data.size.get(Size.gb_units)) + LOCALIZED_GB locale_part_str = _("Partition: ") + part_size_str + " " +\ type_str disk_string.append(locale_part_str) if part_data is None or not part_data.in_zpool: slice_data = get_solaris_slice(doc) slice_num_str = _("Slice %s: ") % slice_data.name slice_size_str = locale.format("%.1f", slice_data.size.get(Size.gb_units)) + LOCALIZED_GB locale_slice_str = slice_num_str + slice_size_str + " " +\ str(slice_data.in_zpool) disk_string.append(locale_slice_str) return "\n".join(disk_string)
def validate(self): ''' Perform final validation of the desired target ''' if self.is_x86 and not self.x86_slice_mode: # delay final validation for x86 until slice mode # is completed. return # perform final target validation doc = InstallEngine.get_instance().doc if self.is_x86: solaris_part = get_solaris_partition(doc) if solaris_part is None: raise RuntimeError("No Solaris2 partition in desired target") solaris_part.bootid = Partition.ACTIVE perform_final_validation(doc)
def get_disk_summary(self): '''Return a string summary of the disk selection''' doc = InstallEngine.get_instance().doc disk = get_desired_target_disk(doc) disk_string = list() disk_size_str = locale.format("%.1f", disk.disk_prop.dev_size.get(Size.gb_units)) + LOCALIZED_GB locale_disk_str = _("Disk: ") + disk_size_str + " " + \ str(disk.disk_prop.dev_type) disk_string.append(locale_disk_str) if not disk.whole_disk: part_data = get_solaris_partition(doc) if part_data is not None: part_size_str = locale.format("%.1f", part_data.size.get(Size.gb_units)) + LOCALIZED_GB locale_part_str = _("Partition: ") + part_size_str + " " +\ str(libdiskmgt_const.PARTITION_ID_MAP[part_data.part_type]) disk_string.append(locale_part_str) if part_data is None or not part_data.in_zpool: slice_data = get_solaris_slice(doc) slice_num_str = _("Slice %s: ") % slice_data.name slice_size_str = locale.format("%.1f", slice_data.size.get(Size.gb_units)) + LOCALIZED_GB locale_slice_str = slice_num_str + slice_size_str + " " +\ str(slice_data.in_zpool) disk_string.append(locale_slice_str) return "\n".join(disk_string)
def _show(self): '''Display partition data for selected disk, and present the two choices ''' doc = InstallEngine.get_instance().doc disk = get_desired_target_disk(doc) if disk.label == "GPT": # this disk has GPT partitions, so skip this screen raise SkipException if self.x86_slice_mode: if disk.whole_disk: raise SkipException sol_partition = get_solaris_partition(doc) if sol_partition is None: # Must have a Solaris partition err_msg = "Critical error - no Solaris partition found" LOGGER.error(err_msg) raise ValueError(err_msg) LOGGER.debug("Working with the following partition:") LOGGER.debug(str(sol_partition)) # See if there are any slices in the partition all_slices = sol_partition.get_children(class_type=Slice) if not all_slices: LOGGER.info("No previous slices found") # Setting the in_zpool flag to indicate the whole # partition should be used. The needed underlying # slices will be created in the next step when # the in_zpool flag is detected. sol_partition.in_zpool = DEFAULT_ZPOOL_NAME raise SkipException LOGGER.debug("Preserved partition with existing slices, " "presenting option to install into a slice") self.disk = sol_partition else: self.disk = get_desired_target_disk(doc) LOGGER.debug("Working with the following disk:") LOGGER.debug(str(self.disk)) if self.disk.whole_disk: LOGGER.debug("disk.whole_disk=True, skip editing") raise SkipException if self.disk.is_boot_disk(): bootable = FDiskPart.BOOT_TEXT else: bootable = u"" disk_size_gb_str = locale.format("%.1f", self.disk.disk_prop.dev_size.get(Size.gb_units)) + LOCALIZED_GB type_bootable_str = FDiskPart.HEADER_TYPE_BOOTABLE % \ {"type": self.disk.disk_prop.dev_type, "bootable": bootable} header_text = self.header_text + disk_size_gb_str + \ type_bootable_str self.main_win.set_header_text(header_text) y_loc = 1 y_loc += self.center_win.add_paragraph(self.paragraph, start_y=y_loc) y_loc += 1 if self.is_x86 and not self.x86_slice_mode: all_parts = self.disk.get_children(class_type=Partition) else: all_parts = self.disk.get_children(class_type=Slice) found_parts = bool(all_parts) if found_parts: next_line = self.found else: next_line = self.proposed y_loc += self.center_win.add_paragraph(next_line, start_y=y_loc) y_loc += 1 disk_win_area = WindowArea(6, 70, y_loc, 0) self.disk_win = DiskWindow(disk_win_area, self.disk, target_controller=self.tc, window=self.center_win) y_loc += disk_win_area.lines y_loc += 3 whole_disk_width = textwidth(self.use_whole) + 3 cols = (self.win_size_x - whole_disk_width) / 2 whole_disk_item_area = WindowArea(1, whole_disk_width, y_loc, cols) self.whole_disk_item = ListItem(whole_disk_item_area, window=self.center_win, text=self.use_whole, centered=True) y_loc += 1 partial_width = textwidth(self.use_part) + 3 cols = (self.win_size_x - partial_width) / 2 partial_item_area = WindowArea(1, partial_width, y_loc, cols) self.partial_disk_item = ListItem(partial_item_area, window=self.center_win, text=self.use_part, centered=True) self.main_win.do_update() if self.use_whole_segment: self.center_win.activate_object(self.whole_disk_item) else: self.center_win.activate_object(self.partial_disk_item)
def _show(self): '''Display partition data for selected disk, and present the two choices ''' doc = InstallEngine.get_instance().doc if self.x86_slice_mode: disk = get_desired_target_disk(doc) if disk.whole_disk: raise SkipException sol_partition = get_solaris_partition(doc) LOGGER.debug("Working with the following partition:") LOGGER.debug(str(sol_partition)) if sol_partition is None: # Must have a Solaris partition err_msg = "Critical error - no Solaris partition found" LOGGER.error(err_msg) raise ValueError(err_msg) # See if there are any slices in the partition all_slices = sol_partition.get_children(class_type=Slice) if not all_slices: LOGGER.info("No previous slices found") # Setting the in_zpool flag to indicate the whole # partition should be used. The needed underlying # slices will be created in the next step when # the in_zpool flag is detected. sol_partition.in_zpool = ROOT_POOL raise SkipException LOGGER.debug("Preserved partition with existing slices, " "presenting option to install into a slice") self.disk = sol_partition else: self.disk = get_desired_target_disk(doc) LOGGER.debug("Working with the following disk:") LOGGER.debug(str(self.disk)) if self.disk.whole_disk: LOGGER.debug("disk.whole_disk=True, skip editting") raise SkipException if self.disk.is_boot_disk(): bootable = FDiskPart.BOOT_TEXT else: bootable = u"" disk_size_gb_str = locale.format("%.1f", self.disk.disk_prop.dev_size.get(Size.gb_units)) + LOCALIZED_GB type_bootable_str = FDiskPart.HEADER_TYPE_BOOTABLE % \ {"type": self.disk.disk_prop.dev_type, "bootable": bootable} header_text = self.header_text + disk_size_gb_str + \ type_bootable_str self.main_win.set_header_text(header_text) y_loc = 1 y_loc += self.center_win.add_paragraph(self.paragraph, start_y=y_loc) y_loc += 1 if self.is_x86 and not self.x86_slice_mode: all_parts = self.disk.get_children(class_type=Partition) else: all_parts = self.disk.get_children(class_type=Slice) found_parts = bool(all_parts) if found_parts: next_line = self.found else: next_line = self.proposed y_loc += self.center_win.add_paragraph(next_line, start_y=y_loc) y_loc += 1 disk_win_area = WindowArea(6, 70, y_loc, 0) self.disk_win = DiskWindow(disk_win_area, self.disk, target_controller=self.tc, window=self.center_win) y_loc += disk_win_area.lines y_loc += 3 whole_disk_width = textwidth(self.use_whole) + 3 cols = (self.win_size_x - whole_disk_width) / 2 whole_disk_item_area = WindowArea(1, whole_disk_width, y_loc, cols) self.whole_disk_item = ListItem(whole_disk_item_area, window=self.center_win, text=self.use_whole, centered=True) y_loc += 1 partial_width = textwidth(self.use_part) + 3 cols = (self.win_size_x - partial_width) / 2 partial_item_area = WindowArea(1, partial_width, y_loc, cols) self.partial_disk_item = ListItem(partial_item_area, window=self.center_win, text=self.use_part, centered=True) self.main_win.do_update() if self.use_whole_segment: self.center_win.activate_object(self.whole_disk_item) else: self.center_win.activate_object(self.partial_disk_item)
def validate(self): ''' Perform final validation of the desired target ''' if self.is_x86: # check for multiple Solaris2 partitions desired_disk = get_desired_target_disk(self.doc) solaris_list = [ p for p in desired_disk.get_children(class_type=Partition) if p.is_solaris ] if len(solaris_list) > 1: raise UIMessage(PartEditScreen.MULTIPLE_SOLARIS2_ERROR) solaris_part = get_solaris_partition(self.doc) if solaris_part is None: raise UIMessage(PartEditScreen.X86_SELECTION_ERROR) # verify the size of the Solaris2 partition is large enough min_size = self.tc.minimum_target_size if min_size > solaris_part.size: raise UIMessage(PartEditScreen.PART_TOO_SMALL % {"size": min_size.get(Size.gb_units)}) disk = solaris_part.parent # unset in_zpool and in_vdev on the partiton and the parent Disk. # This is a workaround to CR 7085718 solaris_part.in_zpool = None solaris_part.in_vdev = None disk.in_zpool = None disk.in_vdev = None # create system partitions if required try: efi_sys, resv, solaris_part = \ disk.add_required_partitions(solaris_part) LOGGER.debug("EFI System Partition: %s", str(efi_sys)) # resv is always None as it is GPT specific so don't log it except NoPartitionSlotsFree: # If there are no unused partitions left we can't proceed LOGGER.warning("No free slots available for EFI system " "partition.") raise UIMessage("Too many partitions. Delete unnecessary " "partitions.") except InsufficientSpaceError as ise: raise RuntimeError("INTERNAL ERROR: Could not allocate space " "for EFI system partition on disk %s: %s" % (disk, str(ise))) if not self.x86_slice_mode: # delay final validation for x86 until slice mode is # completed. return # final target validation will be performed now solaris_part.bootid = Partition.ACTIVE else: inner_window = self.disk_win.get_active_object() edit_object = inner_window.get_active_object() ui_object = edit_object.get_active_object() if ui_object is None: raise UIMessage(PartEditScreen.SPARC_SELECTION_ERROR) perform_final_validation(self.doc)
def _show(self): '''Display the explanatory paragraph and create the DiskWindow''' disk = get_desired_target_disk(self.doc) if disk.label == "GPT": raise SkipException if disk.whole_disk or getattr(disk, "use_whole_segment", False): LOGGER.debug("disk.whole_disk or disk.use_whole_segment is True, " "skip editing") # perform final target validation perform_final_validation(self.doc) raise SkipException if self.x86_slice_mode: LOGGER.debug("in x86 slice mode") part = get_solaris_partition(self.doc) LOGGER.debug(str(part)) if part is None: err_msg = "Critical error - no Solaris partition found" LOGGER.error(err_msg) raise ValueError(err_msg) if part.in_zpool is not None: LOGGER.debug("Whole partition selected. Skipping slice edit") LOGGER.debug(str(part)) # remove the in_zpool value from partition, delete any existing # slices, and create the needed underneath slices part.create_entire_partition_slice(in_zpool=part.in_zpool, in_vdev=DEFAULT_VDEV_NAME, tag=V_ROOT) part.bootid = Partition.ACTIVE part.in_zpool = None LOGGER.debug(str(part)) # Make sure in_zpool is not set on the Disk, target controller # puts it there in some cases disk.in_zpool = None # perform final target validation perform_final_validation(self.doc) raise SkipException else: part = disk if self.x86_slice_mode: header = self.header_text else: bootable = "" if self.is_x86 and disk.is_boot_disk(): bootable = PartEditScreen.BOOTABLE disk_size_str = locale.format( "%.1f", disk.disk_prop.dev_size.get( Size.gb_units)) + LOCALIZED_GB type_boot_str = PartEditScreen.HEADER_TYPE_BOOTABLE % \ {"type": disk.disk_prop.dev_type, "bootable": bootable} header = self.header_text + disk_size_str + type_boot_str self.main_win.set_header_text(header) y_loc = 1 fmt_dict = {'pool': ROOT_POOL} fmt_dict.update(RELEASE) y_loc += self.center_win.add_paragraph(self.paragraph_text % fmt_dict, y_loc) y_loc += 1 disk_win_area = WindowArea(6, 70, y_loc, 0) self.disk_win = DiskWindow(disk_win_area, part, window=self.center_win, editable=True, error_win=self.main_win.error_line, target_controller=self.tc) y_loc += disk_win_area.lines y_loc += 1 LOGGER.log(LOG_LEVEL_INPUT, "calling addch with params start_y=%s," "start_x=%s, ch=%c", y_loc, self.center_win.border_size[1], DiskWindow.DESTROYED_MARK) self.center_win.window.addch(y_loc, self.center_win.border_size[1], DiskWindow.DESTROYED_MARK, self.center_win.color_theme.inactive) self.center_win.add_text(self.destroy_text, y_loc, 2) self.main_win.do_update() self.center_win.activate_object(self.disk_win)
def _show(self): '''Display the explanatory paragraph and create the DiskWindow''' doc = InstallEngine.get_instance().doc if self.x86_slice_mode: LOGGER.debug("in x86 slice mode") disk = get_desired_target_disk(doc) if disk.whole_disk: LOGGER.debug("disk.whole_disk=True, skip editting") disk.whole_disk = False # perform final target validation perform_final_validation(doc) raise SkipException part = get_solaris_partition(doc) LOGGER.debug(str(part)) if part is None: err_msg = "Critical error - no Solaris partition found" LOGGER.error(err_msg) raise ValueError(err_msg) if part.in_zpool is not None: LOGGER.debug("Whole partition selected. Skipping slice edit") LOGGER.debug(str(part)) # # remove the in_zpool value from partition, delete # any existing slices, and create # the needed underneath slices # # All the logic from here to the part.bootid line # can be removed when GPT partitions is supported. # part.create_entire_partition_slice(in_zpool=part.in_zpool, in_vdev=DEFAULT_VDEV_NAME, tag=V_ROOT) part.bootid = Partition.ACTIVE part.in_zpool = None LOGGER.debug(str(part)) # perform final target validation perform_final_validation(doc) raise SkipException else: # get selected disk from desired target disk = get_desired_target_disk(doc) LOGGER.debug("disk.whole_disk: %s", disk.whole_disk) LOGGER.debug(str(disk)) if disk.whole_disk: LOGGER.debug("disk.whole_disk true, skipping editing") if not self.is_x86: # Unset this so Target Instantiation works correctly disk.whole_disk = False # perform final target validation perform_final_validation(doc) raise SkipException part = disk if self.x86_slice_mode: header = self.header_text else: bootable = "" if self.is_x86 and disk.is_boot_disk(): bootable = PartEditScreen.BOOTABLE disk_size_str = locale.format( "%.1f", disk.disk_prop.dev_size.get( Size.gb_units)) + LOCALIZED_GB type_boot_str = PartEditScreen.HEADER_TYPE_BOOTABLE % \ {"type": disk.disk_prop.dev_type, "bootable": bootable} header = self.header_text + disk_size_str + type_boot_str self.main_win.set_header_text(header) y_loc = 1 fmt_dict = {'pool': ROOT_POOL} fmt_dict.update(RELEASE) y_loc += self.center_win.add_paragraph(self.paragraph_text % fmt_dict, y_loc) y_loc += 1 disk_win_area = WindowArea(6, 70, y_loc, 0) self.disk_win = DiskWindow(disk_win_area, part, window=self.center_win, editable=True, error_win=self.main_win.error_line, target_controller=self.tc) y_loc += disk_win_area.lines y_loc += 1 LOGGER.log(LOG_LEVEL_INPUT, "calling addch with params start_y=%s," "start_x=%s, ch=%c", y_loc, self.center_win.border_size[1], DiskWindow.DESTROYED_MARK) self.center_win.window.addch(y_loc, self.center_win.border_size[1], DiskWindow.DESTROYED_MARK, self.center_win.color_theme.inactive) self.center_win.add_text(self.destroy_text, y_loc, 2) self.main_win.do_update() self.center_win.activate_object(self.disk_win)
def _show(self): '''Display the explanatory paragraph and create the DiskWindow''' doc = InstallEngine.get_instance().doc if self.x86_slice_mode: LOGGER.debug("in x86 slice mode") disk = get_desired_target_disk(doc) if disk.whole_disk: LOGGER.debug("disk.whole_disk=True, skip editting") disk.whole_disk = False # perform final target validation perform_final_validation(doc) raise SkipException part = get_solaris_partition(doc) LOGGER.debug(str(part)) if part is None: err_msg = "Critical error - no Solaris partition found" LOGGER.error(err_msg) raise ValueError(err_msg) if part.in_zpool is not None: LOGGER.debug("Whole partition selected. Skipping slice edit") LOGGER.debug(str(part)) # # remove the in_zpool value from partition, delete # any existing slices, and create # the needed underneath slices # # All the logic from here to the part.bootid line # can be removed when GPT partitions is supported. # part.create_entire_partition_slice(in_zpool=part.in_zpool, in_vdev=DEFAULT_VDEV_NAME, tag=V_ROOT) part.bootid = Partition.ACTIVE part.in_zpool = None LOGGER.debug(str(part)) # perform final target validation perform_final_validation(doc) raise SkipException else: # get selected disk from desired target disk = get_desired_target_disk(doc) LOGGER.debug("disk.whole_disk: %s", disk.whole_disk) LOGGER.debug(str(disk)) if disk.whole_disk: LOGGER.debug("disk.whole_disk true, skipping editing") if not self.is_x86: # Unset this so Target Instantiation works correctly disk.whole_disk = False # perform final target validation perform_final_validation(doc) raise SkipException part = disk if self.x86_slice_mode: header = self.header_text else: bootable = "" if self.is_x86 and disk.is_boot_disk(): bootable = PartEditScreen.BOOTABLE disk_size_str = locale.format("%.1f", disk.disk_prop.dev_size.get(Size.gb_units)) + LOCALIZED_GB type_boot_str = PartEditScreen.HEADER_TYPE_BOOTABLE % \ {"type": disk.disk_prop.dev_type, "bootable": bootable} header = self.header_text + disk_size_str + type_boot_str self.main_win.set_header_text(header) y_loc = 1 fmt_dict = {'pool': ROOT_POOL} fmt_dict.update(RELEASE) y_loc += self.center_win.add_paragraph(self.paragraph_text % fmt_dict, y_loc) y_loc += 1 disk_win_area = WindowArea(6, 70, y_loc, 0) self.disk_win = DiskWindow(disk_win_area, part, window=self.center_win, editable=True, error_win=self.main_win.error_line, target_controller=self.tc) y_loc += disk_win_area.lines y_loc += 1 LOGGER.log(LOG_LEVEL_INPUT, "calling addch with params start_y=%s," "start_x=%s, ch=%c", y_loc, self.center_win.border_size[1], DiskWindow.DESTROYED_MARK) self.center_win.window.addch(y_loc, self.center_win.border_size[1], DiskWindow.DESTROYED_MARK, self.center_win.color_theme.inactive) self.center_win.add_text(self.destroy_text, y_loc, 2) self.main_win.do_update() self.center_win.activate_object(self.disk_win)