当前位置: 首页>>代码示例>>Python>>正文


Python ConsumerIdentity.read方法代码示例

本文整理汇总了Python中subscription_manager.certlib.ConsumerIdentity.read方法的典型用法代码示例。如果您正苦于以下问题:Python ConsumerIdentity.read方法的具体用法?Python ConsumerIdentity.read怎么用?Python ConsumerIdentity.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subscription_manager.certlib.ConsumerIdentity的用法示例。


在下文中一共展示了ConsumerIdentity.read方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
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()
开发者ID:splice,项目名称:subscription-manager,代码行数:37,代码来源:subscription-manager.py

示例2: update

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
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()
开发者ID:beav,项目名称:subscription-manager,代码行数:31,代码来源:subscription-manager.py

示例3: _do_update

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
 def _do_update(self):
     mgr = InstalledProductsManager()
     try:
         consumer = ConsumerIdentity.read()
     except IOError:
         return 0
     consumer_uuid = consumer.getConsumerId()
     return mgr.update_check(self.uep, consumer_uuid)
开发者ID:bkearney,项目名称:subscription-manager,代码行数:10,代码来源:cache.py

示例4: consumer_id

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
 def consumer_id(self):
     """
     Get the current consumer ID
     :return: The unique consumer ID of the currently running agent
     :rtype:  str
     """
     certificate = ConsumerIdentity.read()
     return certificate.getConsumerId()
开发者ID:bbuckingham,项目名称:katello-agent,代码行数:10,代码来源:katelloplugin.py

示例5: warnOrGiveUsageMessage

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
def warnOrGiveUsageMessage(conduit):
    """ either output a warning, or a usage message """
    msg = ""
    # TODO: refactor so there are not two checks for this
    if os.getuid() != 0:
        return
    try:
        try:
            ConsumerIdentity.read().getConsumerId()
            entdir = EntitlementDirectory()
            if len(entdir.listValid()) == 0:
                msg = no_subs_warning
            else:
                msg = repo_usage_message
        except:
            msg = not_registered_warning
    finally:
        conduit.info(2, msg)
开发者ID:bkearney,项目名称:subscription-manager,代码行数:20,代码来源:subscription-manager.py

示例6: reload

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
 def reload(self):
     """
     Check for consumer certificate on disk and update our info accordingly.
     """
     log.debug("Loading consumer info from identity certificates.")
     if not ConsumerIdentity.existsAndValid():
         self.name = None
         self.uuid = None
     else:
         consumer = ConsumerIdentity.read()
         self.name = consumer.getConsumerName()
         self.uuid = consumer.getConsumerId()
开发者ID:bkearney,项目名称:subscription-manager,代码行数:14,代码来源:managergui.py

示例7: setup_plugin

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
def setup_plugin():
    """
    Setup the plugin based on registration status using the RHSM configuration.
    """
    if not ConsumerIdentity.existsAndValid():
        # not registered
        return
    cfg = plugin.cfg()
    rhsm_conf = Config(RHSM_CONFIG_PATH)
    certificate = ConsumerIdentity.read()
    cfg.messaging.url = 'ssl://%s:5671' % rhsm_conf['server']['hostname']
    cfg.messaging.uuid = 'pulp.agent.%s' % certificate.getConsumerId()
    bundle(certificate)
开发者ID:bbuckingham,项目名称:katello-agent,代码行数:15,代码来源:katelloplugin.py

示例8: warnOrGiveUsageMessage

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
def warnOrGiveUsageMessage(conduit):

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

    """ either output a warning, or a usage message """
    msg = ""
    # TODO: refactor so there are not two checks for this
    if os.getuid() != 0:
        return
    try:
        try:
            ConsumerIdentity.read().getConsumerId()
            entdir = EntitlementDirectory()
            if len(entdir.listValid()) == 0:
                msg = no_subs_warning
            else:
                msg = registered_message
        except:
            msg = not_registered_warning
    finally:
        conduit.info(2, msg)
开发者ID:splice,项目名称:subscription-manager,代码行数:24,代码来源:subscription-manager.py

示例9: reload

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
 def reload(self):
     """
     Check for consumer certificate on disk and update our info accordingly.
     """
     log.debug("Loading consumer info from identity certificates.")
     try:
         consumer = ConsumerIdentity.read()
         self.name = consumer.getConsumerName()
         self.uuid = consumer.getConsumerId()
     # XXX shouldn't catch the global exception here, but that's what
     # existsAndValid did, so this is better.
     except Exception:
         self.name = None
         self.uuid = None
开发者ID:splice,项目名称:subscription-manager,代码行数:16,代码来源:managergui.py

示例10: send_enabled_report

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
def send_enabled_report(path=REPOSITORY_PATH):
    """
    Send the enabled repository report.
    :param path: The path to a repository file.
    :type path: str
    """
    if not ConsumerIdentity.existsAndValid():
        # not registered
        return
    try:
        uep = UEP()
        certificate = ConsumerIdentity.read()
        report = EnabledReport(path)
        uep.report_enabled(certificate.getConsumerId(), report.content)
    except Exception, e:
        log.error('send enabled report failed: %s', str(e))
开发者ID:bbuckingham,项目名称:katello-agent,代码行数:18,代码来源:katelloplugin.py

示例11: changed

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
 def changed(cls, path):
     """
     A change in the rhsm certificate has been detected.
     When deleted: disconnect from qpid.
     When added/updated: reconnect to qpid.
     @param path: The changed file (ignored).
     @type path: str
     """
     log.info('changed: %s', path)
     if ConsumerIdentity.existsAndValid():
         cert = ConsumerIdentity.read()
         cls.bundle(cert)
         uuid = cert.getConsumerId()
         plugin.setuuid(uuid)
     else:
         plugin.setuuid(None)
开发者ID:AdamSaleh,项目名称:katello,代码行数:18,代码来源:katelloplugin.py

示例12: main

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
def main(options, log):
    if not ConsumerIdentity.existsAndValid():
        log.error('Either the consumer is not registered or the certificates' +
                  ' are corrupted. Certificate update using daemon failed.')
        sys.exit(-1)
    print _('Updating entitlement certificates & repositories')

    try:
        uep = connection.UEPConnection(cert_file=ConsumerIdentity.certpath(),
                                       key_file=ConsumerIdentity.keypath())
        mgr = certmgr.CertManager(uep=uep)
        updates = mgr.update(options.autoheal)

        print _('%d updates required') % updates
        print _('done')
    except connection.GoneException, ge:
        uuid = ConsumerIdentity.read().getConsumerId()
        if ge.deleted_id == uuid:
            log.critical(_("This consumer's profile has been deleted from the server. It's local certificates will now be archived"))
            managerlib.clean_all_data()
            log.critical(_("Certificates archived to '/etc/pki/consumer.old'. Contact your system administrator if you need more information."))
        else:
            raise ge
开发者ID:bkearney,项目名称:subscription-manager,代码行数:25,代码来源:rhsmcertd-worker.py

示例13: _

# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import read [as 别名]
        sys.exit(-1)
    print _('Updating entitlement certificates & repositories')

    try:
        uep = connection.UEPConnection(cert_file=ConsumerIdentity.certpath(),
                                       key_file=ConsumerIdentity.keypath())
        mgr = certmgr.CertManager(uep=uep)
        updates = mgr.update(options.autoheal)

        print _('%d updates required') % updates
        print _('done')
    except connection.ExpiredIdentityCertException, e:
        log.critical(_("Your identity certificate has expired"))
        raise e
    except connection.GoneException, ge:
        uuid = ConsumerIdentity.read().getConsumerId()
        if ge.deleted_id == uuid:
            log.critical(_("This consumer's profile has been deleted from the server. Its local certificates will now be archived"))
            managerlib.clean_all_data()
            log.critical(_("Certificates archived to '/etc/pki/consumer.old'. Contact your system administrator if you need more information."))

        raise ge


if __name__ == '__main__':

    logutil.init_logger()
    log = logging.getLogger('rhsm-app.' + __name__)

    parser = OptionParser(usage=USAGE,
                          formatter=WrappedIndentedHelpFormatter())
开发者ID:tkolhar,项目名称:subscription-manager,代码行数:33,代码来源:rhsmcertd-worker.py


注:本文中的subscription_manager.certlib.ConsumerIdentity.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。