def update(conduit):
    """ update entitlement certificates """
    if os.getuid() != 0:
        conduit.info(3, "Not root, Subscription Management repositories not updated")
        return
    conduit.info(3, "Updating Subscription Management repositories.")

    # XXX: Importing inline as you must be root to read the config file
    from subscription_manager.certlib import ConsumerIdentity

    cert_file = ConsumerIdentity.certpath()
    key_file = ConsumerIdentity.keypath()

    try:
        ConsumerIdentity.read().getConsumerId()
    except Exception:
        conduit.info(3, "Unable to read consumer identity")
        return

    try:
        uep = connection.UEPConnection(cert_file=cert_file, key_file=key_file)
    # FIXME: catchall exception
    except Exception:
        # log
        conduit.info(2, "Unable to connect to Subscription Management Service")
        return

    rl = RepoLib(uep=uep)
    rl.update()
Exemple #2
0
def update(conduit):
    """ update entitlement certificates """
    if os.getuid() != 0:
        conduit.info(
            3, 'Not root, Subscription Management repositories not updated')
        return
    conduit.info(3, 'Updating Subscription Management repositories.')

    # XXX: Importing inline as you must be root to read the config file
    from subscription_manager.certlib import ConsumerIdentity

    cert_file = ConsumerIdentity.certpath()
    key_file = ConsumerIdentity.keypath()

    try:
        ConsumerIdentity.read().getConsumerId()
    except Exception:
        conduit.info(3, "Unable to read consumer identity")
        return

    try:
        uep = connection.UEPConnection(cert_file=cert_file, key_file=key_file)
    #FIXME: catchall exception
    except Exception:
        # log
        conduit.info(2, "Unable to connect to Subscription Management Service")
        return

    rl = RepoLib(uep=uep)
    rl.update()
def clean_all_data(backup=True):
    consumer_dir = cfg.get('rhsm', 'consumerCertDir')
    if backup:
        if consumer_dir[-1] == "/":
            consumer_dir_backup = consumer_dir[0:-1] + ".old"
        else:
            consumer_dir_backup = consumer_dir + ".old"

        shutil.rmtree(consumer_dir_backup, ignore_errors=True)
        os.rename(consumer_dir, consumer_dir_backup)
    else:
        shutil.rmtree(consumer_dir, ignore_errors=True)

    shutil.rmtree(cfg.get('rhsm', 'entitlementCertDir'), ignore_errors=True)

    ProfileManager.delete_cache()
    InstalledProductsManager.delete_cache()
    Facts.delete_cache()
    RepoLib.delete_repo_file()
    log.info("Cleaned local data")
Exemple #4
0
def clean_all_data(backup=True):
    consumer_dir = cfg.get('rhsm', 'consumerCertDir')
    if backup:
        if consumer_dir[-1] == "/":
            consumer_dir_backup = consumer_dir[0:-1] + ".old"
        else:
            consumer_dir_backup = consumer_dir + ".old"

        shutil.rmtree(consumer_dir_backup, ignore_errors=True)
        os.rename(consumer_dir, consumer_dir_backup)
    else:
        shutil.rmtree(consumer_dir, ignore_errors=True)

    shutil.rmtree(cfg.get('rhsm', 'entitlementCertDir'), ignore_errors=True)

    ProfileManager.delete_cache()
    InstalledProductsManager.delete_cache()
    Facts.delete_cache()
    RepoLib.delete_repo_file()
    log.info("Cleaned local data")
def update(conduit):
    """ update entitlement certificates """
    if os.getuid() != 0:
        conduit.info(3, 'Not root, Subscription Management repositories not updated')
        return
    conduit.info(3, 'Updating Subscription Management repositories.')

    # XXX: Importing inline as you must be root to read the config file
    from subscription_manager.certlib import ConsumerIdentity

    cert_file = ConsumerIdentity.certpath()
    key_file = ConsumerIdentity.keypath()

    # if we have a RHIC, it's ok to call RepoLib without a ConsumerId or UEP
    if RhicCertificate.existsAndValid():
        rl = RepoLib()
        rl.update()
        return

    try:
        ConsumerIdentity.read().getConsumerId()
    except Exception:
        conduit.info(3, "Unable to read consumer identity")
        return

    try:
        uep = connection.UEPConnection(cert_file=cert_file, key_file=key_file)
    #FIXME: catchall exception
    except Exception:
        # log
        conduit.info(2, "Unable to connect to Subscription Management Service")
        return

    rl = RepoLib(uep=uep)
    rl.update()
 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 __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)