本文整理汇总了Python中subscription_manager.repolib.RepoActionInvoker.update方法的典型用法代码示例。如果您正苦于以下问题:Python RepoActionInvoker.update方法的具体用法?Python RepoActionInvoker.update怎么用?Python RepoActionInvoker.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subscription_manager.repolib.RepoActionInvoker
的用法示例。
在下文中一共展示了RepoActionInvoker.update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update
# 需要导入模块: from subscription_manager.repolib import RepoActionInvoker [as 别名]
# 或者: from subscription_manager.repolib.RepoActionInvoker import update [as 别名]
def _update(self, cache_only):
""" update entitlement certificates """
logger.info(_('Updating Subscription Management repositories.'))
# XXX: Importing inline as you must be root to read the config file
from subscription_manager.identity import ConsumerIdentity
cert_file = str(ConsumerIdentity.certpath())
key_file = str(ConsumerIdentity.keypath())
identity = inj.require(inj.IDENTITY)
# In containers we have no identity, but we may have entitlements inherited
# from the host, which need to generate a redhat.repo.
if identity.is_valid():
try:
connection.UEPConnection(cert_file=cert_file, key_file=key_file)
# FIXME: catchall exception
except Exception:
# log
logger.info(_("Unable to connect to Subscription Management Service"))
return
else:
logger.info(_("Unable to read consumer identity"))
if config.in_container():
logger.info(_("Subscription Manager is operating in container mode."))
if not cache_only:
cert_action_invoker = EntCertActionInvoker()
cert_action_invoker.update()
repo_action_invoker = RepoActionInvoker(cache_only=cache_only)
repo_action_invoker.update()
示例2: update
# 需要导入模块: from subscription_manager.repolib import RepoActionInvoker [as 别名]
# 或者: from subscription_manager.repolib.RepoActionInvoker import update [as 别名]
def update(conduit, cache_only):
""" 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.identity import ConsumerIdentity
cert_file = ConsumerIdentity.certpath()
key_file = ConsumerIdentity.keypath()
identity = inj.require(inj.IDENTITY)
if not identity.is_valid():
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 = RepoActionInvoker(uep=uep, cache_only=cache_only)
rl.update()
示例3: repo_hook
# 需要导入模块: from subscription_manager.repolib import RepoActionInvoker [as 别名]
# 或者: from subscription_manager.repolib.RepoActionInvoker import update [as 别名]
def repo_hook(self):
"""Update yum repos."""
try:
# NOTE: this may need a lock
rl = RepoActionInvoker()
rl.update()
except Exception, e:
log.debug(e)
log.debug("Failed to update repos")
示例4: Overrides
# 需要导入模块: from subscription_manager.repolib import RepoActionInvoker [as 别名]
# 或者: from subscription_manager.repolib.RepoActionInvoker import update [as 别名]
class Overrides(object):
def __init__(self):
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.cache = inj.require(inj.OVERRIDE_STATUS_CACHE)
self.repo_lib = RepoActionInvoker(cache_only=True)
def get_overrides(self, consumer_uuid):
return self._build_from_json(self.cache.load_status(self._getuep(), consumer_uuid))
def add_overrides(self, consumer_uuid, overrides):
return self._build_from_json(self._getuep().setContentOverrides(consumer_uuid,
self._add(overrides)))
def remove_overrides(self, consumer_uuid, overrides):
return self._delete_overrides(consumer_uuid, self._remove(overrides))
def remove_all_overrides(self, consumer_uuid, repos):
return self._delete_overrides(consumer_uuid, self._remove_all(repos))
def update(self, overrides):
self.cache.server_status = [override.to_json() for override in overrides]
self.cache.write_cache()
self.repo_lib.update()
def _delete_overrides(self, consumer_uuid, override_data):
return self._build_from_json(self._getuep().deleteContentOverrides(consumer_uuid, override_data))
def _add(self, overrides):
return [override.to_json() for override in overrides]
def _remove(self, overrides):
return [{'contentLabel': override.repo_id, 'name': override.name} for override in overrides]
def _remove_all(self, repos):
if repos:
return [{'contentLabel': repo} for repo in repos]
else:
return None
def _build_from_json(self, override_json):
return [Override.from_json(override_dict) for override_dict in override_json]
def _getuep(self):
return self.cp_provider.get_consumer_auth_cp()
示例5: _set_enable_for_yum_repositories
# 需要导入模块: from subscription_manager.repolib import RepoActionInvoker [as 别名]
# 或者: from subscription_manager.repolib.RepoActionInvoker import update [as 别名]
def _set_enable_for_yum_repositories(setting, *repo_ids):
invoker = RepoActionInvoker()
repos = invoker.get_repos()
repos_to_change = []
for r in repo_ids:
matches = set([repo for repo in repos if fnmatch.fnmatch(repo.id, r)])
repos_to_change.extend(matches)
if len(repos_to_change) == 0:
return 0
# The cache should be primed at this point by the invoker.get_repos()
cache = inj.require(inj.OVERRIDE_STATUS_CACHE)
identity = inj.require(inj.IDENTITY)
cp_provider = inj.require(inj.CP_PROVIDER)
if identity.is_valid() and cp_provider.get_consumer_auth_cp().supports_resource('content_overrides'):
overrides = [{'contentLabel': repo.id, 'name': 'enabled', 'value': setting} for repo in repos_to_change]
cp = cp_provider.get_consumer_auth_cp()
results = cp.setContentOverrides(identity.uuid, overrides)
cache = inj.require(inj.OVERRIDE_STATUS_CACHE)
# Update the cache with the returned JSON
cache.server_status = results
cache.write_cache()
invoker.update()
else:
for repo in repos_to_change:
repo['enabled'] = setting
repo_file = YumRepoFile()
repo_file.read()
for repo in repos_to_change:
repo_file.update(repo)
repo_file.write()
return len(repos_to_change)