示例#1
0
文件: bootstrap.py 项目: Itxaka/st2
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)
示例#2
0
文件: bootstrap.py 项目: joshgre/st2
def register_policies():
    # Register policy types and policies.
    try:
        LOG.info("=========================================================")
        LOG.info("############## Registering policy types #################")
        LOG.info("=========================================================")
        import st2actions
        import st2common.content.policiesregistrar as policies_registrar

        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)

    try:
        LOG.info("=========================================================")
        LOG.info("############## Registering policies #####################")
        LOG.info("=========================================================")
        import st2common.content.policiesregistrar as policies_registrar

        registered_count = policies_registrar.register_policies()
    except Exception:
        LOG.warning("Failed to register policies.", exc_info=True)

    LOG.info("Registered %s policies.", registered_count)
示例#3
0
    def test_register_policies(self):
        pack_dir = os.path.join(fixturesloader.get_fixtures_base_path(), 'dummy_pack_1')
        self.assertEqual(register_policies(pack_dir=pack_dir), 2)

        p1 = Policy.get_by_ref('dummy_pack_1.test_policy_1')
        self.assertEqual(p1.name, 'test_policy_1')
        self.assertEqual(p1.pack, 'dummy_pack_1')
        self.assertEqual(p1.resource_ref, 'dummy_pack_1.local')
        self.assertEqual(p1.policy_type, 'action.concurrency')

        p2 = Policy.get_by_ref('dummy_pack_1.test_policy_2')
        self.assertEqual(p2.name, 'test_policy_2')
        self.assertEqual(p2.pack, 'dummy_pack_1')
        self.assertEqual(p2.resource_ref, 'dummy_pack_1.local')
        self.assertEqual(p2.policy_type, 'action.mock_policy_error')
        self.assertEqual(p2.resource_ref, 'dummy_pack_1.local')
示例#4
0
    def test_register_policies(self):
        pack_dir = os.path.join(fixturesloader.get_fixtures_base_path(),
                                'dummy_pack_1')
        self.assertEqual(register_policies(pack_dir=pack_dir), 2)

        p1 = Policy.get_by_ref('dummy_pack_1.test_policy_1')
        self.assertEqual(p1.name, 'test_policy_1')
        self.assertEqual(p1.pack, 'dummy_pack_1')
        self.assertEqual(p1.resource_ref, 'dummy_pack_1.local')
        self.assertEqual(p1.policy_type, 'action.concurrency')

        p2 = Policy.get_by_ref('dummy_pack_1.test_policy_2')
        self.assertEqual(p2.name, 'test_policy_2')
        self.assertEqual(p2.pack, 'dummy_pack_1')
        self.assertEqual(p2.resource_ref, 'dummy_pack_1.local')
        self.assertEqual(p2.policy_type, 'action.mock_policy_error')
        self.assertEqual(p2.resource_ref, 'dummy_pack_1.local')
示例#5
0
文件: bootstrap.py 项目: agilee/st2
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)