• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python certlib.ConsumerIdentity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: update

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,代码行数:35,代码来源:subscription-manager.py


示例2: update

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,代码行数:29,代码来源:subscription-manager.py


示例3: reload

 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,代码行数:12,代码来源:managergui.py


示例4: setup_plugin

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,代码行数:13,代码来源:katelloplugin.py


示例5: send_enabled_report

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,代码行数:16,代码来源:katelloplugin.py


示例6: changed

 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,代码行数:16,代码来源:katelloplugin.py


示例7: check_status

def check_status(force_signal):

    if force_signal is not None:
        debug("forcing status signal from cli arg")
        return force_signal

    if ClassicCheck().is_registered_with_classic():
        debug("System is already registered to another entitlement system")
        return RHN_CLASSIC

    if not ConsumerIdentity.existsAndValid():
        debug("The system is not currently registered.")
        return RHSM_REGISTRATION_REQUIRED

    facts = Facts()
    sorter = CertSorter(certdirectory.ProductDirectory(),
            certdirectory.EntitlementDirectory(), facts.get_facts())

    if len(sorter.unentitled_products.keys()) > 0 or len(sorter.expired_products.keys()) > 0:
        debug("System has one or more certificates that are not valid")
        debug(sorter.unentitled_products.keys())
        debug(sorter.expired_products.keys())
        return RHSM_EXPIRED
    elif len(sorter.partially_valid_products) > 0:
        debug("System has one or more partially entitled products")
        return RHSM_PARTIALLY_VALID
    elif in_warning_period(sorter):
        debug("System has one or more entitlements in their warning period")
        return RHSM_WARNING
    else:
        debug("System entitlements appear valid")
        return RHSM_VALID
开发者ID:beav,项目名称:subscription-manager,代码行数:32,代码来源:rhsm_d.py


示例8: shouldAppear

 def shouldAppear(self):
     """
     Indicates to firstboot whether to show this screen.  In this case
     we want to skip over this screen if there is already an identity
     certificate on the machine (most likely laid down in a kickstart).
     """
     return not ConsumerIdentity.existsAndValid()
开发者ID:beav,项目名称:subscription-manager,代码行数:7,代码来源:firstboot_base.py


示例9: consumer_id

 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,代码行数:8,代码来源:katelloplugin.py


示例10: init

 def init(cls):
     """
     Start path monitor to track changes in the
     rhsm identity certificate.
     """
     path = ConsumerIdentity.certpath()
     cls.pmon.add(path, cls.changed)
     cls.pmon.start()
开发者ID:AdamSaleh,项目名称:katello,代码行数:8,代码来源:katelloplugin.py


示例11: __init__

    def __init__(self):
        self.create_uep(cert_file=ConsumerIdentity.certpath(),
                        key_file=ConsumerIdentity.keypath())

        self.create_content_connection()
        # we don't know the user/pass yet, so no point in
        # creating an admin uep till we need it
        self.admin_uep = None

        self.product_dir = ProductDirectory()
        self.entitlement_dir = EntitlementDirectory()
        self.certlib = CertLib(uep=self.uep)

        self.product_monitor = file_monitor.Monitor(self.product_dir.path)
        self.entitlement_monitor = file_monitor.Monitor(
                self.entitlement_dir.path)
        self.identity_monitor = file_monitor.Monitor(ConsumerIdentity.PATH)
开发者ID:bkearney,项目名称:subscription-manager,代码行数:17,代码来源:managergui.py


示例12: _do_update

 def _do_update(self):
     profile_mgr = ProfileManager()
     try:
         consumer = ConsumerIdentity.read()
     except IOError:
         return 0
     consumer_uuid = consumer.getConsumerId()
     return profile_mgr.update_check(self.uep, consumer_uuid)
开发者ID:bkearney,项目名称:subscription-manager,代码行数:8,代码来源:cache.py


示例13: main

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.ExpiredIdentityCertException, e:
        log.critical(_("Your identity certificate has expired"))
        raise e
开发者ID:tkolhar,项目名称:subscription-manager,代码行数:18,代码来源:rhsmcertd-worker.py


示例14: warnOrGiveUsageMessage

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,代码行数:18,代码来源:subscription-manager.py


示例15: __init__

    def __init__(self):
        self.create_uep(cert_file=ConsumerIdentity.certpath(), key_file=ConsumerIdentity.keypath())

        self.create_content_connection()
        # we don't know the user/pass yet, so no point in
        # creating an admin uep till we need it
        self.admin_uep = None

        self.product_dir = ProductDirectory()
        self.entitlement_dir = EntitlementDirectory()
        self.certlib = CertLib(uep=self.uep)

        self.product_monitor = file_monitor.Monitor(self.product_dir.path)
        self.entitlement_monitor = file_monitor.Monitor(self.entitlement_dir.path)
        self.identity_monitor = file_monitor.Monitor(ConsumerIdentity.PATH)

        # connect handlers to refresh the cached data when we notice a change.
        # do this before any other handlers might connect
        self.product_monitor.connect("changed", lambda monitor: self.product_dir.refresh())
        self.entitlement_monitor.connect("changed", lambda monitor: self.entitlement_dir.refresh())
开发者ID:splice,项目名称:subscription-manager,代码行数:20,代码来源:managergui.py


示例16: _read_rhn_proxy_settings

    def _read_rhn_proxy_settings(self):
        # Read and store rhn-setup's proxy settings, as they have been set
        # on the prior screen (which is owned by rhn-setup)
        up2date_cfg = config.initUp2dateConfig()
        cfg = rhsm.config.initConfig()

        if up2date_cfg['enableProxy']:
            proxy = up2date_cfg['httpProxy']
            if proxy:
                # Remove any URI scheme provided
                proxy = remove_scheme(proxy)
                try:
                    host, port = proxy.split(':')
                    cfg.set('server', 'proxy_hostname', host)
                    cfg.set('server', 'proxy_port', port)
                except ValueError:
                    cfg.set('server', 'proxy_hostname', proxy)
                    cfg.set('server', 'proxy_port',
                            rhsm.config.DEFAULT_PROXY_PORT)
            if up2date_cfg['enableProxyAuth']:
                cfg.set('server', 'proxy_user', up2date_cfg['proxyUser'])
                cfg.set('server', 'proxy_password',
                        up2date_cfg['proxyPassword'])
        else:
            cfg.set('server', 'proxy_hostname', '')
            cfg.set('server', 'proxy_port', '')
            cfg.set('server', 'proxy_user', '')
            cfg.set('server', 'proxy_password', '')

        cfg.save()
        self.backend.uep = rhsm.connection.UEPConnection(
            host=cfg.get('server', 'hostname'),
            ssl_port=int(cfg.get('server', 'port')),
            handler=cfg.get('server', 'prefix'),
            proxy_hostname=cfg.get('server', 'proxy_hostname'),
            proxy_port=cfg.get('server', 'proxy_port'),
            proxy_user=cfg.get('server', 'proxy_user'),
            proxy_password=cfg.get('server', 'proxy_password'),
            username=None, password=None,
            cert_file=ConsumerIdentity.certpath(),
            key_file=ConsumerIdentity.keypath())
开发者ID:bkearney,项目名称:subscription-manager,代码行数:41,代码来源:rhsm_login.py


示例17: get_server_versions

def get_server_versions(cp, exception_on_timeout=False):
    cp_version = _("Unknown")
    server_type = _("This system is currently not registered.")

    # check for Classic before doing anything else
    if ClassicCheck().is_registered_with_classic():
        if ConsumerIdentity.existsAndValid():
            server_type = get_branding().REGISTERED_TO_BOTH_SUMMARY
        else:
            server_type = get_branding().REGISTERED_TO_OTHER_SUMMARY
    else:
        if ConsumerIdentity.existsAndValid():
            server_type = get_branding().REGISTERED_TO_SUBSCRIPTION_MANAGEMENT_SUMMARY

    if cp:
        try:
            if cp.supports_resource("status"):
                status = cp.getStatus()
                cp_version = '-'.join([status['version'], status['release']])
            else:
                cp_version = _("Unknown")
        except socket.timeout, e:
            log.error("Timeout error while checking server version")
            log.exception(e)
            # for cli, we can assume if we get a timeout here, the rest
            # of the calls will timeout as well, so raise exception here
            # instead of waiting for all the calls to timeout
            if exception_on_timeout:
                log.error("Timeout error while checking server version")
                raise
            # otherwise, ignore the timeout exception
        except Exception, e:
            if isinstance(e, GoneException):
                log.info("Server Versions: Error: consumer has been deleted, unable to check server version")
            else:
                # a more useful error would be handy here
                log.error(("Error while checking server version: %s") % e)

            log.exception(e)
            cp_version = _("Unknown")
开发者ID:tkolhar,项目名称:subscription-manager,代码行数:40,代码来源:utils.py


示例18: pre_check_status

def pre_check_status(force_signal):
    if force_signal is not None:
        debug("forcing status signal from cli arg")
        return force_signal

    if ClassicCheck().is_registered_with_classic():
        debug("System is already registered to another entitlement system")
        return RHN_CLASSIC

    if not ConsumerIdentity.existsAndValid():
        debug("The system is not currently registered.")
        return RHSM_REGISTRATION_REQUIRED
    return None
开发者ID:tkolhar,项目名称:subscription-manager,代码行数:13,代码来源:rhsm_d.py


示例19: pre

 def pre(self):
     # Because the RHN client tools check if certs exist and bypass our
     # firstboot module if so, we know that if we reach this point and
     # identity certs exist, someone must have hit the back button.
     # TODO: i'd like this call to be inside the async progress stuff,
     # since it does take some time
     if ConsumerIdentity.exists():
         try:
             managerlib.unregister(self._parent.backend.cp_provider.get_consumer_auth_cp(),
                     self._parent.identity.uuid)
         except socket.error, e:
             handle_gui_exception(e, e, self._parent.window)
         self._parent._registration_finished = False
开发者ID:tkolhar,项目名称:subscription-manager,代码行数:13,代码来源:rhsm_login.py


示例20: warnOrGiveUsageMessage

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,代码行数:22,代码来源:subscription-manager.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cli.system_exit函数代码示例发布时间:2022-05-27
下一篇:
Python certdirectory.Path类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap