7066493 Target Selection failing on system with CRO output, but no CRO disks.
authorDarren Kenny <Darren.Kenny@Oracle.COM>
Wed, 13 Jul 2011 06:22:25 -0700
changeset 1275 a1022e164e5e
parent 1274 257bd997a06e
child 1276 663decbf8cb1
7066493 Target Selection failing on system with CRO output, but no CRO disks.
usr/src/lib/install_target/__init__.py
usr/src/lib/install_target/discovery.py
--- a/usr/src/lib/install_target/__init__.py	Wed Jul 13 05:41:17 2011 -0700
+++ b/usr/src/lib/install_target/__init__.py	Wed Jul 13 06:22:25 2011 -0700
@@ -202,8 +202,10 @@
 
         # compare the first element of the croinfo tuple (the position)
         def compare(x, y):
-            if isinstance(x, physical.Disk) and isinstance(y, physical.Disk):
+            if isinstance(x, physical.Disk) and isinstance(y, physical.Disk) \
+               and x.ctd in cro_dict and y.ctd in cro_dict:
                 return cmp(cro_dict[x.ctd][0], cro_dict[y.ctd][0])
+            return 0  # Default is to maintain location as-is
 
         # sort the children by croinfo order
         return sorted(unsorted_children, cmp=compare)
--- a/usr/src/lib/install_target/discovery.py	Wed Jul 13 05:41:17 2011 -0700
+++ b/usr/src/lib/install_target/discovery.py	Wed Jul 13 06:22:25 2011 -0700
@@ -745,8 +745,11 @@
             self.cro_dict[ctd] = (i, alias or None, receptacle)
             i += 1
 
-        self.doc.persistent.insert_children(
-            DataObjectDict(CRO_LABEL, self.cro_dict, generate_xml=True))
+        if self.cro_dict:
+            # Only insert if there is something in it
+            self.doc.persistent.insert_children(
+                DataObjectDict(CRO_LABEL, self.cro_dict, 
+                               generate_xml=True))
 
     def execute(self, dry_run=False):
         """ primary execution checkpoint for Target Discovery