本文整理汇总了Python中subscription_manager.certlib.ConsumerIdentity.existsAndValid方法的典型用法代码示例。如果您正苦于以下问题:Python ConsumerIdentity.existsAndValid方法的具体用法?Python ConsumerIdentity.existsAndValid怎么用?Python ConsumerIdentity.existsAndValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subscription_manager.certlib.ConsumerIdentity
的用法示例。
在下文中一共展示了ConsumerIdentity.existsAndValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shouldAppear
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [as 别名]
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()
示例2: check_status
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [as 别名]
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
示例3: reload
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [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()
示例4: get_server_versions
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [as 别名]
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")
示例5: setup_plugin
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [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)
示例6: pre_check_status
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [as 别名]
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
示例7: registration_changed
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [as 别名]
def registration_changed(path):
"""
Notification that a change in registration has been detected.
On registration: setup the plugin; attach to the message broker.
On un-registration: detach from the message broker.
:param path: The path to the file that changed.
:type path: str
"""
log.info('changed: %s', path)
if ConsumerIdentity.existsAndValid():
setup_plugin()
plugin.attach()
else:
plugin.detach()
示例8: send_enabled_report
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [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))
示例9: changed
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [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)
示例10: main
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [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.ExpiredIdentityCertException, e:
log.critical(_("Your identity certificate has expired"))
raise e
示例11: main
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [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
示例12: main
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [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:
if options.autoheal:
actionclient = action_client.HealingActionClient()
else:
actionclient = action_client.ActionCertClient()
update_reports = actionclient.update(options.autoheal)
for update_report in update_reports:
# FIXME: make sure we don't get None reports
if update_report:
print update_report
except connection.ExpiredIdentityCertException, e:
log.critical(_("Your identity certificate has expired"))
raise e
示例13: Writer
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [as 别名]
raise
if certs:
try:
writer = Writer()
cert = certificate.create_from_pem(certs['cert'])
key = certificate.Key(certs['key'])
writer.write(key, cert)
except:
raise
rhiclib.cleanExpiredCerts(ProductDirectory(), EntitlementDirectory(), facts.to_dict())
sys.exit(0)
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()
示例14: registered
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [as 别名]
def registered(self):
return ConsumerIdentity.existsAndValid()
示例15: is_registered
# 需要导入模块: from subscription_manager.certlib import ConsumerIdentity [as 别名]
# 或者: from subscription_manager.certlib.ConsumerIdentity import existsAndValid [as 别名]
def is_registered(self):
if ConsumerIdentity.existsAndValid():
return True
return False