コード例 #1
0
    def _use_existing_drive_partition_table(self):
        self.destination_partition_combobox_list.clear()
        self.partition_selection_list.clear()

        num_destination_partitions = 0

        with self.lvm_lv_path_lock:
            for lvm_lv_path in self.lvm_lv_path_list:
                self.destination_partition_combobox_list.append([lvm_lv_path, "Logical Volume: " + lvm_lv_path])
                num_destination_partitions += 1

        print("Looking at " + str(self.selected_image) + " and " + str(self.dest_drive_dict))

        # For the safety of end-users, ensure the initial combobox mapping is blank. It's possible to autogenerate a
        # mapping, but this could be wrong so far simpler for now to leave the mapping blank and rely on end-user
        # decisions.
        flattened_part_description = self.NOT_RESTORING_PARTITION_ENDUSER_FRIENDLY
        dest_partition_key = self.NOT_RESTORING_PARTITION_KEY
        is_restoring_partition = False

        # Populate image partition selection list (left-hand side column)
        if isinstance(self.selected_image, ClonezillaImage) or isinstance(self.selected_image, RedoBackupLegacyImage) or \
                isinstance(self.selected_image, FogProjectImage) or isinstance(self.selected_image, RedoRescueImage) or \
                isinstance(self.selected_image, FoxcloneImage) or isinstance(self.selected_image, ApartGtkImage) or \
                isinstance(self.selected_image, MetadataOnlyImage):
            for image_format_dict_key in self.selected_image.image_format_dict_dict.keys():
                if self.selected_image.does_image_key_belong_to_device(image_format_dict_key):
                    if self.selected_image.image_format_dict_dict[image_format_dict_key]['is_lvm_logical_volume']:
                        flat_image_part_description = "Logical Volume " + image_format_dict_key + ": "\
                                                      + self.selected_image.flatten_partition_string(image_format_dict_key)
                    elif isinstance(self.selected_image, ApartGtkImage):
                        # ApartGtkImage may contain multiple partitions, so the key contains the timestamp too. Therefore
                        # need to make sure the split device string function doesn't get called
                        flat_image_part_description = image_format_dict_key + ": "\
                                                      + self.selected_image.flatten_partition_string(image_format_dict_key)
                    else:
                        image_base_device_node, image_partition_number = Utility.split_device_string(image_format_dict_key)
                        flat_image_part_description = _("Partition {partition_number}").format(partition_number=str(
                    image_partition_number)) + ": "\
                                                      + self.selected_image.flatten_partition_string(image_format_dict_key)
                    self.partition_selection_list.append(
                        [image_format_dict_key, is_restoring_partition, flat_image_part_description, dest_partition_key,
                         flattened_part_description,
                         dest_partition_key, flattened_part_description])
                    num_destination_partitions += 1
        elif isinstance(self.selected_image, FsArchiverImage):
            for fs_key in self.selected_image.fsa_dict['filesystems'].keys():
                flat_image_part_description = "Filesystem " + str(
                fs_key) + ": " + self.selected_image.flatten_partition_string(fs_key)
                self.partition_selection_list.append(
                    [fs_key, is_restoring_partition, flat_image_part_description, dest_partition_key,
                     flattened_part_description,
                     dest_partition_key, flattened_part_description])
                num_destination_partitions += 1

        if num_destination_partitions == 0:
            # The destination disk must be empty.
            self.partition_selection_list.append(
                [self.dest_drive_node, is_restoring_partition, flat_image_part_description, self.dest_drive_node,
                 flattened_part_description,
                 dest_partition_key, flattened_part_description])

        # Populate combobox (right-hand side column)
        num_combo_box_entries = 0
        is_destination_partition_target_drive = False
        if 'partitions' in self.dest_drive_dict.keys() and len(self.dest_drive_dict['partitions'].keys()) > 0:
            # Loop over the partitions in in the destination drive
            for dest_partition_key in self.dest_drive_dict['partitions'].keys():
                if 'type' in self.dest_drive_dict['partitions'][dest_partition_key].keys() and self.dest_drive_dict['partitions'][dest_partition_key]['type'] == "extended":
                    # Do not add a destination combobox entry for any Extended Boot Record (EBR) destination partition
                    # nodes to reduce risk of user confusion.
                    continue
                if dest_partition_key == self.dest_drive_node:
                    is_destination_partition_target_drive = True
                flattened_part_description = dest_partition_key + ": " + CombinedDriveState.flatten_part(
                    self.dest_drive_dict['partitions'][dest_partition_key])
                self.destination_partition_combobox_list.append([dest_partition_key, flattened_part_description])
                num_combo_box_entries += 1

        # If there is no partitions on the destination disk, provide the option to remap the partitions to the whole
        # destination disk. If the source image doesn't have a partition table, also want to be able to remap partitons
        # to the destination disk. Finally, if the destination disk already has a filesystem directly on disk then
        # that would have already been handled above and there's no need to add a new entry to the combobox.
        if (num_combo_box_entries == 0 or not self.selected_image.has_partition_table()) and not is_destination_partition_target_drive:
            flattened_disk_description = self.dest_drive_node + ": " + CombinedDriveState.flatten_drive(self.dest_drive_dict)
            # If there are no partitions in the destination drive, we place the entire drive as the destination
            self.destination_partition_combobox_list.append([self.dest_drive_node, "WHOLE DRIVE " + flattened_disk_description])

        for mode in self.mode_list:
            self.destination_partition_combobox_cell_renderer_dict[mode].set_sensitive(True)
コード例 #2
0
    def _use_existing_drive_partition_table(self):
        self.destination_partition_combobox_list.clear()
        self.restore_partition_selection_list.clear()

        num_destination_partitions = 0

        with self.lvm_lv_path_lock:
            for lvm_lv_path in self.lvm_lv_path_list:
                self.destination_partition_combobox_list.append(
                    [lvm_lv_path, "Logical Volume: " + lvm_lv_path])
                num_destination_partitions += 1

        print("Looking at " + str(self.selected_image) + " and " +
              str(self.dest_drive_dict))

        # For the safety of end-users, ensure the initial combobox mapping is blank. It's possible to autogenerate a
        # mapping, but this could be wrong so far simpler for now to leave the mapping blank and rely on end-user
        # decisions.
        flattened_part_description = self.NOT_RESTORING_PARTITION_ENDUSER_FRIENDLY
        dest_partition_key = self.NOT_RESTORING_PARTITION_KEY
        is_restoring_partition = False

        # Populate image partition selection list (left-hand side column)
        if isinstance(self.selected_image, ClonezillaImage):
            for image_format_dict_key in self.selected_image.image_format_dict_dict.keys(
            ):
                # TODO: Support Clonezilla multidisk
                short_device_key = self.selected_image.short_device_node_disk_list[
                    0]
                if self.selected_image.does_image_key_belong_to_device(
                        image_format_dict_key, short_device_key):
                    if self.selected_image.image_format_dict_dict[
                            image_format_dict_key]['is_lvm_logical_volume']:
                        flat_image_part_description = "Logical Volume " + image_format_dict_key + ": " + self.selected_image.flatten_partition_string(
                            short_device_key, image_format_dict_key)
                    else:
                        image_base_device_node, image_partition_number = Utility.split_device_string(
                            image_format_dict_key)
                        flat_image_part_description = "Partition " + str(
                            image_partition_number
                        ) + ": " + self.selected_image.flatten_partition_string(
                            short_device_key, image_format_dict_key)
                    self.restore_partition_selection_list.append([
                        image_format_dict_key, is_restoring_partition,
                        flat_image_part_description, dest_partition_key,
                        flattened_part_description, dest_partition_key,
                        flattened_part_description
                    ])
                    num_destination_partitions += 1
        elif isinstance(self.selected_image, RedoBackupLegacyImage):
            partitions = self.selected_image.short_device_node_partition_list
            for image_format_dict_key in partitions:
                image_base_device_node, image_partition_number = Utility.split_device_string(
                    image_format_dict_key)
                flat_image_part_description = "Partition " + str(
                    image_partition_number
                ) + ": " + self.selected_image.flatten_partition_string(
                    image_format_dict_key)
                self.restore_partition_selection_list.append([
                    image_format_dict_key, is_restoring_partition,
                    flat_image_part_description, dest_partition_key,
                    flattened_part_description, dest_partition_key,
                    flattened_part_description
                ])
                num_destination_partitions += 1

        if num_destination_partitions == 0:
            # The destination disk must be empty.
            self.restore_partition_selection_list.append([
                self.dest_drive_node, is_restoring_partition,
                flat_image_part_description, self.dest_drive_node,
                flattened_part_description, dest_partition_key,
                flattened_part_description
            ])

        # Populate combobox (right-hand side column)
        num_combo_box_entries = 0
        if 'partitions' in self.dest_drive_dict.keys() and len(
                self.dest_drive_dict['partitions'].keys()) > 0:
            # Loop over the partitions in in the destination drive
            for dest_partition_key in self.dest_drive_dict['partitions'].keys(
            ):
                if 'type' in self.dest_drive_dict['partitions'][
                        dest_partition_key].keys(
                        ) and self.dest_drive_dict['partitions'][
                            dest_partition_key]['type'] == "extended":
                    # Do not add a destination combobox entry for any Extended Boot Record (EBR) destination partition
                    # nodes to reduce risk of user confusion.
                    continue

                flattened_part_description = dest_partition_key + ": " + CombinedDriveState.flatten_part(
                    self.dest_drive_dict['partitions'][dest_partition_key])
                self.destination_partition_combobox_list.append(
                    [dest_partition_key, flattened_part_description])
                num_combo_box_entries += 1

        if num_combo_box_entries == 0:
            # TODO: Improve disk description
            flattened_disk_description = self.dest_drive_node
            # If there are no partitions in the destination drive, we place the entire drive as the destination
            self.destination_partition_combobox_list.append([
                self.dest_drive_node,
                "WHOLE DRIVE " + flattened_disk_description
            ])

        self.builder.get_object(
            "destination_partition_combobox_cell_renderer").set_sensitive(True)