本文整理汇总了Python中subscription_manager.certlib.ConsumerIdentity类的典型用法代码示例。如果您正苦于以下问题:Python ConsumerIdentity类的具体用法?Python ConsumerIdentity怎么用?Python ConsumerIdentity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConsumerIdentity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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()
示例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()
示例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)
示例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))
示例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)
示例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
示例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()
示例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()
示例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()
示例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)
示例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)
示例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
示例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)
示例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())