Esempio n. 1
0
 def set_status_message(self, message):
     '''Set the status message on the screen, completely overwriting
     the previous message'''
     self.center_win.add_text(ljust_columns(message,
                                            self.status_msg_loc[2]),
                              self.status_msg_loc[0],
                              self.status_msg_loc[1],
                              max_chars=self.status_msg_loc[2])
Esempio n. 2
0
    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
Esempio n. 3
0
 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
Esempio n. 4
0
    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