本文整理汇总了Python中st2common.bootstrap.policiesregistrar.register_policy_types函数的典型用法代码示例。如果您正苦于以下问题:Python register_policy_types函数的具体用法?Python register_policy_types怎么用?Python register_policy_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了register_policy_types函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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']
示例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)
示例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']
示例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)
示例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)
示例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)
示例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)
示例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")
示例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
示例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
示例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)
示例15: setUpClass
def setUpClass(cls):
super(PolicyBootstrapTest, cls).setUpClass()
# Register common policy types
register_policy_types(st2common)