def _show(self): '''Create a list of disks to choose from and create the window for displaying the partition/slice information from the selected disk ''' if self.install_profile.install_to_pool: raise SkipException self.wait_for_disks() self.num_targets = 0 if not self.disks: self.center_win.add_paragraph(DiskScreen.NO_DISKS, 1, 1, max_x=(self.win_size_x - 1)) return if isinstance(self.disks[0], BaseException): if len(self.disks) == 1: raise tgt.TgtError(("Unexpected error (%s) during target " "discovery. See log for details.") % self.disks[0]) else: self.disks = self.disks[1:] logging.warn("Failure in target discovery, but one or more" " disks found. Continuing.") boot_disk = self.disks[0] for disk in self.disks: if (disk.size.size_as("gb") > self.minimum_size): self.num_targets += 1 if disk.boot: boot_disk = disk self.disks.remove(boot_disk) self.disks.insert(0, boot_disk) if self.num_targets == 0: self.center_win.add_paragraph(DiskScreen.NO_TARGETS, 1, 1, max_x=(self.win_size_x - 1)) return self.main_win.reset_actions() self.main_win.show_actions() y_loc = 1 self.center_win.add_text(DiskScreen.PARAGRAPH, y_loc, 1) y_loc += 1 self.center_win.add_text(self.size_line, y_loc, 1) y_loc += 2 self.center_win.add_text(self.disk_header_text, y_loc, 1) y_loc += 1 self.center_win.window.hline(y_loc, self.center_win.border_size[1] + 1, curses.ACS_HLINE, textwidth(self.disk_header_text)) y_loc += 1 disk_win_area = WindowArea(4, textwidth(self.disk_header_text) + 2, y_loc, 0) disk_win_area.scrollable_lines = len(self.disks) + 1 self.disk_win = ScrollWindow(disk_win_area, window=self.center_win) disk_item_area = WindowArea(1, disk_win_area.columns - 2, 0, 1) disk_index = 0 len_use = DiskScreen.DISK_HEADERS[0][0] - 1 len_type = DiskScreen.DISK_HEADERS[1][0] - 1 len_size = DiskScreen.DISK_HEADERS[2][0] - 1 len_boot = DiskScreen.DISK_HEADERS[3][0] - 1 len_dev = DiskScreen.DISK_HEADERS[4][0] - 1 len_mftr = DiskScreen.DISK_HEADERS[5][0] - 1 for disk in self.disks: disk_text_fields = [] type_field = disk.type[:len_type] type_field = ljust_columns(type_field, len_type) disk_text_fields.append(type_field) disk_size = disk.size.size_as("gb") size_field = "%*.1f" % (len_size, disk_size) disk_text_fields.append(size_field) if disk.boot: bootable_field = "+".center(len_boot) else: bootable_field = " " * (len_boot) disk_text_fields.append(bootable_field) device_field = disk.name[:len_dev] device_field = ljust_columns(device_field, len_dev) disk_text_fields.append(device_field) if disk.vendor is not None: mftr_field = disk.vendor[:len_mftr] mftr_field = ljust_columns(mftr_field, len_mftr) else: mftr_field = " " * len_mftr disk_text_fields.append(mftr_field) selectable = True if disk_size < self.minimum_size: note_field = self.too_small_text selectable = False elif DiskInfo.GPT in disk.label: note_field = DiskScreen.GPT_LABELED elif disk_size > SliceInfo.MAX_VTOC.size_as("gb"): note_field = self.too_big_warn else: note_field = "" # Use first selectable disk if no disk was used yet if disk.used is None and not self.one_disk_used and selectable: disk.used = True self.one_disk_used = True disk_text_fields.append(note_field) disk_text = " ".join(disk_text_fields) disk_item_area.y_loc = disk_index disk_list_item = MultiListItem(disk_item_area, window=self.disk_win, text=disk_text, add_obj=selectable, used=disk.used) disk_list_item.on_make_active = on_activate disk_list_item.on_make_active_kwargs["disk_info"] = disk disk_list_item.on_make_active_kwargs["disk_select"] = self disk_list_item.on_select = on_select disk_list_item.on_select_kwargs["disk_info"] = disk disk_list_item.on_select_kwargs["disk_select"] = self disk_index += 1 self.disk_win.no_ut_refresh() y_loc += 7 disk_detail_area = WindowArea(6, 70, y_loc, 1) self.disk_detail = DiskWindow(disk_detail_area, self.disks[0], window=self.center_win) self.main_win.do_update() self.center_win.activate_object(self.disk_win) self.disk_win.activate_object(self.selected_disk) # Set the flag so that the disk is not copied by on_change_screen, # unless on_select gets called as a result of the user changing # the selected disks. self.do_copy = False
def _show(self): '''Display partition data for selected disk, and present the two choices ''' if self.install_profile.install_to_pool: raise SkipException if self.x86_slice_mode: if len(self.install_profile.disks) > 1: # When installing on multiple disks use only whole disk EFI type logging.error("Not looking at partitions on multi-dev install") raise SkipException disk = self.install_profile.disks[0] self.disk_info = disk.get_solaris_data() if self.disk_info is None: # No partitions selected - it's whole disk EFI install logging.error("No partitions were selected. Continuing.") raise SkipException logging.debug("bool(self.disk_info.slices)=%s", bool(self.disk_info.slices)) logging.debug("self.disk_info.modified()=%s", self.disk_info.modified()) if not self.disk_info.slices or self.disk_info.modified(): logging.debug("Setting partition.use_whole_segment," "creating default layout, and skipping") self.disk_info.use_whole_segment = True # We only do slice level editing on x86 if there are # existing slices on an existing (unmodified)Solaris # partition self.disk_info.create_default_layout() raise SkipException disp_disk = self.install_profile.original_disks[ 0].get_solaris_data() logging.debug("Preserved partition with existing slices:" " presenting option to install into a slice") else: if len(self.install_profile.disks) > 1: suggested_pool_types = ['mirror'] if len(self.install_profile.disks) > 2: suggested_pool_types.append('raidz') if len(self.install_profile.disks) > 3: suggested_pool_types.append('raidz2') if len(self.install_profile.disks) > 4: suggested_pool_types.append('raidz3') # Show selected disks header_text = self.HEADER_ZPOOL % (SliceInfo.DEFAULT_POOL.data) self.main_win.set_header_text(header_text) y_loc = 1 y_loc += self.center_win.add_paragraph(self.SELECTED_DISKS, start_y=y_loc) for disk in self.install_profile.disks: y_loc += self.center_win.add_paragraph(self.DISK_INFO % { "name": disk.name, "size": disk.size }, start_y=y_loc) y_loc += 2 y_loc += self.center_win.add_paragraph(self.SELECT_POOL_TYPE, start_y=y_loc) pool_type_win_area = WindowArea(1, 1, y_loc, 0) selected_pool_type = 0 for pool_type in suggested_pool_types: pool_type_win_area.y_loc = y_loc pool_type_win_area.columns = len(pool_type) + 1 list_item = ListItem(pool_type_win_area, window=self.center_win, text=pool_type, data_obj=pool_type) if pool_type == self.selected_pool_type_name: selected_pool_type = list_item y_loc += 1 self.main_win.do_update() self.center_win.activate_object(selected_pool_type) else: self.disk_info = self.install_profile.disks[0] disp_disk = self.install_profile.original_disks[0] if self.disk_info.boot: bootable = FDiskPart.BOOT_TEXT else: bootable = "" header_text = self.header_text % \ {"size" : self.disk_info.size.size_as("gb"), "type" : self.disk_info.type, "bootable" : bootable} self.main_win.set_header_text(header_text) if len(self.install_profile.disks) == 1: 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: found_parts = bool(self.disk_info.partitions) else: found_parts = bool(self.disk_info.slices) 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, disp_disk, window=self.center_win) y_loc += disk_win_area.lines y_loc += 3 whole_disk_width = textwidth(self.use_whole) + 3 cols = int((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 = int((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.disk_info.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): '''Create an EditField for entering hostname, and list items for each of the network types ''' if self.install_profile.system is None: self.install_profile.system = SystemInfo() self.sys_info = self.install_profile.system if self.install_profile.nic is None: self.install_profile.nic = self.nic_info y_loc = 1 y_loc += self.center_win.add_paragraph(NetworkTypeScreen.PARAGRAPH, y_loc) y_loc += 1 self.center_win.add_text(NetworkTypeScreen.HOSTNAME_TEXT, y_loc) max_cols = self.win_size_x - self.hostfield_offset cols = min(max_cols, NetworkTypeScreen.HOSTNAME_SCREEN_LEN) scrollable_columns = SystemInfo.MAX_HOSTNAME_LEN + 1 hostname_area = WindowArea(1, cols, y_loc, self.hostfield_offset, scrollable_columns=scrollable_columns) self.hostname = EditField(hostname_area, window=self.center_win, text=self.sys_info.hostname, validate=hostname_is_valid, error_win=self.main_win.error_line) self.hostname.item_key = None y_loc += 3 if not self.have_nic: self.center_win.add_paragraph(NetworkTypeScreen.NO_NICS_FOUND, y_loc, 1) self.main_win.do_update() activate = self.net_type_dict.get(self.nic_info.type, self.hostname) self.center_win.activate_object(activate) return y_loc += self.center_win.add_paragraph(NetworkTypeScreen.NET_TYPE_TEXT, y_loc) y_loc += 1 item_area = WindowArea(1, NetworkTypeScreen.ITEM_MAX_WIDTH, y_loc, NetworkTypeScreen.ITEM_OFFSET) self.automatic = ListItem(item_area, window=self.center_win, text=NetworkTypeScreen.AUTO_TEXT) self.automatic.item_key = NetworkInfo.AUTOMATIC self.net_type_dict[self.automatic.item_key] = self.automatic self.center_win.add_text(NetworkTypeScreen.AUTO_DETAIL, y_loc, NetworkTypeScreen.ITEM_DESC_OFFSET, self.menu_item_desc_max) y_loc += 2 item_area.y_loc = y_loc self.manual = ListItem(item_area, window=self.center_win, text=NetworkTypeScreen.MANUAL_TEXT) self.manual.item_key = NetworkInfo.MANUAL self.net_type_dict[self.manual.item_key] = self.manual self.center_win.add_text(NetworkTypeScreen.MANUAL_DETAIL, y_loc, NetworkTypeScreen.ITEM_DESC_OFFSET, self.menu_item_desc_max) y_loc += 2 item_area.y_loc = y_loc self.none_option = ListItem(item_area, window=self.center_win, text=NetworkTypeScreen.NONE_TEXT) self.none_option.item_key = NetworkInfo.NONE self.net_type_dict[self.none_option.item_key] = self.none_option self.center_win.add_text(NetworkTypeScreen.NONE_DETAIL, y_loc, NetworkTypeScreen.ITEM_DESC_OFFSET, self.menu_item_desc_max) self.main_win.do_update() activate = self.net_type_dict.get(self.nic_info.type, self.hostname) self.center_win.activate_object(activate)
def _show(self): '''Create a list of disks to choose from and create the window for displaying the partition/slice information from the selected disk ''' self.wait_for_disks() self.num_targets = 0 if not self.disks: self.center_win.add_paragraph(DiskScreen.NO_DISKS, 1, 1, max_x=(self.win_size_x - 1)) return if isinstance(self.disks[0], BaseException): if len(self.disks) == 1: raise tgt.TgtError(("Unexpected error (%s) during target " "discovery. See log for details.") % self.disks[0]) else: self.disks = self.disks[1:] logging.warn("Failure in target discovery, but one or more" " disks found. Continuing.") boot_disk = self.disks[0] for disk in self.disks: if (disk.size.size_as("gb") > self.minimum_size): self.num_targets += 1 if disk.boot: boot_disk = disk self.disks.remove(boot_disk) self.disks.insert(0, boot_disk) if self.num_targets == 0: self.center_win.add_paragraph(DiskScreen.NO_TARGETS, 1, 1, max_x=(self.win_size_x - 1)) return self.main_win.reset_actions() self.main_win.show_actions() y_loc = 1 self.center_win.add_text(DiskScreen.PARAGRAPH, y_loc, 1) y_loc += 1 self.center_win.add_text(self.size_line, y_loc, 1) y_loc += 2 self.center_win.add_text(self.disk_header_text, y_loc, 1) y_loc += 1 self.center_win.window.hline(y_loc, self.center_win.border_size[1] + 1, curses.ACS_HLINE, textwidth(self.disk_header_text)) y_loc += 1 disk_win_area = WindowArea(4, textwidth(self.disk_header_text) + 2, y_loc, 0) disk_win_area.scrollable_lines = len(self.disks) + 1 self.disk_win = ScrollWindow(disk_win_area, window=self.center_win) disk_item_area = WindowArea(1, disk_win_area.columns - 2, 0, 1) disk_index = 0 len_type = DiskScreen.DISK_HEADERS[0][0] - 1 len_size = DiskScreen.DISK_HEADERS[1][0] - 1 len_boot = DiskScreen.DISK_HEADERS[2][0] - 1 len_dev = DiskScreen.DISK_HEADERS[3][0] - 1 len_mftr = DiskScreen.DISK_HEADERS[4][0] - 1 for disk in self.disks: disk_text_fields = [] type_field = disk.type[:len_type] type_field = ljust_columns(type_field, len_type) disk_text_fields.append(type_field) disk_size = disk.size.size_as("gb") size_field = "%*.1f" % (len_size, disk_size) disk_text_fields.append(size_field) if disk.boot: bootable_field = "+".center(len_boot) else: bootable_field = " " * (len_boot) disk_text_fields.append(bootable_field) device_field = disk.name[:len_dev] device_field = ljust_columns(device_field, len_dev) disk_text_fields.append(device_field) if disk.vendor is not None: mftr_field = disk.vendor[:len_mftr] mftr_field = ljust_columns(mftr_field, len_mftr) else: mftr_field = " " * len_mftr disk_text_fields.append(mftr_field) selectable = True if disk_size < self.minimum_size: note_field = self.too_small_text selectable = False elif DiskInfo.GPT in disk.label: note_field = DiskScreen.GPT_LABELED elif disk_size > SliceInfo.MAX_VTOC.size_as("gb"): note_field = self.too_big_warn else: note_field = "" disk_text_fields.append(note_field) disk_text = " ".join(disk_text_fields) disk_item_area.y_loc = disk_index disk_list_item = ListItem(disk_item_area, window=self.disk_win, text=disk_text, add_obj=selectable) disk_list_item.on_make_active = on_activate disk_list_item.on_make_active_kwargs["disk_info"] = disk disk_list_item.on_make_active_kwargs["disk_select"] = self disk_index += 1 self.disk_win.no_ut_refresh() y_loc += 7 disk_detail_area = WindowArea(6, 70, y_loc, 1) self.disk_detail = DiskWindow(disk_detail_area, self.disks[0], window=self.center_win) self.main_win.do_update() self.center_win.activate_object(self.disk_win) self.disk_win.activate_object(self.selected_disk) # Set the flag so that the disk is not copied by on_change_screen, # unless on_activate gets called as a result of the user changing # the selected disk. self.do_copy = False
def _show(self): '''Create a list of pools to choose from, ask user to select BE name and if we should overwrite pool's boot configuration ''' if not self.install_profile.install_to_pool: raise SkipException if len(self.existing_pools) == 0: self.existing_pools.extend(get_zpool_list()) self.num_targets = 0 if len(self.existing_pools) == 0: self.center_win.add_paragraph(ZpoolScreen.NO_POOLS, 1, 1, max_x=(self.win_size_x - 1)) return for pool in self.existing_pools: free_gb = get_zpool_free_size(pool) / 1024 / 1024 / 1024 if (get_zpool_free_size(pool) / 1024 / 1024 / 1024 > self.minimum_size): self.num_targets += 1 else: logging.info("Skipping pool %s: need %d GB, free %d GB" % (pool, self.minimum_size, free_gb)) if self.num_targets == 0: self.center_win.add_paragraph(ZpoolScreen.NO_TARGETS, 1, 1, max_x=(self.win_size_x - 1)) return self.main_win.reset_actions() self.main_win.show_actions() y_loc = 1 self.center_win.add_text(ZpoolScreen.PARAGRAPH, y_loc, 1) y_loc += 1 self.center_win.add_text(self.size_line, y_loc, 1) y_loc += 2 self.center_win.add_text(self.pool_header_text, y_loc, 1) y_loc += 1 self.center_win.window.hline(y_loc, self.center_win.border_size[1] + 1, curses.ACS_HLINE, textwidth(self.pool_header_text)) y_loc += 1 pool_win_area = WindowArea(4, textwidth(self.pool_header_text) + 2, y_loc, 0) pool_win_area.scrollable_lines = len(self.existing_pools) + 1 self.pool_win = ScrollWindow(pool_win_area, window=self.center_win) pool_item_area = WindowArea(1, pool_win_area.columns - 2, 0, 1) pool_index = 0 len_name = ZpoolScreen.POOL_HEADERS[0][0] - 1 len_size = ZpoolScreen.POOL_HEADERS[2][0] - 1 for pool in self.existing_pools: pool_text_fields = [] name_field = pool[:len_name] name_field = ljust_columns(name_field, len_name) pool_text_fields.append(name_field) pool_size = get_zpool_free_size(pool) / 1024 / 1024 / 1024 size_field = "%*.1f" % (len_size, pool_size) pool_text_fields.append(size_field) selectable = True if pool_size < self.minimum_size: note_field = self.too_small_text selectable = False else: note_field = "" pool_text_fields.append(note_field) pool_text = " ".join(pool_text_fields) pool_item_area.y_loc = pool_index pool_list_item = ListItem(pool_item_area, window=self.pool_win, text=pool_text, add_obj=selectable) pool_list_item.on_make_active = on_activate pool_list_item.on_make_active_kwargs["pool_select"] = self pool_index += 1 self.pool_win.no_ut_refresh() y_loc += 7 self.list_area.y_loc = y_loc y_loc += 2 self.error_area.y_loc = y_loc self.be_name_err = ErrorWindow(self.error_area, window=self.center_win) self.be_name_list = ListItem(self.list_area, window=self.center_win, text=ZpoolScreen.BE_LABEL) self.be_name_edit = EditField(self.edit_area, window=self.be_name_list, validate=be_name_valid, error_win=self.be_name_err, text=self.install_profile.be_name) y_loc += 2 boot_configuration_width = textwidth( ZpoolScreen.OVERWRITE_BOOT_CONFIGURATION_LABEL) + 5 cols = int((self.win_size_x - boot_configuration_width) / 2) boot_configuration_area = WindowArea(1, boot_configuration_width, y_loc, cols) self.boot_configuration_item = MultiListItem( boot_configuration_area, window=self.center_win, text=ZpoolScreen.OVERWRITE_BOOT_CONFIGURATION_LABEL, used=self.install_profile.overwrite_boot_configuration) self.boot_configuration_item.on_select = on_select_obc self.boot_configuration_item.on_select_kwargs["pool_select"] = self self.main_win.do_update() self.center_win.activate_object(self.pool_win) self.pool_win.activate_object(self.selected_pool) # Set the flag so that the pool is not copied by on_change_screen, # unless on_activate gets called as a result of the user changing # the selected pool. self.do_copy = False