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

Python repolib.RepoActionInvoker类代码示例

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

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



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

示例1: update

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()
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:29,代码来源:subscription-manager.py


示例2: _update

    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()
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:34,代码来源:subscription-manager.py


示例3: test_is_managed

    def test_is_managed(self):
        self._stub_content()
        repo_action_invoker = RepoActionInvoker()
        repo_label = 'a_test_repo'

        im_result = repo_action_invoker.is_managed(repo_label)

        self.assertTrue(im_result)
开发者ID:Januson,项目名称:subscription-manager,代码行数:8,代码来源:test_repolib.py


示例4: clean_all_data

def clean_all_data(backup=True):
    consumer_dir = cfg.get('rhsm', 'consumerCertDir')
    if backup:
        if consumer_dir[-1] == "/":
            consumer_dir_backup = consumer_dir[0:-1] + ".old"
        else:
            consumer_dir_backup = consumer_dir + ".old"

        # Delete backup dir if it exists:
        shutil.rmtree(consumer_dir_backup, ignore_errors=True)

        # Copy current consumer dir:
        log.debug("Backing up %s to %s.", consumer_dir, consumer_dir_backup)
        shutil.copytree(consumer_dir, consumer_dir_backup)

# FIXME FIXME
    # Delete current consumer certs:
    for path in [ConsumerIdentity.keypath(), ConsumerIdentity.certpath()]:
        if (os.path.exists(path)):
            log.debug("Removing identity cert: %s" % path)
            os.remove(path)

    require(IDENTITY).reload()

    # Delete all entitlement certs rather than the directory itself:
    ent_cert_dir = cfg.get('rhsm', 'entitlementCertDir')
    if os.path.exists(ent_cert_dir):

        for f in glob.glob("%s/*.pem" % ent_cert_dir):
            certpath = os.path.join(ent_cert_dir, f)
            log.debug("Removing entitlement cert: %s" % f)
            os.remove(certpath)
    else:
        log.warn("Entitlement cert directory does not exist: %s" % ent_cert_dir)

    # Subclasses of cache.CacheManager have a @classmethod delete_cache
    # for deleting persistent caches
    cache.ProfileManager.delete_cache()
    cache.InstalledProductsManager.delete_cache()
    if SyncedStore is not None:
        SyncedStore(None).update_cache({})
    # FIXME: implement as dbus client to facts service DeleteCache() once implemented
    # Facts.delete_cache()
    # WrittenOverridesCache is also a subclass of cache.CacheManager, but
    # it is deleted in RepoActionInvoker.delete_repo_file() below.
    # StatusCache subclasses have a a per instance cache varable
    # and delete_cache is an instance method, so we need to call
    # the delete_cache on the instances created in injectioninit.
    require(ENTITLEMENT_STATUS_CACHE).delete_cache()
    require(SYSTEMPURPOSE_COMPLIANCE_STATUS_CACHE).delete_cache()
    require(PROD_STATUS_CACHE).delete_cache()
    require(POOL_STATUS_CACHE).delete_cache()
    require(OVERRIDE_STATUS_CACHE).delete_cache()
    require(RELEASE_STATUS_CACHE).delete_cache()

    RepoActionInvoker.delete_repo_file()
    log.debug("Cleaned local data")
开发者ID:Januson,项目名称:subscription-manager,代码行数:57,代码来源:managerlib.py


示例5: repo_hook

 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")
开发者ID:cnsnyder,项目名称:subscription-manager,代码行数:9,代码来源:entcertlib.py


示例6: test_get_repos

 def test_get_repos(self):
     self._stub_content(include_content_access=True)
     repo_action_invoker = RepoActionInvoker()
     repos = repo_action_invoker.get_repos()
     self.assertEqual(2, len(repos), 'Should produce two repos')
     matching_repos = [repo for repo in repos if repo.id == 'a_test_repo']
     self.assertEqual(1, len(matching_repos), 'Should only produce one repo for "a_test_repo"')
     repo = matching_repos[0]
     certpath = repo.get('sslclientcert')
     self.assertNotEqual(certpath, self.stub_content_access_cert.path)
开发者ID:Januson,项目名称:subscription-manager,代码行数:10,代码来源:test_repolib.py


示例7: Overrides

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()
开发者ID:belonesox,项目名称:subscription-manager,代码行数:45,代码来源:overrides.py


示例8: clean_all_data

def clean_all_data(backup=True):
    consumer_dir = cfg.get('rhsm', 'consumerCertDir')
    if backup:
        if consumer_dir[-1] == "/":
            consumer_dir_backup = consumer_dir[0:-1] + ".old"
        else:
            consumer_dir_backup = consumer_dir + ".old"

        # Delete backup dir if it exists:
        shutil.rmtree(consumer_dir_backup, ignore_errors=True)

        # Copy current consumer dir:
        log.info("Backing up %s to %s." % (consumer_dir, consumer_dir_backup))
        shutil.copytree(consumer_dir, consumer_dir_backup)

# FIXME FIXME
    # Delete current consumer certs:
    for path in [ConsumerIdentity.keypath(), ConsumerIdentity.certpath()]:
        if (os.path.exists(path)):
            log.debug("Removing identity cert: %s" % path)
            os.remove(path)

    require(IDENTITY).reload()

    # Delete all entitlement certs rather than the directory itself:
    ent_cert_dir = cfg.get('rhsm', 'entitlementCertDir')
    if os.path.exists(ent_cert_dir):

        for f in glob.glob("%s/*.pem" % ent_cert_dir):
            certpath = os.path.join(ent_cert_dir, f)
            log.debug("Removing entitlement cert: %s" % f)
            os.remove(certpath)
    else:
        log.warn("Entitlement cert directory does not exist: %s" % ent_cert_dir)

    cache.ProfileManager.delete_cache()
    cache.InstalledProductsManager.delete_cache()
    Facts.delete_cache()

    # Must also delete in-memory cache
    require(ENTITLEMENT_STATUS_CACHE).delete_cache()
    require(PROD_STATUS_CACHE).delete_cache()
    require(OVERRIDE_STATUS_CACHE).delete_cache()
    RepoActionInvoker.delete_repo_file()
    log.info("Cleaned local data")
开发者ID:aweiteka,项目名称:subscription-manager,代码行数:45,代码来源:managerlib.py


示例9: _set_enable_for_yum_repositories

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)
开发者ID:Januson,项目名称:subscription-manager,代码行数:40,代码来源:repos.py


示例10: __init__

    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)
开发者ID:belonesox,项目名称:subscription-manager,代码行数:5,代码来源:overrides.py


示例11: test_get_repo_file

    def test_get_repo_file(self):
        repo_action_invoker = RepoActionInvoker()

        repo_file = repo_action_invoker.get_repo_file()
        self.assertFalse(repo_file is None)
开发者ID:Januson,项目名称:subscription-manager,代码行数:5,代码来源:test_repolib.py


示例12: test_get_repos_empty_dirs

 def test_get_repos_empty_dirs(self):
     repo_action_invoker = RepoActionInvoker()
     repos = repo_action_invoker.get_repos()
     if repos:
         self.fail("get_repos() should have returned an empty set but did not.")
开发者ID:Januson,项目名称:subscription-manager,代码行数:5,代码来源:test_repolib.py


示例13: test_get_repos

 def test_get_repos(self):
     self._stub_content()
     repo_action_invoker = RepoActionInvoker()
     repos = repo_action_invoker.get_repos()
     if len(repos) == 0:
         self.fail("get_repos() should have a set of Repo's, but the set is empty.")
开发者ID:megaumi,项目名称:subscription-manager,代码行数:6,代码来源:test_repolib.py


示例14: str

#!/usr/bin/python
#
# This script was downloaded from https://bugzilla.redhat.com/attachment.cgi?id=1027300 and slightly modified
# This purpose of this script is to verify bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1223038
# Bug 1223038 - RepoActionInvoker.is_managed() broken in subscription-manager-1.14.5-1.el6.x86_64 /usr/share/rhsm/subscription_manager/repolib.py
#
import sys
import logging
LOG_FILENAME = 'ismanagedtest.log'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)

# read argument to this script
some_repo = str(sys.argv[1])

_LIBPATH = "/usr/share/rhsm"
# add to the path if need be
if _LIBPATH not in sys.path:
    sys.path.append(_LIBPATH)

from subscription_manager.injectioninit import init_dep_injection
init_dep_injection()
from subscription_manager.repolib import RepoActionInvoker
rai = RepoActionInvoker()

# Should print "False" if is_managed is working
print rai.is_managed(some_repo)
开发者ID:rehana-raj,项目名称:rhsm-qe,代码行数:26,代码来源:ismanagedtest.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python repolib.RepoUpdateActionCommand类代码示例发布时间:2022-05-27
下一篇:
Python repolib.Repo类代码示例发布时间: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