Fix preferred publisher install errors oi_151a
authorJon Tibble <meths@btinternet.com>
Tue, 26 Jun 2012 14:11:05 +0100
branchoi_151a
changeset 1447 f7571d01f887
parent 1446 280969bf3321
child 1448 820ea18f3c75
Fix preferred publisher install errors
usr/src/lib/libict_pymod/ict.py
--- a/usr/src/lib/libict_pymod/ict.py	Wed May 30 14:07:38 2012 +0100
+++ b/usr/src/lib/libict_pymod/ict.py	Tue Jun 26 14:11:05 2012 +0100
@@ -2232,8 +2232,8 @@
     def reset_image_uuid(self):
         '''ICT - reset pkg(1) image UUID for preferred publisher
 
-        Obtain name of preferred publisher by parsing output of following
-        command: pkg -R basedir property -H preferred-publisher
+        Obtain name of all publishers by parsing output of the following
+        command: pkg -R basedir property -H publisher-search-order
 
         launch pkg -R basedir set-publisher --reset-uuid --no-refresh \
             <preferred_publisher>
@@ -2243,34 +2243,30 @@
         return 0 for success, otherwise error code
         '''
         _register_task(inspect.currentframe())
-        cmd = '/usr/bin/pkg -R ' + self.basedir + \
-            ' property -H preferred-publisher'
+        cmd = '/usr/bin/pkg -R ' + self.basedir + ' property -H ' + \
+            'publisher-search-order'
         status, co = _cmd_out(cmd)
         if status != 0:
-            prerror('pkg(1) failed to obtain name of preferred publisher - '
+            prerror('pkg(1) failed to obtain list of publishers - '
                     'exit status = ' + str(status) + ', command was ' + cmd)
             prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
             return ICT_PKG_RESET_UUID_FAILED
 
-        try:
-            preferred_publisher = co[0].split()[1]
-
-        except IndexError:
-            prerror('Could not determine name of preferred publisher from '
-                    'following input : ' + repr(co))
-            prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
-            return ICT_PKG_RESET_UUID_FAILED
+        publisher_search_order = co[0].strip().split(None, 1)
+        # strip off the leading '[' and trailing ']' characters
+        for publisher in publisher_search_order[1:-1]:
+            # strip off any ' or , characters
+            publisher = publisher.strip("',")
 
-        _dbg_msg('Preferred publisher: ' + preferred_publisher)
-
-        cmd = 'pkg -R ' + self.basedir + \
-            ' set-publisher --reset-uuid --no-refresh ' + preferred_publisher
-        status = _cmd_status(cmd)
-        if status != 0:
-            prerror('Reset uuid failed - exit status = ' + str(status) +
-                ', command was ' + cmd)
-            prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
-            return ICT_PKG_RESET_UUID_FAILED
+            cmd = 'pkg -R ' + self.basedir + \
+                ' set-publisher --reset-uuid --no-refresh ' + publisher
+            status = _cmd_status(cmd)
+            if status != 0:
+                prerror('Reset uuid failed for publisher:  ' + publisher +
+                        '- exit status = ' + str(status) +
+                        ', command was ' + cmd)
+                prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
+                return ICT_PKG_RESET_UUID_FAILED
 
         cmd = 'pkg -R ' + self.basedir + ' set-property send-uuid True'
         status = _cmd_status(cmd)