コード例 #1
0
 def test_get_entry_point_absolute_path_empty(self):
     service = RunnerContainerService()
     orig_path = cfg.CONF.content.system_packs_base_path
     cfg.CONF.content.system_packs_base_path = "/tests/packs"
     acutal_path = service.get_entry_point_abs_path(pack="foo", entry_point=None)
     self.assertEqual(acutal_path, None, "Entry point path doesn't match.")
     acutal_path = service.get_entry_point_abs_path(pack="foo", entry_point="")
     self.assertEqual(acutal_path, None, "Entry point path doesn't match.")
     cfg.CONF.content.system_packs_base_path = orig_path
コード例 #2
0
 def test_get_entry_point_absolute_path_empty(self):
     service = RunnerContainerService()
     orig_path = cfg.CONF.content.system_packs_base_path
     cfg.CONF.content.system_packs_base_path = '/tests/packs'
     acutal_path = service.get_entry_point_abs_path(pack='foo', entry_point=None)
     self.assertEqual(acutal_path, None, 'Entry point path doesn\'t match.')
     acutal_path = service.get_entry_point_abs_path(pack='foo', entry_point='')
     self.assertEqual(acutal_path, None, 'Entry point path doesn\'t match.')
     cfg.CONF.content.system_packs_base_path = orig_path
コード例 #3
0
 def test_get_entry_point_absolute_path_empty(self):
     service = RunnerContainerService()
     orig_path = cfg.CONF.content.packs_base_path
     cfg.CONF.content.packs_base_path = '/tests/packs'
     acutal_path = service.get_entry_point_abs_path(pack='foo',
                                                    entry_point=None)
     self.assertEqual(acutal_path, None, 'Entry point path doesn\'t match.')
     acutal_path = service.get_entry_point_abs_path(pack='foo',
                                                    entry_point='')
     self.assertEqual(acutal_path, None, 'Entry point path doesn\'t match.')
     cfg.CONF.content.packs_base_path = orig_path
コード例 #4
0
def invoke_post_run(liveaction_db, action_db=None):
    LOG.info('Invoking post run for action execution %s.', liveaction_db.id)

    # Identify action and runner.
    if not action_db:
        action_db = action_db_utils.get_action_by_ref(liveaction_db.action)

    if not action_db:
        LOG.exception('Unable to invoke post run. Action %s no longer exists.',
                      liveaction_db.action)
        return

    LOG.info('Action execution %s runs %s of runner type %s.',
             liveaction_db.id, action_db.name, action_db.runner_type['name'])

    # Get an instance of the action runner.
    runnertype_db = action_db_utils.get_runnertype_by_name(
        action_db.runner_type['name'])
    runner = runners.get_runner(runnertype_db.runner_module)

    # Configure the action runner.
    runner.container_service = RunnerContainerService()
    runner.action = action_db
    runner.action_name = action_db.name
    runner.action_execution_id = str(liveaction_db.id)
    runner.entry_point = RunnerContainerService.get_entry_point_abs_path(
        pack=action_db.pack, entry_point=action_db.entry_point)
    runner.context = getattr(liveaction_db, 'context', dict())
    runner.callback = getattr(liveaction_db, 'callback', dict())
    runner.libs_dir_path = RunnerContainerService.get_action_libs_abs_path(
        pack=action_db.pack, entry_point=action_db.entry_point)

    # Invoke the post_run method.
    runner.post_run(liveaction_db.status, liveaction_db.result)
コード例 #5
0
 def test_get_entry_point_absolute_path(self):
     service = RunnerContainerService()
     orig_path = cfg.CONF.content.packs_base_path
     cfg.CONF.content.packs_base_path = '/tests/packs'
     acutal_path = service.get_entry_point_abs_path(pack='foo', entry_point='/foo/bar.py')
     self.assertEqual(acutal_path, '/foo/bar.py', 'Entry point path doesn\'t match.')
     cfg.CONF.content.packs_base_path = orig_path
コード例 #6
0
ファイル: base.py プロジェクト: Pulsant/st2
    def _invoke_post_run(self, actionexec_db, action_db):
        LOG.info(
            "Invoking post run for action execution %s. Action=%s; Runner=%s",
            actionexec_db.id,
            action_db.name,
            action_db.runner_type["name"],
        )

        # Get an instance of the action runner.
        runnertype_db = get_runnertype_by_name(action_db.runner_type["name"])
        runner = get_runner(runnertype_db.runner_module)

        # Configure the action runner.
        runner.container_service = RunnerContainerService()
        runner.action = action_db
        runner.action_name = action_db.name
        runner.action_execution_id = str(actionexec_db.id)
        runner.entry_point = RunnerContainerService.get_entry_point_abs_path(
            pack=action_db.pack, entry_point=action_db.entry_point
        )
        runner.context = getattr(actionexec_db, "context", dict())
        runner.callback = getattr(actionexec_db, "callback", dict())
        runner.libs_dir_path = RunnerContainerService.get_action_libs_abs_path(
            pack=action_db.pack, entry_point=action_db.entry_point
        )

        # Invoke the post_run method.
        runner.post_run(actionexec_db.status, actionexec_db.result)
コード例 #7
0
 def test_get_entry_point_relative_path(self):
     service = RunnerContainerService()
     orig_path = cfg.CONF.content.system_packs_base_path
     cfg.CONF.content.system_packs_base_path = "/tests/packs"
     acutal_path = service.get_entry_point_abs_path(pack="foo", entry_point="foo/bar.py")
     expected_path = os.path.join(cfg.CONF.content.system_packs_base_path, "foo", "actions", "foo/bar.py")
     self.assertEqual(acutal_path, expected_path, "Entry point path doesn't match.")
     cfg.CONF.content.system_packs_base_path = orig_path
コード例 #8
0
 def test_get_entry_point_relative_path(self):
     service = RunnerContainerService()
     orig_path = cfg.CONF.content.system_packs_base_path
     cfg.CONF.content.system_packs_base_path = '/tests/packs'
     acutal_path = service.get_entry_point_abs_path(pack='foo', entry_point='foo/bar.py')
     expected_path = os.path.join(cfg.CONF.content.system_packs_base_path, 'foo', 'actions',
                                  'foo/bar.py')
     self.assertEqual(acutal_path, expected_path, 'Entry point path doesn\'t match.')
     cfg.CONF.content.system_packs_base_path = orig_path
コード例 #9
0
 def test_get_entry_point_absolute_path(self):
     service = RunnerContainerService()
     orig_path = cfg.CONF.content.system_packs_base_path
     cfg.CONF.content.system_packs_base_path = '/tests/packs'
     acutal_path = service.get_entry_point_abs_path(
         pack='foo', entry_point='/foo/bar.py')
     self.assertEqual(acutal_path, '/foo/bar.py',
                      'Entry point path doesn\'t match.')
     cfg.CONF.content.system_packs_base_path = orig_path
コード例 #10
0
 def test_get_entry_point_relative_path(self):
     service = RunnerContainerService()
     orig_path = cfg.CONF.content.packs_base_path
     cfg.CONF.content.packs_base_path = '/tests/packs'
     acutal_path = service.get_entry_point_abs_path(
         pack='foo', entry_point='foo/bar.py')
     expected_path = os.path.join(cfg.CONF.content.packs_base_path, 'foo',
                                  'actions', 'foo/bar.py')
     self.assertEqual(acutal_path, expected_path,
                      'Entry point path doesn\'t match.')
     cfg.CONF.content.packs_base_path = orig_path
コード例 #11
0
ファイル: base.py プロジェクト: vishnu81/st2
    def _invoke_post_run(self, actionexec_db, action_db):
        LOG.info('Invoking post run for action execution %s. Action=%s; Runner=%s',
                 actionexec_db.id, action_db.name, action_db.runner_type['name'])

        # Get an instance of the action runner.
        runnertype_db = get_runnertype_by_name(action_db.runner_type['name'])
        runner = get_runner(runnertype_db.runner_module)

        # Configure the action runner.
        runner.container_service = RunnerContainerService()
        runner.action = action_db
        runner.action_name = action_db.name
        runner.action_execution_id = str(actionexec_db.id)
        runner.entry_point = RunnerContainerService.get_entry_point_abs_path(
            pack=action_db.pack, entry_point=action_db.entry_point)
        runner.context = getattr(actionexec_db, 'context', dict())
        runner.callback = getattr(actionexec_db, 'callback', dict())
        runner.libs_dir_path = RunnerContainerService.get_action_libs_abs_path(
            pack=action_db.pack, entry_point=action_db.entry_point)

        # Invoke the post_run method.
        runner.post_run(actionexec_db.status, actionexec_db.result)
コード例 #12
0
ファイル: actionviews.py プロジェクト: bjoernbessert/st2
    def get_one(self, action_id):
        """
            Outputs the file associated with action entry_point

            Handles requests:
                GET /actions/views/entry_point/1
        """
        LOG.info('GET /actions/views/overview with id=%s', action_id)
        action_db = LookupUtils._get_action_by_id(action_id)

        pack = getattr(action_db, 'pack', None)
        entry_point = getattr(action_db, 'entry_point', None)

        abs_path = RunnerContainerService.get_entry_point_abs_path(pack, entry_point)

        if not abs_path:
            raise StackStormDBObjectNotFoundError('Action id=%s has no entry_point to output'
                                                  % action_id)

        with open(abs_path) as file:
            content = file.read()

        return content
コード例 #13
0
ファイル: actionviews.py プロジェクト: gitter-badger/st2
    def get_one(self, action_id):
        """
            Outputs the file associated with action entry_point

            Handles requests:
                GET /actions/views/entry_point/1
        """
        LOG.info('GET /actions/views/overview with id=%s', action_id)
        action_db = LookupUtils._get_action_by_id(action_id)

        pack = getattr(action_db, 'pack', None)
        entry_point = getattr(action_db, 'entry_point', None)

        abs_path = RunnerContainerService.get_entry_point_abs_path(
            pack, entry_point)

        if not abs_path:
            raise StackStormDBObjectNotFoundError(
                'Action id=%s has no entry_point to output' % action_id)

        with open(abs_path) as file:
            content = file.read()

        return content
コード例 #14
0
ファイル: base.py プロジェクト: gitter-badger/st2
 def _get_entry_point_abs_path(self, pack, entry_point):
     return RunnerContainerService.get_entry_point_abs_path(
         pack=pack, entry_point=entry_point)
コード例 #15
0
ファイル: base.py プロジェクト: beryah/st2
 def _get_entry_point_abs_path(self, pack, entry_point):
     return RunnerContainerService.get_entry_point_abs_path(pack=pack,
                                                            entry_point=entry_point)