7046766 Final validation should check for all solaris partition types, not just Solaris2
authorDrew Fisher <drew.fisher@oracle.com>
Mon, 23 May 2011 10:49:53 -0600
changeset 1142 47266a70ba5f
parent 1141 c1d4dae5faa8
child 1143 b5b7daf22e33
7046766 Final validation should check for all solaris partition types, not just Solaris2 7047335 Gaps calculation for logical partions should ignore extended partitions being deleted. 7047084 Final Validation Failed when creating Solaris2 logical partition on extened partition
usr/src/lib/install_target/__init__.py
usr/src/lib/install_target/physical.py
usr/src/lib/install_target/test/test_shadow_list.py
--- a/usr/src/lib/install_target/__init__.py	Fri May 20 15:20:13 2011 -0700
+++ b/usr/src/lib/install_target/__init__.py	Mon May 23 10:49:53 2011 -0600
@@ -90,16 +90,32 @@
             # for x86, check for at least one active Solaris2 partition
             # specified
             if platform.processor() == "i386":
-                valid = False
-                valid_part_value = physical.Partition.name_to_num("Solaris2")
+                old_solaris = \
+                    physical.Partition.name_to_num("Solaris/Linux swap")
+                solaris2 = physical.Partition.name_to_num("Solaris2")
                 p_list = self.get_descendants(class_type=physical.Partition)
+                found_old_solaris = False
                 for partition in p_list:
-                    if partition.part_type == valid_part_value:
-                        if partition.bootid == physical.Partition.ACTIVE:
-                            valid = True
+                    # look for the old solaris partition id (130)
+                    if partition.part_type == old_solaris:
+                        found_old_solaris = True
+
+                    # if the partition is a solaris2 partition (191), verify
+                    # it's an active primary partition or a logical partition
+                    if partition.part_type == solaris2:
+                        if partition.bootid == physical.Partition.ACTIVE or \
+                           partition.is_logical:
                             break
                 else:
-                    raise Target.InvalidError("No active 'Solaris2' " +
+                    # check to see if an older solaris partition was found.  If
+                    # so, warn the user before failing
+                    if found_old_solaris:
+                        self.logger.warning("Only found an older 'solaris' "
+                                            "partition.  Consider using "
+                                            "fdisk to change the partition ID "
+                                            "to 'solaris2'")
+
+                    raise Target.InvalidError("No active 'Solaris2' "
                                               "partitions found")
 
             # verify one zpool is specified with is_root set to "true"
--- a/usr/src/lib/install_target/physical.py	Fri May 20 15:20:13 2011 -0700
+++ b/usr/src/lib/install_target/physical.py	Mon May 23 10:49:53 2011 -0600
@@ -235,7 +235,7 @@
             return[HoleyObject(0, self.size)]
 
         # create a list of sector usage by this partition.
-        usage = []
+        usage = list()
         for child in self._children:
             # skip slices marked for deletion
             if child.action == "delete":
@@ -258,7 +258,7 @@
         else:
             usage.append(self.size.sectors)
 
-        holes = []
+        holes = list()
         i = 0
         while i < len(usage) - 1:
             # subtract i+1 to get the size of this hole.
@@ -742,14 +742,14 @@
         """
         # the Disk must have a disk_prop.dev_size attribute
         if not hasattr(self.disk_prop, "dev_size"):
-            return []
+            return list()
 
         if not self._children:
             # return a list of the size of the disk
             return[HoleyObject(0, self.disk_prop.dev_size)]
 
         # create a list of sector usage by this disk.
-        usage = []
+        usage = list()
         for child in self._children:
             # skip partitions or slices marked for deletion
             if child.action == "delete":
@@ -779,7 +779,7 @@
         else:
             usage.append(self.disk_prop.dev_size.sectors)
 
-        holes = []
+        holes = list()
         i = 0
         while i < len(usage) - 1:
             # subtract i+1 to get the size of this hole.
@@ -809,11 +809,11 @@
         part_list = self.get_children(class_type=Partition)
 
         for part in part_list:
-            if part.is_extended:
+            if part.is_extended and part.action != "delete":
                 extended_part = part
                 break
         else:
-            return []
+            return list()
 
         # extract all logicial partitions
         logical_list = [p for p in part_list if p.is_logical]
@@ -823,7 +823,7 @@
                                 extended_part.size)]
 
         # create a list of sector usage by the logical partitions
-        usage = []
+        usage = list()
         for logical_part in logical_list:
             usage.append(logical_part.start_sector)
             usage.append(logical_part.start_sector + logical_part.size.sectors)
@@ -842,7 +842,7 @@
             usage.append(extended_part.start_sector + \
                          extended_part.size.sectors)
 
-        holes = []
+        holes = list()
         i = 0
         while i < len(usage) - 1:
             # subtract i+1 to get the size of this hole.
--- a/usr/src/lib/install_target/test/test_shadow_list.py	Fri May 20 15:20:13 2011 -0700
+++ b/usr/src/lib/install_target/test/test_shadow_list.py	Mon May 23 10:49:53 2011 -0600
@@ -1433,6 +1433,26 @@
 
         self.assertTrue(self.target.final_validation())
 
+    def test_simple_with_solaris2_on_logical(self):
+        # insert the smallest required objects:   one disk, one active solaris2
+        # logical partition and one slice with in_zpool set to the root pool
+        # name, one BE under the root pool
+
+        # 30 gb primary partition, 10 gb logical solaris2 partition, and 1 gb
+        # slice
+        primary_part = self.disk1.add_partition(1, 0, 30, Size.gb_units,
+            Partition.name_to_num("Win95 Extended(LBA)"))
+        logical_part = self.disk1.add_partition(5, 0, 10, Size.gb_units)
+        logical_part.add_slice(0, 0, 1, in_zpool="rpool")
+
+        # "rpool" boot pool with one BE
+        zpool = self.logical.add_zpool("rpool", is_root=True)
+        zpool.insert_children(BE())
+
+        self.target.insert_children([self.disk1, self.logical])
+
+        self.assertTrue(self.target.final_validation())
+
     def test_missing_active_solaris2_partition_x86(self):
         if platform.processor() != "i386":
             raise SkipTest("test not supported on sparc")