7080223 AI over zealous in software packages validation
authorMatt Keenan <matt.keenan@oracle.com>
Mon, 22 Aug 2011 17:13:35 +0100
changeset 1411 d41bda7a63f8
parent 1410 6d2cdddef951
child 1412 36eed4eb1342
7080223 AI over zealous in software packages validation
usr/src/cmd/auto-install/auto_install.py
usr/src/cmd/auto-install/test/test_target_selection_x86_cro.py
--- a/usr/src/cmd/auto-install/auto_install.py	Mon Aug 22 08:10:27 2011 -0700
+++ b/usr/src/cmd/auto-install/auto_install.py	Mon Aug 22 17:13:35 2011 +0100
@@ -76,7 +76,7 @@
 from solaris_install.target.logical import BE, Logical
 from solaris_install.transfer import create_checkpoint
 from solaris_install.transfer.info import Software, Source, Destination, \
-    Image, ImType, Dir, INSTALL, IPSSpec, CPIOSpec, SVR4Spec
+    Image, ImType, Dir, INSTALL, IPSSpec, CPIOSpec, SVR4Spec, P5ISpec
 from solaris_install.transfer.ips import AbstractIPS
 
 ZPOOL = "/usr/sbin/zpool"
@@ -942,6 +942,11 @@
 
             image_action = AbstractIPS.CREATE  # For first IPS only
             transfer_count = 0  # For generating names if none provided
+            # Ensure there is at least one software_data element with
+            # Install action exists, and that all software_data elements
+            # contain at least one 'name' sub element. Only one sw_data
+            # element across all Software nodes is required.
+            found_install_sw_data = False
             for sw in sw_nodes:
                 transfer_count += 1
                 if sw.name is None or len(sw.name) == 0:
@@ -958,10 +963,6 @@
                             self.FIRST_TRANSFER_CHECKPOINT:
                             self.options.stop_checkpoint = sw.name
 
-                # Ensure there is at least one software_data element with
-                # Install action exists, and that all software_data elements
-                # contain at least one 'name' sub element.
-                found_install_sw_data = False
                 tran_type = sw.tran_type.upper()
                 for sw_child in sw.children:
                     found_sw_data = False
@@ -979,6 +980,11 @@
                         found_sw_data = True
                         if sw_child.action == SVR4Spec.INSTALL:
                             found_install_sw_data = True
+                    elif tran_type == "P5I" and \
+                        isinstance(sw_child, P5ISpec):
+                        found_sw_data = True
+                        if sw_child.action == P5ISpec.INSTALL:
+                            found_install_sw_data = True
                     elif isinstance(sw_child, Source) or \
                          isinstance(sw_child, Destination):
                         # Skip these
@@ -994,12 +1000,6 @@
                             "least one package to install/uninstall.")
                         return False
 
-                if not found_install_sw_data:
-                    self.logger.error("No packages specified to install. "
-                        "Manifest must contain at least one <software_data> "
-                        "element with 'install' action.")
-                    return False
-
                 self.logger.debug("Setting destination for transfer: %s to %s"
                     % (sw.name, self.installed_root_dir))
 
@@ -1064,6 +1064,13 @@
                         % (sw.name))
                     return False
 
+            # Ensure at least one software_data exists with packages to install
+            if not found_install_sw_data:
+                self.logger.error("No packages specified to install. "
+                    "Manifest must contain at least one <software_data> "
+                    "element with 'install' action.")
+                return False
+
             # Register ICT Checkpoints
             #=========================
             # 1. Initialize SMF Repository
--- a/usr/src/cmd/auto-install/test/test_target_selection_x86_cro.py	Mon Aug 22 08:10:27 2011 -0700
+++ b/usr/src/cmd/auto-install/test/test_target_selection_x86_cro.py	Mon Aug 22 17:13:35 2011 +0100
@@ -316,7 +316,7 @@
         dev_size="143364060secs"/>
         ....<disk_keyword key="boot_disk"/>
         ....<partition action="create" name="1" part_type="191">
-        ......<size val="143363548secs" start_sector="512"/>
+        ......<size val="143363072secs" start_sector="512"/>
         ......<slice name="0" action="create" force="true" is_swap="false" \
         in_zpool="myrpool" in_vdev="vdev">
         ........<size val="143361536secs" start_sector="512"/>