예제 #1
0
class CertManager:
    """
    An object used to update the certficates, yum repos, and facts for
    the system.

    @ivar certlib: The RHSM I{entitlement} certificate management lib.
    @type certlib: L{CertLib}
    @ivar repolib: The RHSM repository management lib.
    @type repolib: L{RepoLib}
    """

    def __init__(self, lock=ActionLock(), uep=None, product_dir=None):
        self.lock = lock
        self.uep = uep
        self.certlib = CertLib(self.lock, uep=self.uep)
        self.repolib = RepoLib(self.lock, uep=self.uep)
        self.factlib = FactLib(self.lock, uep=self.uep)
        self.profilelib = PackageProfileLib(self.lock, uep=self.uep)
        self.installedprodlib = InstalledProductsLib(self.lock, uep=self.uep)
        #healinglib requires a fact set in order to get socket count
        facts = Facts()
        self.healinglib = HealingLib(self.lock, self.uep, facts.to_dict(),
                                     product_dir)
        self.idcertlib = IdentityCertLib(self.lock, uep=self.uep)

    def update(self, autoheal=False):
        """
        Update I{entitlement} certificates and corresponding
        yum repositiories.
        @return: The number of updates required.
        @rtype: int
        """
        updates = 0
        lock = self.lock
        try:
            lock.acquire()

            # WARNING: order is important here, we need to update a number
            # of things before attempting to autoheal, and we need to autoheal
            # before attempting to fetch our certificates:
            if autoheal:
                libset = [self.healinglib]
            else:
                libset = [self.idcertlib, self.repolib, self.factlib, self.profilelib, self.installedprodlib]

            # WARNING
            # Certlib inherits DataLib as well as the above 'lib' objects,
            # but for some reason it's update method returns a tuple instead
            # of an int:
            ret = []
            try:
                ret = self.certlib.update()
            except Exception, e:
                log.exception(e)
                print e
            # run the certlib update first as it will talk to candlepin,
            # and we can find out if we got deleted or not.
            for lib in libset:
                try:
                    updates += lib.update()
                except Exception, e:
                    log.exception(e)
                    print e
            # NOTE: with no consumer cert, most of these actually
            # fail
            if ret:
                updates += ret[0]
                for e in ret[1]:
                    print ' '.join(str(e).split('-')[1:]).strip()
예제 #2
0
class CertManager:
    """
    An object used to update the certficates, yum repos, and facts for
    the system.

    @ivar certlib: The RHSM I{entitlement} certificate management lib.
    @type certlib: L{CertLib}
    @ivar repolib: The RHSM repository management lib.
    @type repolib: L{RepoLib}
    """
    def __init__(self, lock=ActionLock(), uep=None):
        self.lock = lock
        self.uep = uep
        self.certlib = CertLib(self.lock, uep=self.uep)
        self.repolib = RepoLib(self.lock, uep=self.uep)
        self.factlib = FactLib(self.lock, uep=self.uep)
        self.profilelib = PackageProfileLib(self.lock, uep=self.uep)
        self.installedprodlib = InstalledProductsLib(self.lock, uep=self.uep)
        #healinglib requires a fact set in order to get socket count
        facts = Facts()
        self.healinglib = HealingLib(self.lock,
                                     uep=self.uep,
                                     facts_dict=facts.to_dict())

    def update(self, autoheal=False):
        """
        Update I{entitlement} certificates and corresponding
        yum repositiories.
        @return: The number of updates required.
        @rtype: int
        """
        updates = 0
        lock = self.lock
        try:
            lock.acquire()

            # WARNING: order is important here, we need to update a number
            # of things before attempting to autoheal, and we need to autoheal
            # before attempting to fetch our certificates:
            if autoheal:
                libset = [self.healinglib]
            else:
                libset = [
                    self.repolib, self.factlib, self.profilelib,
                    self.installedprodlib
                ]

            # WARNING
            # Certlib inherits DataLib as well as the above 'lib' objects,
            # but for some reason it's update method returns a tuple instead
            # of an int:
            ret = []
            try:
                ret = self.certlib.update()
            except Exception, e:
                print e
            # run the certlib update first as it will talk to candlepin,
            # and we can find out if we got deleted or not.
            for lib in libset:
                updates += lib.update()

            # NOTE: with no consumer cert, most of these actually
            # fail
            if ret:
                updates += ret[0]
                for e in ret[1]:
                    print ' '.join(str(e).split('-')[1:]).strip()
        finally:
예제 #3
0
class CertManager:
    """
    An object used to update the certficates, yum repos, and facts for
    the system.

    @ivar certlib: The RHSM I{entitlement} certificate management lib.
    @type certlib: L{CertLib}
    @ivar repolib: The RHSM repository management lib.
    @type repolib: L{RepoLib}
    """

    def __init__(self, lock=ActionLock(), uep=None, product_dir=None,
            facts=None):
        self.lock = lock
        self.uep = uep
        self.certlib = CertLib(self.lock, uep=self.uep)
        self.repolib = RepoLib(self.lock, uep=self.uep)
        self.factlib = FactLib(self.lock, uep=self.uep, facts=facts)
        self.profilelib = PackageProfileLib(self.lock, uep=self.uep)
        self.installedprodlib = InstalledProductsLib(self.lock, uep=self.uep)
        #healinglib requires a fact set in order to get socket count
        self.healinglib = HealingLib(self.lock, self.uep, product_dir)
        self.idcertlib = IdentityCertLib(self.lock, uep=self.uep)

    def update(self, autoheal=False):
        """
        Update I{entitlement} certificates and corresponding
        yum repositiories.
        @return: The number of updates required.
        @rtype: int
        """
        updates = 0
        lock = self.lock
        try:
            lock.acquire()

            # WARNING: order is important here, we need to update a number
            # of things before attempting to autoheal, and we need to autoheal
            # before attempting to fetch our certificates:
            if autoheal:
                libset = [self.installedprodlib, self.healinglib]
            else:
                libset = [self.idcertlib, self.repolib, self.factlib, self.profilelib, self.installedprodlib]

            # WARNING
            # Certlib inherits DataLib as well as the above 'lib' objects,
            # but for some reason it's update method returns a tuple instead
            # of an int:
            ret = []
            try:
                ret = self.certlib.update()
            # see bz#852706, reraise GoneException so that
            # consumer cert deletion works
            except GoneException, e:
                raise
            # raise this so it can be exposed clearly
            except ExpiredIdentityCertException, e:
                raise
            except Exception, e:
                log.warning("Exception caught while running certlib update")
                log.exception(e)
예제 #4
0
class CertManager:
    """
    An object used to update the certficates, yum repos, and facts for
    the system.

    @ivar certlib: The RHSM I{entitlement} certificate management lib.
    @type certlib: L{CertLib}
    @ivar repolib: The RHSM repository management lib.
    @type repolib: L{RepoLib}
    """
    def __init__(self,
                 lock=ActionLock(),
                 uep=None,
                 product_dir=None,
                 facts=None):
        self.lock = lock
        self.uep = uep
        self.certlib = CertLib(self.lock, uep=self.uep)
        self.repolib = RepoLib(self.lock, uep=self.uep)
        self.factlib = FactLib(self.lock, uep=self.uep, facts=facts)
        self.profilelib = PackageProfileLib(self.lock, uep=self.uep)
        self.installedprodlib = InstalledProductsLib(self.lock, uep=self.uep)
        #healinglib requires a fact set in order to get socket count
        self.healinglib = HealingLib(self.lock, self.uep, product_dir)
        self.idcertlib = IdentityCertLib(self.lock, uep=self.uep)

    def update(self, autoheal=False):
        """
        Update I{entitlement} certificates and corresponding
        yum repositiories.
        @return: The number of updates required.
        @rtype: int
        """
        updates = 0
        lock = self.lock
        try:
            lock.acquire()

            # WARNING: order is important here, we need to update a number
            # of things before attempting to autoheal, and we need to autoheal
            # before attempting to fetch our certificates:
            if autoheal:
                libset = [self.installedprodlib, self.healinglib]
            else:
                libset = [
                    self.idcertlib, self.repolib, self.factlib,
                    self.profilelib, self.installedprodlib
                ]

            # WARNING
            # Certlib inherits DataLib as well as the above 'lib' objects,
            # but for some reason it's update method returns a tuple instead
            # of an int:
            ret = []
            try:
                ret = self.certlib.update()
            # see bz#852706, reraise GoneException so that
            # consumer cert deletion works
            except GoneException, e:
                raise
            # raise this so it can be exposed clearly
            except ExpiredIdentityCertException, e:
                raise
            except Exception, e:
                log.warning("Exception caught while running certlib update")
                log.exception(e)