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

Python policiesregistrar.register_policy_types函数代码示例

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

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



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

示例1: setUp

    def setUp(self):
        super(MistralRunnerPolicyTest, self).setUp()

        # Start with a clean database for each test.
        self._establish_connection_and_re_create_db()

        # Register runners.
        runnersregistrar.register_runners()

        actions_registrar = actionsregistrar.ActionsRegistrar(
            use_pack_cache=False,
            fail_on_failure=True
        )

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)

        # Register policies required for the tests.
        policiesregistrar.register_policy_types(st2common)

        policies_registrar = policiesregistrar.PolicyRegistrar(
            use_pack_cache=False,
            fail_on_failure=True
        )

        for pack in PACKS:
            policies_registrar.register_from_pack(pack)
开发者ID:nzlosh,项目名称:st2,代码行数:27,代码来源:test_mistral_v2_policy.py


示例2: setUpClass

    def setUpClass(cls):
        EventletTestCase.setUpClass()
        DbTestCase.setUpClass()

        # Register common policy types
        register_policy_types(st2common)

        loader = FixturesLoader()
        loader.save_fixtures_to_db(fixtures_pack=PACK, fixtures_dict=TEST_FIXTURES)
开发者ID:rlugojr,项目名称:st2,代码行数:9,代码来源:test_concurrency.py


示例3: setUpClass

    def setUpClass(cls):
        ExecutionDbTestCase.setUpClass()

        # Register runners
        runners_registrar.register_runners()

        # Register common policy types
        register_policy_types(st2common)

        loader = FixturesLoader()
        loader.save_fixtures_to_db(fixtures_pack=PACK,
                                   fixtures_dict=TEST_FIXTURES)
开发者ID:StackStorm,项目名称:st2,代码行数:12,代码来源:test_scheduler.py


示例4: setUp

    def setUp(self):
        super(SchedulerPoliciesTest, self).setUp()

        # Register common policy types
        register_policy_types(st2common)

        loader = FixturesLoader()
        models = loader.save_fixtures_to_db(fixtures_pack=PACK,
                                            fixtures_dict=TEST_FIXTURES_2)

        # Policy with "post_run" application
        self.policy_db = models['policies']['policy_1.yaml']
开发者ID:lyandut,项目名称:st2,代码行数:12,代码来源:test_base.py


示例5: setUpClass

    def setUpClass(cls):
        super(PolicyServiceTestCase, cls).setUpClass()

        # Register runners
        runners_registrar.register_runners()

        # Register common policy types
        policies_registrar.register_policy_types(st2common)

        loader = fixtures.FixturesLoader()
        loader.save_fixtures_to_db(fixtures_pack=PACK,
                                   fixtures_dict=TEST_FIXTURES)
开发者ID:StackStorm,项目名称:st2,代码行数:12,代码来源:test_policy.py


示例6: setUp

    def setUp(self):
        super(NotifierPoliciesTestCase, self).setUp()

        # Register runners
        runners_registrar.register_runners()

        # Register common policy types
        register_policy_types(st2common)

        loader = FixturesLoader()
        models = loader.save_fixtures_to_db(fixtures_pack=PACK,
                                            fixtures_dict=TEST_FIXTURES_1)

        # Policy with "post_run" application
        self.policy_db = models['policies']['policy_4.yaml']
开发者ID:StackStorm,项目名称:st2,代码行数:15,代码来源:test_base.py


示例7: setUpClass

    def setUpClass(cls):
        super(OrquestaRunnerTest, cls).setUpClass()

        # Register runners and policy types.
        runnersregistrar.register_runners()
        policiesregistrar.register_policy_types(st2common)

        # Register test pack(s).
        registrar_options = {'use_pack_cache': False, 'fail_on_failure': True}
        actions_registrar = actionsregistrar.ActionsRegistrar(**registrar_options)
        policies_registrar = policiesregistrar.PolicyRegistrar(**registrar_options)

        for pack in PACKS:
            actions_registrar.register_from_pack(pack)
            policies_registrar.register_from_pack(pack)
开发者ID:nzlosh,项目名称:st2,代码行数:15,代码来源:test_policies.py


示例8: register_policies

def register_policies():
    # Register policy types and policies.
    pack_dir = cfg.CONF.register.pack
    fail_on_failure = not cfg.CONF.register.no_fail_on_failure

    registered_type_count = 0

    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering policy types #################')
        LOG.info('=========================================================')
        registered_type_count = policies_registrar.register_policy_types(st2common)
    except Exception:
        LOG.warning('Failed to register policy types.', exc_info=True)

    LOG.info('Registered %s policy types.', registered_type_count)

    registered_count = 0
    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering policies #####################')
        LOG.info('=========================================================')
        registered_count = policies_registrar.register_policies(pack_dir=pack_dir,
                                                                fail_on_failure=fail_on_failure)
    except Exception as e:
        exc_info = not fail_on_failure
        LOG.warning('Failed to register policies: %s', e, exc_info=exc_info)

        if fail_on_failure:
            raise e

    LOG.info('Registered %s policies.', registered_count)
开发者ID:lyandut,项目名称:st2,代码行数:32,代码来源:bootstrap.py


示例9: setUpClass

    def setUpClass(cls):
        EventletTestCase.setUpClass()
        DbTestCase.setUpClass()

        # Override the coordinator to use the noop driver otherwise the tests will be blocked.
        tests_config.parse_args(coordinator_noop=True)
        coordination.COORDINATOR = None

        # Register runners
        runners_registrar.register_runners()

        # Register common policy types
        register_policy_types(st2common)

        loader = FixturesLoader()
        loader.save_fixtures_to_db(fixtures_pack=PACK,
                                   fixtures_dict=TEST_FIXTURES)
开发者ID:StackStorm,项目名称:st2,代码行数:17,代码来源:test_concurrency.py


示例10: setUp

    def setUp(self):
        super(RetryPolicyTestCase, self).setUp()

        # Register common policy types
        register_policy_types(st2actions)

        loader = FixturesLoader()
        models = loader.save_fixtures_to_db(fixtures_pack=PACK,
                                            fixtures_dict=TEST_FIXTURES)

        # Instantiate policy applicator we will use in the tests
        policy_db = models['policies']['policy_4.yaml']
        retry_on = policy_db.parameters['retry_on']
        max_retry_count = policy_db.parameters['max_retry_count']
        self.policy = ExecutionRetryPolicyApplicator(policy_ref='test_policy',
                                                     policy_type='action.retry',
                                                     retry_on=retry_on,
                                                     max_retry_count=max_retry_count,
                                                     delay=0)
开发者ID:Plexxi,项目名称:st2,代码行数:19,代码来源:test_retry_policy.py


示例11: test_register_policy_types

    def test_register_policy_types(self):
        self.assertEqual(register_policy_types(st2tests), 2)

        type1 = PolicyType.get_by_ref("action.concurrency")
        self.assertEqual(type1.name, "concurrency")
        self.assertEqual(type1.resource_type, "action")

        type2 = PolicyType.get_by_ref("action.mock_policy_error")
        self.assertEqual(type2.name, "mock_policy_error")
        self.assertEqual(type2.resource_type, "action")
开发者ID:azamsheriff,项目名称:st2,代码行数:10,代码来源:test_policies.py


示例12: post

    def post(self, pack_register_request):
        if pack_register_request and hasattr(pack_register_request, 'types'):
            types = pack_register_request.types
            if 'all' in types:
                types = PackRegisterController.CONTENT_TYPES
        else:
            types = PackRegisterController.CONTENT_TYPES

        if pack_register_request and hasattr(pack_register_request, 'packs'):
            packs = list(set(pack_register_request.packs))
        else:
            packs = None

        result = defaultdict(int)

        # Register depended resources (actions depend on runners, rules depend on rule types, etc)
        if ('runner' in types or 'runners' in types) or ('action' in types or 'actions' in types):
            result['runners'] = runners_registrar.register_runners(experimental=True)
        if ('rule_type' in types or 'rule_types' in types) or \
           ('rule' in types or 'rules' in types):
            result['rule_types'] = rule_types_registrar.register_rule_types()
        if ('policy_type' in types or 'policy_types' in types) or \
           ('policy' in types or 'policies' in types):
            result['policy_types'] = policies_registrar.register_policy_types(st2common)

        use_pack_cache = False

        fail_on_failure = getattr(pack_register_request, 'fail_on_failure', True)
        for type, (Registrar, name) in six.iteritems(ENTITIES):
            if type in types or name in types:
                registrar = Registrar(use_pack_cache=use_pack_cache,
                                      use_runners_cache=True,
                                      fail_on_failure=fail_on_failure)
                if packs:
                    for pack in packs:
                        pack_path = content_utils.get_pack_base_path(pack)

                        try:
                            registered_count = registrar.register_from_pack(pack_dir=pack_path)
                            result[name] += registered_count
                        except ValueError as e:
                            # Throw more user-friendly exception if requsted pack doesn't exist
                            if re.match('Directory ".*?" doesn\'t exist', six.text_type(e)):
                                msg = 'Pack "%s" not found on disk: %s' % (pack, six.text_type(e))
                                raise ValueError(msg)

                            raise e
                else:
                    packs_base_paths = content_utils.get_packs_base_paths()
                    registered_count = registrar.register_from_packs(base_dirs=packs_base_paths)
                    result[name] += registered_count

        return result
开发者ID:nzlosh,项目名称:st2,代码行数:53,代码来源:packs.py


示例13: post

    def post(self, pack_register_request):
        if pack_register_request and hasattr(pack_register_request, 'types'):
            types = pack_register_request.types
        else:
            types = ['runner', 'action', 'trigger', 'sensor', 'rule', 'rule_type', 'alias',
                     'policy_type', 'policy', 'config']

        if pack_register_request and hasattr(pack_register_request, 'packs'):
            packs = pack_register_request.packs
        else:
            packs = None

        result = {}

        if 'runner' in types or 'action' in types:
            result['runners'] = runners_registrar.register_runners(experimental=True)
        if 'rule_type' in types or 'rule' in types:
            result['rule_types'] = rule_types_registrar.register_rule_types()
        if 'policy_type' in types or 'policy' in types:
            result['policy_types'] = policies_registrar.register_policy_types(st2common)

        use_pack_cache = False

        for type, (Registrar, name) in six.iteritems(ENTITIES):
            if type in types:
                registrar = Registrar(use_pack_cache=use_pack_cache,
                                      fail_on_failure=False)
                if packs:
                    for pack in packs:
                        pack_path = content_utils.get_pack_base_path(pack)
                        result[name] = registrar.register_from_pack(pack_dir=pack_path)
                else:
                    packs_base_paths = content_utils.get_packs_base_paths()
                    result[name] = registrar.register_from_packs(base_dirs=packs_base_paths)

        return result
开发者ID:LindsayHill,项目名称:st2,代码行数:36,代码来源:packs.py


示例14: register_policies

def register_policies():
    # Register policy types and policies.
    registered_type_count = 0
    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering policy types #################')
        LOG.info('=========================================================')
        import st2actions
        registered_type_count = policies_registrar.register_policy_types(st2actions)
    except Exception:
        LOG.warning('Failed to register policy types.', exc_info=True)

    LOG.info('Registered %s policy types.', registered_type_count)

    registered_count = 0
    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering policies #####################')
        LOG.info('=========================================================')
        registered_count = policies_registrar.register_policies()
    except Exception:
        LOG.warning('Failed to register policies.', exc_info=True)

    LOG.info('Registered %s policies.', registered_count)
开发者ID:hejin,项目名称:st2,代码行数:24,代码来源:bootstrap.py


示例15: setUpClass

    def setUpClass(cls):
        super(PolicyBootstrapTest, cls).setUpClass()

        # Register common policy types
        register_policy_types(st2common)
开发者ID:azamsheriff,项目名称:st2,代码行数:5,代码来源:test_policies.py


示例16: setUp

    def setUp(self):
        super(PoliciesRegistrarTestCase, self).setUp()

        # Register common policy types
        register_policy_types(st2common)
开发者ID:LindsayHill,项目名称:st2,代码行数:5,代码来源:test_policies_registrar.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python runnersregistrar.register_runners函数代码示例发布时间:2022-05-27
下一篇:
Python base.ResourceRegistrar类代码示例发布时间: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