当前位置: 首页>>代码示例>>Python>>正文


Python action.Action类代码示例

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


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

示例1: test_action_with_notify_crud

    def test_action_with_notify_crud(self):
        runnertype = self._create_save_runnertype(metadata=False)
        saved = self._create_save_action(runnertype, metadata=False)

        # Update action with notification settings
        on_complete = NotificationSubSchema(message='Action complete.')
        saved.notify = NotificationSchema(on_complete=on_complete)
        saved = Action.add_or_update(saved)

        # Check if notification settings were set correctly.
        retrieved = Action.get_by_id(saved.id)
        self.assertEqual(retrieved.notify.on_complete.message, on_complete.message)

        # Now reset notify in action to empty and validate it's gone.
        retrieved.notify = NotificationSchema(on_complete=None)
        saved = Action.add_or_update(retrieved)
        retrieved = Action.get_by_id(saved.id)
        self.assertEqual(retrieved.notify.on_complete, None)

        # cleanup
        self._delete([retrieved])
        try:
            retrieved = Action.get_by_id(saved.id)
        except ValueError:
            retrieved = None
        self.assertIsNone(retrieved, 'managed to retrieve after failure.')
开发者ID:bootinge,项目名称:st2,代码行数:26,代码来源:test_db.py

示例2: test_parameter_schema

    def test_parameter_schema(self):
        runnertype = self._create_save_runnertype(metadata=True)
        saved = self._create_save_action(runnertype, metadata=True)
        retrieved = Action.get_by_id(saved.id)

        # validate generated schema
        schema = util_schema.get_schema_for_action_parameters(retrieved)
        self.assertDictEqual(schema, PARAM_SCHEMA)
        validator = util_schema.get_validator()
        validator.check_schema(schema)

        # use schema to validate parameters
        jsonschema.validate({"r2": "abc", "p1": "def"}, schema, validator)
        jsonschema.validate({"r2": "abc", "p1": "def", "r1": {"r1a": "ghi"}}, schema, validator)
        self.assertRaises(jsonschema.ValidationError, jsonschema.validate,
                          '{"r2": "abc", "p1": "def"}', schema, validator)
        self.assertRaises(jsonschema.ValidationError, jsonschema.validate,
                          {"r2": "abc"}, schema, validator)
        self.assertRaises(jsonschema.ValidationError, jsonschema.validate,
                          {"r2": "abc", "p1": "def", "r1": 123}, schema, validator)

        # cleanup
        self._delete([retrieved])
        try:
            retrieved = Action.get_by_id(saved.id)
        except ValueError:
            retrieved = None
        self.assertIsNone(retrieved, 'managed to retrieve after failure.')
开发者ID:azamsheriff,项目名称:st2,代码行数:28,代码来源:test_db.py

示例3: setup_action_models

    def setup_action_models(cls):
        action_db = ActionDB()
        action_db.name = 'action-1'
        action_db.description = 'awesomeness'
        action_db.enabled = True
        action_db.pack = 'wolfpack'
        action_db.entry_point = ''
        action_db.runner_type = {'name': 'test-runner'}
        action_db.parameters = {
            'actionstr': {'type': 'string', 'required': True},
            'actionint': {'type': 'number', 'default': 10},
            'runnerdummy': {'type': 'string', 'default': 'actiondummy'},
            'runnerimmutable': {'type': 'string', 'default': 'failed_override'},
            'actionimmutable': {'type': 'string', 'default': 'actionimmutable', 'immutable': True}
        }
        RunnerContainerTest.action_db = Action.add_or_update(action_db)

        action_db = ActionDB()
        action_db.name = 'action-2'
        action_db.description = 'awesomeness'
        action_db.enabled = True
        action_db.pack = 'wolfpack'
        action_db.entry_point = ''
        action_db.runner_type = {'name': 'test-failingrunner'}
        action_db.parameters = {}
        RunnerContainerTest.failingaction_db = Action.add_or_update(action_db)
开发者ID:ojacques,项目名称:st2,代码行数:26,代码来源:test_runner_container.py

示例4: setUpClass

    def setUpClass(cls):
        super(ExecutionCancellationTestCase, cls).setUpClass()
        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))

        runners_registrar.register_runners()
开发者ID:nzlosh,项目名称:st2,代码行数:7,代码来源:test_execution_cancellation.py

示例5: delete

    def delete(self, action_ref_or_id):
        """
            Delete an action.

            Handles requests:
                POST /actions/1?_method=delete
                DELETE /actions/1
                DELETE /actions/mypack.myaction
        """
        action_db = self._get_by_ref_or_id(ref_or_id=action_ref_or_id)
        action_id = action_db.id

        try:
            validate_not_part_of_system_pack(action_db)
        except ValueValidationException as e:
            abort(http_client.BAD_REQUEST, str(e))

        LOG.debug('DELETE /actions/ lookup with ref_or_id=%s found object: %s',
                  action_ref_or_id, action_db)

        try:
            Action.delete(action_db)
        except Exception as e:
            LOG.error('Database delete encountered exception during delete of id="%s". '
                      'Exception was %s', action_id, e)
            abort(http_client.INTERNAL_SERVER_ERROR, str(e))
            return

        extra = {'action_db': action_db}
        LOG.audit('Action deleted. Action.id=%s' % (action_db.id), extra=extra)
        return None
开发者ID:jspittman,项目名称:st2,代码行数:31,代码来源:actions.py

示例6: tearDownClass

    def tearDownClass(cls):
        for actiondb in cls.actiondbs.values():
            Action.delete(actiondb)

        RunnerType.delete(cls.runnerdb)

        super(TestActionExecutionService, cls).tearDownClass()
开发者ID:logikal,项目名称:st2,代码行数:7,代码来源:test_action.py

示例7: setUpClass

    def setUpClass(cls):
        super(TestMistralRunner, cls).setUpClass()
        runners_registrar.register_runner_types()

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))
开发者ID:emptywee,项目名称:st2,代码行数:7,代码来源:test_mistral_v2.py

示例8: _register_action

    def _register_action(self, pack, action):
        with open(action, 'r') as fd:
            try:
                content = json.load(fd)
            except ValueError:
                LOG.exception('Failed loading action json from %s.', action)
                raise

            try:
                model = Action.get_by_name(str(content['name']))
            except ValueError:
                model = ActionDB()
            model.name = content['name']
            model.description = content['description']
            model.enabled = content['enabled']
            model.pack = pack
            model.entry_point = content['entry_point']
            model.parameters = content.get('parameters', {})
            runner_type = str(content['runner_type'])
            valid_runner_type, runner_type_db = self._has_valid_runner_type(runner_type)
            if valid_runner_type:
                model.runner_type = {'name': runner_type_db.name}
            else:
                LOG.exception('Runner type %s doesn\'t exist.')
                raise

            try:
                model = Action.add_or_update(model)
                LOG.audit('Action created. Action %s from %s.', model, action)
            except Exception:
                LOG.exception('Failed to write action to db %s.', model.name)
                raise
开发者ID:ojacques,项目名称:st2,代码行数:32,代码来源:actionsregistrar.py

示例9: setUpClass

 def setUpClass(cls):
     super(TestMistralRunner, cls).setUpClass()
     runners_registrar.register_runner_types()
     metadata = fixture.ARTIFACTS['metadata']
     action_local = ActionAPI(**copy.deepcopy(metadata['actions']['local']))
     Action.add_or_update(ActionAPI.to_model(action_local))
     action_wkflow = ActionAPI(**copy.deepcopy(metadata['actions']['workflow-v2']))
     Action.add_or_update(ActionAPI.to_model(action_wkflow))
开发者ID:bjoernbessert,项目名称:st2,代码行数:8,代码来源:test_mistral_v2.py

示例10: test_request_disabled_action

 def test_request_disabled_action(self):
     self.actiondb.enabled = False
     Action.add_or_update(self.actiondb)
     parameters = {'hosts': 'localhost', 'cmd': 'uname -a'}
     execution = LiveActionDB(action=ACTION_REF, parameters=parameters)
     self.assertRaises(ValueError, action_service.request, execution)
     self.actiondb.enabled = True
     Action.add_or_update(self.actiondb)
开发者ID:hejin,项目名称:st2,代码行数:8,代码来源:test_action.py

示例11: setUp

 def setUp(self):
     RUNNER_TYPE.id = None
     RunnerType.add_or_update(RUNNER_TYPE)
     ACTION.id = None
     ACTION.runner_type = {'name': RUNNER_TYPE.name}
     Action.add_or_update(ACTION)
     TRIGGER.id = None
     Trigger.add_or_update(TRIGGER)
开发者ID:ojacques,项目名称:st2,代码行数:8,代码来源:test_rules.py

示例12: setUpClass

 def setUpClass(cls):
     super(TestActionExecutionHistoryWorker, cls).setUpClass()
     runners_registrar.register_runners()
     action_local = ActionAPI(**copy.deepcopy(fixture.ARTIFACTS["actions"]["local"]))
     Action.add_or_update(ActionAPI.to_model(action_local))
     action_chain = ActionAPI(**copy.deepcopy(fixture.ARTIFACTS["actions"]["chain"]))
     action_chain.entry_point = fixture.PATH + "/chain.yaml"
     Action.add_or_update(ActionAPI.to_model(action_chain))
开发者ID:pixelrebel,项目名称:st2,代码行数:8,代码来源:test_executions.py

示例13: setUpClass

 def setUpClass(cls):
     super(TestActionExecutionHistoryWorker, cls).setUpClass()
     runners_registrar.register_runner_types()
     action_local = ActionAPI(**copy.deepcopy(fixture.ARTIFACTS['actions']['local']))
     Action.add_or_update(ActionAPI.to_model(action_local))
     action_chain = ActionAPI(**copy.deepcopy(fixture.ARTIFACTS['actions']['chain']))
     action_chain.entry_point = fixture.PATH + '/chain.yaml'
     Action.add_or_update(ActionAPI.to_model(action_chain))
开发者ID:Kailashkatheth1,项目名称:st2,代码行数:8,代码来源:test_executions.py

示例14: setUpClass

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

        instance = RunnerTypeAPI(**RUNNER_TYPE_1)
        RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        instance = ActionAPI(**ACTION_1)
        Action.add_or_update(ActionAPI.to_model(instance))
开发者ID:lyandut,项目名称:st2,代码行数:8,代码来源:test_stream.py

示例15: setUpClass

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

        for _, fixture in six.iteritems(FIXTURES['runners']):
            instance = RunnerTypeAPI(**fixture)
            RunnerType.add_or_update(RunnerTypeAPI.to_model(instance))

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            Action.add_or_update(ActionAPI.to_model(instance))
开发者ID:StackStorm,项目名称:st2,代码行数:10,代码来源:test_util_mistral_dsl_transform.py


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