本文整理汇总了Python中subscription_manager.injection.require函数的典型用法代码示例。如果您正苦于以下问题:Python require函数的具体用法?Python require怎么用?Python require使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了require函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.identity = inj.require(inj.IDENTITY)
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.ent_dir = inj.require(inj.ENT_DIR)
self.pool_cache = inj.require(inj.POOL_STATUS_CACHE)
self.pooltype_map = {}
self.update()
示例2: __init__
def __init__(self, cache_only=False, apply_overrides=True):
self.identity = inj.require(inj.IDENTITY)
# These should probably move closer their use
self.ent_dir = inj.require(inj.ENT_DIR)
self.prod_dir = inj.require(inj.PROD_DIR)
self.ent_source = ent_cert.EntitlementDirEntitlementSource()
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.uep = self.cp_provider.get_consumer_auth_cp()
self.manage_repos = 1
self.apply_overrides = apply_overrides
self.manage_repos = manage_repos_enabled()
self.release = None
self.overrides = {}
self.override_supported = False
try:
self.override_supported = bool(self.identity.is_valid() and self.uep and self.uep.supports_resource('content_overrides'))
except socket.error as e:
# swallow the error to fix bz 1298327
log.exception(e)
pass
self.written_overrides = WrittenOverrideCache()
# FIXME: empty report at the moment, should be changed to include
# info about updated repos
self.report = RepoActionReport()
self.report.name = "Repo updates"
# If we are not registered, skip trying to refresh the
# data from the server
if not self.identity.is_valid():
return
# NOTE: if anything in the RepoActionInvoker init blocks, and it
# could, yum could still block. The closest thing to an
# event loop we have is the while True: sleep() in lock.py:Lock.acquire()
# Only attempt to update the overrides if they are supported
# by the server.
if self.override_supported:
self.written_overrides._read_cache()
try:
override_cache = inj.require(inj.OVERRIDE_STATUS_CACHE)
except KeyError:
override_cache = OverrideStatusCache()
if cache_only:
status = override_cache._read_cache()
else:
status = override_cache.load_status(self.uep, self.identity.uuid)
for item in status or []:
# Don't iterate through the list
if item['contentLabel'] not in self.overrides:
self.overrides[item['contentLabel']] = {}
self.overrides[item['contentLabel']][item['name']] = item['value']
示例3: __init__
def __init__(self, uep=None):
uep = uep or inj.require(inj.CP_PROVIDER).get_consumer_auth_cp()
self.identity = inj.require(inj.IDENTITY)
if self.identity.is_valid():
self.prod_status_cache = inj.require(inj.PROD_STATUS_CACHE)
self.prod_status = self.prod_status_cache.load_status(
uep, self.identity.uuid)
示例4: __init__
def __init__(self, report=None):
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.uep = self.cp_provider.get_consumer_auth_cp()
self.ent_dir = inj.require(inj.ENT_DIR)
self.identity = require(IDENTITY)
self.report = EntCertUpdateReport()
self.content_access_cache = inj.require(inj.CONTENT_ACCESS_CACHE)
示例5: get_filtered_pools_list
def get_filtered_pools_list(self, active_on, incompatible,
overlapping, uninstalled, text, filter_string, future=None, after_date=None):
"""
Used for CLI --available filtering
cuts down on api calls
"""
self.all_pools = {}
self.compatible_pools = {}
if active_on and overlapping:
self.sorter = ComplianceManager(active_on)
elif not active_on and overlapping:
self.sorter = require(CERT_SORTER)
if incompatible:
for pool in list_pools(require(CP_PROVIDER).get_consumer_auth_cp(),
self.identity.uuid, active_on=active_on,
filter_string=filter_string, future=future, after_date=after_date):
self.compatible_pools[pool['id']] = pool
else: # --all has been used
for pool in list_pools(require(CP_PROVIDER).get_consumer_auth_cp(),
self.identity.uuid, list_all=True, active_on=active_on,
filter_string=filter_string, future=future, after_date=after_date):
self.all_pools[pool['id']] = pool
return self._filter_pools(incompatible, overlapping, uninstalled, False, text)
示例6: __init__
def __init__(self):
self.release_status_cache = inj.require(inj.RELEASE_STATUS_CACHE)
self._expansion = None
self.identity = inj.require(inj.IDENTITY)
self.cp_provider = inj.require(inj.CP_PROVIDER)
示例7: list_pools
def list_pools(uep, consumer_uuid, list_all=False, active_on=None, filter_string=None, future=None,
after_date=None):
"""
Wrapper around the UEP call to fetch pools, which forces a facts update
if anything has changed before making the request. This ensures the
rule checks server side will have the most up to date info about the
consumer possible.
"""
# client tells service 'look for facts again'
# if service finds new facts:
# -emit a signal?
# - or just update properties
# - and set a 'been_synced' property to False
# client waits for facts check to finish
# if no changes or been_synced=True, continue
# if changes or unsynced:
# subman updates candlepin with the latest version of services GetFacts() [blocking]
# when finished, subman emit's 'factsSyncFinished'
# - then service flops 'been_synced' property
# -or- subman calls 'here_are_the_latest_facts_to_the_server()' on service
# then service flops 'been_synced' property
# subman gets signal that props changed, and that been_synced is now true
# since it's been synced, then subman continues
require(FACTS).update_check(uep, consumer_uuid)
profile_mgr = cache.ProfileManager()
profile_mgr.update_check(uep, consumer_uuid)
owner = uep.getOwner(consumer_uuid)
ownerid = owner['key']
return uep.getPoolsList(consumer=consumer_uuid, listAll=list_all,
active_on=active_on, owner=ownerid, filter_string=filter_string, future=future,
after_date=after_date)
示例8: perform
def perform(self):
mgr = inj.require(inj.INSTALLED_PRODUCTS_MANAGER)
consumer_identity = inj.require(inj.IDENTITY)
ret = mgr.update_check(self.uep, consumer_identity.uuid)
self.report._status = ret
return self.report
示例9: __init__
def __init__(self, uep):
"""
Initialization of Unregister instance
"""
self.identity = inj.require(inj.IDENTITY)
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.uep = uep
示例10: __init__
def __init__(self, on_date=None):
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.product_dir = inj.require(inj.PROD_DIR)
self.entitlement_dir = inj.require(inj.ENT_DIR)
self.identity = inj.require(inj.IDENTITY)
self.on_date = on_date
self.load()
示例11: get_installed_product_status
def get_installed_product_status(product_directory, entitlement_directory, uep):
"""
Returns the Installed products and their subscription states
"""
product_status = []
sorter = require(CERT_SORTER)
calculator = require(PRODUCT_DATE_RANGE_CALCULATOR, uep)
for installed_product in sorter.installed_products:
product_cert = sorter.installed_products[installed_product]
for product in product_cert.products:
begin = ""
end = ""
prod_status_range = calculator.calculate(product.id)
if prod_status_range:
# Format the date in user's local time as the date
# range is returned in GMT.
begin = format_date(prod_status_range.begin())
end = format_date(prod_status_range.end())
data = (product.name,
installed_product,
product.version,
",".join(product.architectures),
sorter.get_status(product.id),
sorter.reasons.get_product_reasons(product),
begin,
end)
product_status.append(data)
return product_status
示例12: __init__
def __init__(self, facts):
super(SystemFactsDialog, self).__init__()
#self.consumer = consumer
self.identity = inj.require(inj.IDENTITY)
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.facts = facts
self.connect_signals({
"on_system_facts_dialog_delete_event": self._hide_callback,
"on_close_button_clicked": self._hide_callback,
"on_facts_update_button_clicked": self._update_facts_callback
})
# Set up the model
self.facts_store = ga_Gtk.TreeStore(str, str)
self.facts_view.set_model(self.facts_store)
# Set up columns on the view
self._add_column(_("Fact"), 0)
self._add_column(_("Value"), 1)
# set up the signals from the view
self.facts_view.connect("row_activated",
widgets.expand_collapse_on_row_activated_callback)
示例13: setUp
def setUp(self):
super(TestPoolTypeCache, self).setUp()
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.cp_provider.consumer_auth_cp = Mock()
self.cp = self.cp_provider.consumer_auth_cp
certs = [StubEntitlementCertificate(StubProduct('pid1'), pool=StubPool('someid'))]
self.ent_dir = StubEntitlementDirectory(certificates=certs)
self.pool_cache = inj.require(inj.POOL_STATUS_CACHE)
self.pool_cache.write_cache = Mock()
示例14: __init__
def __init__(self, cache_only=False, apply_overrides=True):
self.identity = inj.require(inj.IDENTITY)
# These should probably move closer their use
self.ent_dir = inj.require(inj.ENT_DIR)
self.prod_dir = inj.require(inj.PROD_DIR)
self.ent_source = ent_cert.EntitlementDirEntitlementSource()
self.cp_provider = inj.require(inj.CP_PROVIDER)
self.uep = self.cp_provider.get_consumer_auth_cp()
self.manage_repos = 1
self.apply_overrides = apply_overrides
if CFG.has_option('rhsm', 'manage_repos'):
self.manage_repos = int(CFG.get('rhsm', 'manage_repos'))
self.release = None
self.overrides = {}
self.override_supported = bool(self.identity.is_valid() and self.uep and self.uep.supports_resource('content_overrides'))
self.written_overrides = WrittenOverrideCache()
# FIXME: empty report at the moment, should be changed to include
# info about updated repos
self.report = RepoActionReport()
self.report.name = "Repo updates"
# If we are not registered, skip trying to refresh the
# data from the server
if not self.identity.is_valid():
return
# Only attempt to update the overrides if they are supported
# by the server.
if self.override_supported:
self.written_overrides._read_cache()
try:
override_cache = inj.require(inj.OVERRIDE_STATUS_CACHE)
except KeyError:
override_cache = OverrideStatusCache()
if cache_only:
status = override_cache._read_cache()
else:
status = override_cache.load_status(self.uep, self.identity.uuid)
for item in status or []:
# Don't iterate through the list
if item['contentLabel'] not in self.overrides:
self.overrides[item['contentLabel']] = {}
self.overrides[item['contentLabel']][item['name']] = item['value']
message = "Release API is not supported by the server. Using default."
try:
result = self.uep.getRelease(self.identity.uuid)
self.release = result['releaseVer']
except RemoteServerException, e:
log.debug(message)
示例15: update_product_manager
def update_product_manager(self):
if self.is_registered():
cp_provider = inj.require(inj.CP_PROVIDER)
consumer_identity = inj.require(inj.IDENTITY)
try:
self.installed_mgr.update_check(cp_provider.get_consumer_auth_cp(),
consumer_identity.uuid)
except RestlibException:
# Invalid consumer certificate
pass