Ejemplo n.º 1
0
 def test_register_actions_from_bad_pack(self):
     packs_base_path = tests_base.get_fixtures_path()
     try:
         actions_registrar.register_actions(packs_base_paths=[packs_base_path])
         self.fail("Should have thrown.")
     except:
         pass
Ejemplo n.º 2
0
 def test_register_actions_from_bad_pack(self):
     packs_base_path = tests_base.get_fixtures_path()
     try:
         actions_registrar.register_actions(packs_base_paths=[packs_base_path])
         self.fail('Should have thrown.')
     except:
         pass
Ejemplo n.º 3
0
 def test_register_all_actions(self):
     try:
         packs_base_path = fixtures_loader.get_fixtures_base_path()
         all_actions_in_db = Action.get_all()
         actions_registrar.register_actions(packs_base_paths=[packs_base_path])
     except Exception as e:
         print(str(e))
         self.fail('All actions must be registered without exceptions.')
     else:
         all_actions_in_db = Action.get_all()
         self.assertTrue(len(all_actions_in_db) > 0)
 def test_register_all_actions(self):
     try:
         packs_base_path = fixtures_loader.get_fixtures_base_path()
         all_actions_in_db = Action.get_all()
         actions_registrar.register_actions(
             packs_base_paths=[packs_base_path])
     except Exception as e:
         print(str(e))
         self.fail('All actions must be registered without exceptions.')
     else:
         all_actions_in_db = Action.get_all()
         self.assertTrue(len(all_actions_in_db) > 0)
Ejemplo n.º 5
0
    def test_register_all_actions(self):
        try:
            packs_base_path = fixtures_loader.get_fixtures_base_path()
            all_actions_in_db = Action.get_all()
            actions_registrar.register_actions(packs_base_paths=[packs_base_path])
        except Exception as e:
            print(six.text_type(e))
            self.fail("All actions must be registered without exceptions.")
        else:
            all_actions_in_db = Action.get_all()
            self.assertTrue(len(all_actions_in_db) > 0)

        # Assert metadata_file field is populated
        expected_path = "actions/action-with-no-parameters.yaml"
        self.assertEqual(all_actions_in_db[0].metadata_file, expected_path)
Ejemplo n.º 6
0
    def test_register_all_actions(self):
        try:
            packs_base_path = fixtures_loader.get_fixtures_base_path()
            all_actions_in_db = Action.get_all()
            actions_registrar.register_actions(packs_base_paths=[packs_base_path])
        except Exception as e:
            print(six.text_type(e))
            self.fail('All actions must be registered without exceptions.')
        else:
            all_actions_in_db = Action.get_all()
            self.assertTrue(len(all_actions_in_db) > 0)

        # Assert metadata_file field is populated
        expected_path = 'actions/action-with-no-parameters.yaml'
        self.assertEqual(all_actions_in_db[0].metadata_file, expected_path)
Ejemplo n.º 7
0
def register_actions():
    # Register runnertypes and actions. The order is important because actions require action
    # types to be present in the system.
    pack_dir = cfg.CONF.register.pack
    fail_on_failure = cfg.CONF.register.fail_on_failure

    registered_count = 0

    # 1. Register runner types
    try:
        LOG.info("=========================================================")
        LOG.info("############## Registering actions ######################")
        LOG.info("=========================================================")
        runners_registrar.register_runner_types(experimental=cfg.CONF.experimental)
    except Exception as e:
        LOG.warning("Failed to register runner types: %s", e, exc_info=True)
        LOG.warning("Not registering stock runners .")
        return

    # 2. Register actions
    try:
        registered_count = actions_registrar.register_actions(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 actions: %s", e, exc_info=exc_info)

        if fail_on_failure:
            raise e

    LOG.info("Registered %s actions." % (registered_count))
Ejemplo n.º 8
0
def register_actions():
    # Register runnertypes and actions. The order is important because actions require action
    # types to be present in the system.
    pack_dir = cfg.CONF.register.pack
    fail_on_failure = cfg.CONF.register.fail_on_failure

    registered_count = 0

    # 1. Register runner types
    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering actions ######################')
        LOG.info('=========================================================')
        runners_registrar.register_runner_types(
            experimental=cfg.CONF.experimental)
    except Exception as e:
        LOG.warning('Failed to register runner types: %s', e, exc_info=True)
        LOG.warning('Not registering stock runners .')
        return

    # 2. Register actions
    try:
        registered_count = actions_registrar.register_actions(
            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 actions: %s', e, exc_info=exc_info)

        if fail_on_failure:
            raise e

    LOG.info('Registered %s actions.' % (registered_count))
Ejemplo n.º 9
0
def register_actions():
    # Register runnertypes and actions. The order is important because actions require action
    # types to be present in the system.
    pack_dir = cfg.CONF.register.pack
    fail_on_failure = not cfg.CONF.register.no_fail_on_failure

    registered_count = 0
    overridden_count = 0

    try:
        LOG.info("=========================================================")
        LOG.info("############## Registering actions ######################")
        LOG.info("=========================================================")
        with Timer(key="st2.register.actions"):
            registered_count, overridden_count = actions_registrar.register_actions(
                pack_dir=pack_dir,
                fail_on_failure=fail_on_failure,
                use_runners_cache=True,
            )
    except Exception as e:
        exc_info = not fail_on_failure
        LOG.warning("Failed to register actions: %s", e, exc_info=exc_info)

        if fail_on_failure:
            raise e

    LOG.info("Registered %s actions." % (registered_count))
    LOG.info("%s actions had their metadata overridden." % (overridden_count))
Ejemplo n.º 10
0
def register_actions():
    # Register runnertypes and actions. The order is important because actions require action
    # types to be present in the system.
    pack_dir = cfg.CONF.register.pack
    fail_on_failure = not cfg.CONF.register.no_fail_on_failure

    registered_count = 0

    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering actions ######################')
        LOG.info('=========================================================')
        with Timer(key='st2.register.actions'):
            registered_count = actions_registrar.register_actions(
                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 actions: %s', e, exc_info=exc_info)

        if fail_on_failure:
            raise e

    LOG.info('Registered %s actions.' % (registered_count))
Ejemplo n.º 11
0
def register_actions():
    # Register runnertypes and actions. The order is important because actions require action
    # types to be present in the system.
    pack_dir = cfg.CONF.register.pack
    fail_on_failure = not cfg.CONF.register.no_fail_on_failure

    registered_count = 0

    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering actions ######################')
        LOG.info('=========================================================')
        with Timer(key='st2.register.actions'):
            registered_count = actions_registrar.register_actions(
                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 actions: %s', e, exc_info=exc_info)

        if fail_on_failure:
            raise e

    LOG.info('Registered %s actions.' % (registered_count))
Ejemplo n.º 12
0
def register_actions():
    # Register runnertypes and actions. The order is important because actions require action
    # types to be present in the system.
    registered_count = 0

    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering actions ######################')
        LOG.info('=========================================================')
        runners_registrar.register_runner_types(experimental=cfg.CONF.experimental)
    except Exception as e:
        LOG.warning('Failed to register runner types: %s', e, exc_info=True)
        LOG.warning('Not registering stock runners .')
    else:
        try:
            registered_count = actions_registrar.register_actions(pack_dir=cfg.CONF.register.pack)
        except Exception as e:
            LOG.warning('Failed to register actions: %s', e, exc_info=True)

    LOG.info('Registered %s actions.' % (registered_count))
Ejemplo n.º 13
0
def register_actions():
    # Register runnertypes and actions. The order is important because actions require action
    # types to be present in the system.
    registered_count = 0

    try:
        LOG.info('=========================================================')
        LOG.info('############## Registering actions ######################')
        LOG.info('=========================================================')
        runners_registrar.register_runner_types(
            experimental=cfg.CONF.experimental)
    except Exception as e:
        LOG.warning('Failed to register runner types: %s', e, exc_info=True)
        LOG.warning('Not registering stock runners .')
    else:
        try:
            registered_count = actions_registrar.register_actions(
                pack_dir=cfg.CONF.register.pack)
        except Exception as e:
            LOG.warning('Failed to register actions: %s', e, exc_info=True)

    LOG.info('Registered %s actions.' % (registered_count))
Ejemplo n.º 14
0
    def setUpClass(cls):
        super(PacksViewsControllerTestCase, cls).setUpClass()

        # Register local action and pack fixtures
        actions_registrar.register_actions(use_pack_cache=False)
Ejemplo n.º 15
0
    def setUpClass(cls):
        super(PacksViewsControllerTestCase, cls).setUpClass()

        # Register local action and pack fixtures
        actions_registrar.register_actions(use_pack_cache=False)