Esempio n. 1
0
    def test_resetting_all_disks(self):
        '''Validate that all selected disks can be reset'''
        discovered_disks = self._get_discovered_disks()
        tc = TargetController(self.doc)

        # Set disk.label to VTOC explicitly. If there is no label set
        # then TargetController will default it to GPT and remove the
        # MBR partitions.
        for i in [1, 2]:
            discovered_disks[i].label = "VTOC"

        selected_disks = tc.select_disk(
            [discovered_disks[1], discovered_disks[2]])

        selected_disks[0].delete_children(class_type=Partition)
        selected_disks[1].delete_children(class_type=Partition)

        tc.reset_layout()

        desired_disks = self._get_desired_disks()
        self.assertEqual(len(desired_disks), 2,
                         "there should be 2 Disks selected")
        self.assertEqual(
            len(desired_disks[0].get_children(class_type=Partition)), 1,
            "1st disk should have 1 partition")
        self.assertEqual(
            len(desired_disks[1].get_children(class_type=Partition)), 1,
            "2nd disk should have 1 partition")
Esempio n. 2
0
    def test_reset_layout(self):
        '''Validate that existing partitions are restored with reset_layout.'''
        if platform.processor() != "i386":
            raise SkipTest("test not supported on sparc")

        discovered_disks = self._get_discovered_disks()
        tc = TargetController(self.doc, debug=True)

        # Set disk.label to VTOC explicitly. If there is no label set
        # then TargetController will default it to GPT and remove the
        # MBR partitions.
        discovered_disks[3].label = "VTOC"

        selected_disks = tc.select_disk(discovered_disks[3])
        self.assertEqual(len(selected_disks), 1,
                         "there should be 1 Disk returned")

        # When wipe_disk is True the default layout becomes GPT based rather
        # than VTOC.
        tc.apply_default_layout(selected_disks[0], use_whole_disk=False, \
                                wipe_disk=True)
        self.assertEqual(selected_disks[0].label, "GPT",
            "disk should have a GPT label now. Has %s instead." \
            % selected_disks[0].label)
        self.assertEqual(
            len(selected_disks[0].get_children(class_type=GPTPartition)), 3,
            "disk should have 3 GPT partitions now")
        copy_disks = tc.reset_layout(selected_disks[0], use_whole_disk=False)

        self.assertEqual(len(copy_disks), 1, "there should be 1 Disk returned")
        self.assertEqual(copy_disks[0].ctd, discovered_disks[3].ctd,
                         "incorrect disk returned")
        self.assertEqual(len(copy_disks[0].get_children(class_type=Partition)),
                         2, "disk should have 2 partitions again")
    def test_resetting_all_disks(self):
        '''Validate that all selected disks can be reset'''
        discovered_disks = self._get_discovered_disks()
        tc = TargetController(self.doc)
        selected_disks = tc.select_disk(
            [discovered_disks[1], discovered_disks[2]])

        selected_disks[0].delete_children(class_type=Partition)
        selected_disks[1].delete_children(class_type=Partition)

        tc.reset_layout()

        desired_disks = self._get_desired_disks()
        self.assertEqual(len(desired_disks), 2,
            "there should be 2 Disks selected")
        self.assertEqual(
            len(desired_disks[0].get_children(class_type=Partition)),
            1,
            "1st disk should have 1 partition")
        self.assertEqual(
            len(desired_disks[1].get_children(class_type=Partition)),
            1,
            "2nd disk should have 1 partition")
    def test_reset_layout(self):
        '''Validate that existing partitions are restored with reset_layout.'''
        if platform.processor() != "i386":
            raise SkipTest("test not supported on sparc")

        discovered_disks = self._get_discovered_disks()
        tc = TargetController(self.doc, debug=True)
        selected_disks = tc.select_disk(discovered_disks[3])
        self.assertEqual(len(selected_disks), 1,
            "there should be 1 Disk returned")
        tc.apply_default_layout(selected_disks[0], use_whole_disk=False, \
                                wipe_disk=True)
        self.assertEqual(
            len(selected_disks[0].get_children(class_type=Partition)),
            1, "disk should have 1 partition now")
        copy_disks = tc.reset_layout(selected_disks[0], use_whole_disk=False)

        self.assertEqual(len(copy_disks), 1,
            "there should be 1 Disk returned")
        self.assertEqual(copy_disks[0].ctd, discovered_disks[3].ctd,
            "incorrect disk returned")
        self.assertEqual(
            len(copy_disks[0].get_children(class_type=Partition)),
            2, "disk should have 2 partitions again")