7040795 install fails with setting preferred publisher errors after fix for 7039499 is integrated Build165
authorDrew Fisher <drew.fisher@oracle.com>
Sun, 01 May 2011 16:36:24 -0700
changeset 1101 30df8e9b5f27
parent 1100 e14505a13f61
child 1102 88b76230ad5e
7040795 install fails with setting preferred publisher errors after fix for 7039499 is integrated 7040909 install set the wrong default publisher after fix for 7039499 is integrated for all installs.
usr/src/lib/install_transfer/ips.py
usr/src/lib/libict_pymod/ict.py
--- a/usr/src/lib/install_transfer/ips.py	Fri Apr 29 16:21:12 2011 -0700
+++ b/usr/src/lib/install_transfer/ips.py	Sun May 01 16:36:24 2011 -0700
@@ -317,11 +317,13 @@
             self.set_image_args()
 
     def _transfer(self):
-        '''If an update of the image has been specified, the preferred
-           publisher is set, all other publishers are removed, and the new
-           additional publishers are added. Then properties are set, if
-           specified and the transfer specific operations of install, uninstall
-           and purge history are performed.
+        '''If an update of the image has been specified, the publishers of the
+           existing image are examined.  If a matching publisher is found, the
+           origins and mirrors (if present) are reset to the desired entries.
+           All other publishers in the image are removed and the new additional
+           publishers are added.  Then properties are set, if specified and the
+           transfer specific operations of install, uninstall and purge history
+           are performed.
            If creation of the image has been specified, the additional
            publishers are added to the image, properties are set and the
            transfer specific operations of install, uninstall and purge history
@@ -341,47 +343,39 @@
 
             self.logger.info("Setting post-install publishers to:")
             self.print_repository_uris()
-            # Look for the preferred publisher (_publ) in pub_list.
-            # If it is found, set the preferred publisher to _publ and break.
-            for pub in pub_list:
-                # If the new preferred publisher was already listed
-                # as a publisher, bump it to preferred and reset
-                # the origins and mirrors to those specified.
-                if pub == self._publ:
-                    self.logger.debug("Updating the preferred publisher, %s",
-                                      str(self._publ))
-                    repo = pub.repository
-                    repo.reset_origins()
-                    for origin in self._origin:
-                        repo.add_origin(origin)
-                    if self._mirror:
-                        for mirror in self._mirror:
-                            repo.add_mirror(mirror)
-                    self.api_inst.update_publisher(pub=pub,
-                                                   refresh_allowed=False)
-                    break
 
-            # If the preferred publisher was not found, then it is added
-            # to the image.
-            if pub != self._publ:
-                # The new preferred publisher needs to be added since
-                # it wasn't one of our publishers previously.
-                self.logger.debug("Updating the preferred publisher: %s",
-                                  str(self._publ))
+            # Look to see if the publisher in _publ is already in the Image
+            if self.api_inst.has_publisher(prefix=self._publ):
+                # update the publisher
+                pub = self.api_inst.get_publisher(prefix=self._publ,
+                                                  duplicate=True)
+                self.logger.debug("Updating publisher information for " \
+                                  "%s" % str(self._publ))
+                repository = pub.repository
+                repository.reset_origins()
+                repository.reset_mirrors()
+                for origin in self._origin:
+                    repository.add_origin(origin)
+                if self._mirror is not None:
+                    for mirror in self._mirror:
+                        repository.add_mirror(mirror)
+                self.api_inst.update_publisher(pub=pub, refresh_allowed=False,
+                                               search_first=True)
+            else:
+                # create a new publisher and set it to the highest ranked
+                # publisher
                 if self._mirror:
                     repo = publisher.Repository(mirrors=self._mirror,
                                                 origins=self._origin)
                 else:
                     repo = publisher.Repository(origins=self._origin)
                 pub = publisher.Publisher(prefix=self._publ, repository=repo)
-                self.api_inst.add_publisher(pub=pub, refresh_allowed=False)
-                self.api_inst.set_highest_ranked_publisher(prefix=self._publ)
+                self.api_inst.add_publisher(pub=pub, refresh_allowed=False,
+                                            search_first=True)
 
-            self.check_cancel_event()
-            # Now we can remove all but the preferred publisher.
-            pub_list = self.api_inst.get_publishers(duplicate=True)
-
-            for pub in pub_list[1:]:
+            # the highest ranking publisher has been set.  Walk the other
+            # publishers in the list and remove them.
+            for pub in self.api_inst.get_publishers(duplicate=True)[1:]:
                 self.api_inst.remove_publisher(prefix=pub.prefix)
 
         # Add specified publishers/origins/mirrors to the image.
--- a/usr/src/lib/libict_pymod/ict.py	Fri Apr 29 16:21:12 2011 -0700
+++ b/usr/src/lib/libict_pymod/ict.py	Sun May 01 16:36:24 2011 -0700
@@ -2055,8 +2055,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>
@@ -2066,34 +2066,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)