Logo Search packages:      
Sourcecode: bcfg2 version File versions  Download package

def lib::Client::Tools::PkgTool::Install (   self,
  packages 
)

Run a one-pass install, followed by single pkg installs in case of failure

Reimplemented from lib::Client::Tools::Tool.

Definition at line 180 of file __init__.py.

00180                                :
        '''Run a one-pass install, followed by single pkg installs in case of failure'''
        self.logger.info("Trying single pass package install for pkgtype %s" % \
                         self.pkgtype)

        data = [tuple([pkg.get(field) for field in self.pkgtool[1][1]]) for pkg in packages]
        pkgargs = " ".join([self.pkgtool[1][0] % datum for datum in data])

        self.logger.debug("Installing packages: :%s:" % pkgargs)
        self.logger.debug("Running command ::%s::" % (self.pkgtool[0] % pkgargs))

        cmdrc = self.cmd.run(self.pkgtool[0] % pkgargs)[0]
        if cmdrc == 0:
            self.logger.info("Single Pass Succeded")
            # set all package states to true and flush workqueues
            pkgnames = [pkg.get('name') for pkg in packages]
            for entry in [entry for entry in self.states.keys()
                          if entry.tag == 'Package' and entry.get('type') == self.pkgtype
                          and entry.get('name') in pkgnames]:
                self.logger.debug('Setting state to true for pkg %s' % (entry.get('name')))
                self.states[entry] = True
            self.RefreshPackages()
        else:
            self.logger.error("Single Pass Failed")
            # do single pass installs
            self.RefreshPackages()
            for pkg in packages:
                # handle state tracking updates
                if self.VerifyPackage(pkg, []):
                    self.logger.info("Forcing state to true for pkg %s" % (pkg.get('name')))
                    self.states[pkg] = True
                else:
                    self.logger.info("Installing pkg %s version %s" %
                                     (pkg.get('name'), pkg.get('version')))
                    cmdrc = self.cmd.run(self.pkgtool[0] %
                                         (self.pkgtool[1][0] %
                                          tuple([pkg.get(field) for field in self.pkgtool[1][1]])))
                    if cmdrc[0] == 0:
                        self.states[pkg] = True
                    else:
                        self.logger.error("Failed to install package %s" % (pkg.get('name')))
        for entry in [ent for ent in packages if self.states[ent]]:
            self.modified.append(entry)

    def RefreshPackages(self):


Generated by  Doxygen 1.6.0   Back to index