Exemple #1
0
    def _show(self):
        '''Display the explanatory paragraph and create the DiskWindow'''

        disk = get_desired_target_disk(self.doc)
        if disk.label == "VTOC":
            raise SkipException

        if disk.whole_disk:
            LOGGER.debug("disk.whole_disk=True, skip editing")

            # perform final target validation
            perform_final_validation(self.doc)

            raise SkipException

        part = disk

        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)
Exemple #2
0
    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 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)
Exemple #4
0
    def validate(self):
        ''' Perform final validation of the desired target
        '''

        # Before validation can happen, we need to set the in_zpool and in_vdev
        # attributes on *ONLY* the GPT partition the user selected.  We provide
        # the ability for the user to create multiple 'solaris' GPT partitions,
        # but we only use one of them for the root pool.
        # If there are multiple Solaris partitions the user must select one
        # explicitly by highlighting it. If there is only one though, its
        # selection is implicit.
        gpt_partition = None
        disk = get_desired_target_disk(self.doc)

        # In order to get to the specific DOC object we need to translate
        # through the many window layers:
        # main_win.disk_win.[left | right]_win.list_obj.edit_obj.UI_obj.DOC_obj
        inner_window = self.disk_win.get_active_object()
        edit_object = inner_window.get_active_object()
        ui_object = edit_object.get_active_object()

        # trap on any non Solaris partition
        if ui_object is None:
            parts = disk.get_children(class_type=GPTPartition)
            if parts:
                solparts = [p for p in parts if p.is_solaris]
                # Only one Solaris partition, so its selection is implicit.
                if len(solparts) == 1:
                    gpt_partition = solparts[0]

            if gpt_partition is None:
                raise UIMessage(GPTPartEditScreen.SELECTION_ERROR)
        else:
            gpt_partition = ui_object.data_obj.doc_obj

        # verify the size of the selected partition is large enough
        min_size = self.tc.minimum_target_size
        if min_size > gpt_partition.size:
            raise UIMessage(GPTPartEditScreen.PART_TOO_SMALL %
                            {"size": min_size.get(Size.gb_units)})

        # unset in_zpool and in_vdev on the parent Disk object
        disk.in_zpool = None
        disk.in_vdev = None

        # unset in_zpool and in_vdev on all other GPT Partitions on this disk
        for entry in disk.get_children(class_type=GPTPartition):
            if entry.name != gpt_partition.name:
                entry.in_zpool = None
                entry.in_vdev = None

        # Set in_zpool, in_vdev and the action for this partition
        gpt_partition.in_zpool = DEFAULT_ZPOOL_NAME
        gpt_partition.in_vdev = DEFAULT_VDEV_NAME
        gpt_partition.action = "create"

        # create required EFI System or BIOS boot partitions and reserved
        # partitions
        try:
            sys_part, resv_part, gpt_partition = \
                disk.add_required_partitions(donor=gpt_partition)
            LOGGER.debug("System/Boot Partition:  %s", str(sys_part))
            LOGGER.debug("Reserved Partition:  %s", str(resv_part))

        except NoGPTPartitionSlotsFree:
            # If there are no unused partitions left we can't proceed
            LOGGER.warning("No free slots available for boot partition.")
            raise UIMessage("Too many partitions.  Delete unnecessary "
                            "partitions.")

        except InsufficientSpaceError as ise:
            raise RuntimeError(
                "INTERNAL ERROR: Could not allocate space "
                "for system partition or reserved partition on disk %s: "
                "%s" % (disk, str(ise)))

        perform_final_validation(self.doc)
Exemple #5
0
    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)
Exemple #6
0
    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)
Exemple #7
0
    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)