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


Python ActionDB.name方法代码示例

本文整理汇总了Python中st2common.models.db.action.ActionDB.name方法的典型用法代码示例。如果您正苦于以下问题:Python ActionDB.name方法的具体用法?Python ActionDB.name怎么用?Python ActionDB.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在st2common.models.db.action.ActionDB的用法示例。


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

示例1: setup_action_models

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
    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,代码行数:28,代码来源:test_runner_container.py

示例2: _register_action

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
    def _register_action(self, pack, action):
        content = self._meta_loader.load(action)
        action_ref = ResourceReference(pack=pack, name=str(content['name']))
        model = action_utils.get_action_by_ref(action_ref)
        if not model:
            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.', runner_type)
            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:nagyist,项目名称:StackStorm-st2,代码行数:28,代码来源:actionsregistrar.py

示例3: setup_action_models

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
    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.ref = ResourceReference(name=action_db.name, pack=action_db.pack).ref
        action_db.entry_point = ''
        action_db.runner_type = {'name': 'test-runner'}
        action_db.parameters = {
            'actionstr': {'type': 'string', 'position': 1, 'required': True},
            'actionint': {'type': 'number', 'default': 10, 'position': 0},
            'runnerdummy': {'type': 'string', 'default': 'actiondummy'}
        }
        ActionDBUtilsTestCase.action_db = Action.add_or_update(action_db)

        liveaction_db = LiveActionDB()
        liveaction_db.status = 'initializing'
        liveaction_db.start_timestamp = get_datetime_utc_now()
        liveaction_db.action = ActionDBUtilsTestCase.action_db.ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        liveaction_db.parameters = params
        ActionDBUtilsTestCase.liveaction_db = LiveAction.add_or_update(liveaction_db)
开发者ID:ipv1337,项目名称:st2,代码行数:29,代码来源:test_action_db_utils.py

示例4: _register_action

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
    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,代码行数:34,代码来源:actionsregistrar.py

示例5: _setup_action_models

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
 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', 'immutable': True},
         'runnerimmutable': {'type': 'string', 'default': 'failed_override'},
         'actionimmutable': {'type': 'string', 'default': 'actionimmutable', 'immutable': True}
     }
     ParamsUtilsTest.action_db = action_db
开发者ID:bjoernbessert,项目名称:st2,代码行数:18,代码来源:test_param_utils.py

示例6: _create_save_action

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
 def _create_save_action(runnertype, metadata=False):
     created = ActionDB()
     created.name = 'action-1'
     created.description = 'awesomeness'
     created.enabled = True
     created.entry_point = '/tmp/action.py'
     created.pack = 'wolfpack'
     created.ref = ResourceReference(pack=created.pack, name=created.name).ref
     created.runner_type = {'name': runnertype.name}
     if not metadata:
         created.parameters = {'p1': None, 'p2': None, 'p3': None}
     else:
         created.parameters = {
             'p1': {'type': 'string', 'required': True},
             'p2': {'type': 'number', 'default': 2868},
             'p3': {'type': 'boolean', 'default': False}
         }
     return Action.add_or_update(created)
开发者ID:srenatus,项目名称:st2,代码行数:20,代码来源:test_db.py

示例7: test_format_secret_action_parameters_are_masked

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
    def test_format_secret_action_parameters_are_masked(self):
        formatter = ConsoleLogFormatter()

        mock_message = 'test message 1'

        mock_action_db = ActionDB()
        mock_action_db.name = 'test.action'
        mock_action_db.pack = 'testpack'
        mock_action_db.parameters = {
            'parameter1': {
                'type': 'string',
                'required': False
            },
            'parameter2': {
                'type': 'string',
                'required': False,
                'secret': True
            }
        }

        mock_action_execution_db = ActionExecutionDB()
        mock_action_execution_db.action = mock_action_db.to_serializable_dict()
        mock_action_execution_db.parameters = {
            'parameter1': 'value1',
            'parameter2': 'value2'
        }

        record = MockRecord()
        record.msg = mock_message

        # Add "extra" attributes
        record._action_execution_db = mock_action_execution_db

        expected_msg_part = "'parameters': {'parameter1': 'value1', 'parameter2': '********'}"

        message = formatter.format(record=record)
        self.assertTrue('test message 1' in message)
        self.assertTrue(expected_msg_part in message)
开发者ID:ipv1337,项目名称:st2,代码行数:40,代码来源:test_logger.py

示例8: TriggerDB

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
import st2tests.config as tests_config

MOCK_TRIGGER = TriggerDB()
MOCK_TRIGGER.id = 'trigger-test.id'
MOCK_TRIGGER.name = 'trigger-test.name'
MOCK_TRIGGER.pack = 'dummypack1'

MOCK_TRIGGER_INSTANCE = TriggerInstanceDB()
MOCK_TRIGGER_INSTANCE.id = 'triggerinstance-test'
MOCK_TRIGGER_INSTANCE.trigger = reference.get_ref_from_model(MOCK_TRIGGER)
MOCK_TRIGGER_INSTANCE.payload = {}
MOCK_TRIGGER_INSTANCE.occurrence_time = datetime.datetime.utcnow()

MOCK_ACTION = ActionDB()
MOCK_ACTION.id = 'action-test-1.id'
MOCK_ACTION.name = 'action-test-1.name'

MOCK_ACTION_EXECUTION = ActionExecutionDB()
MOCK_ACTION_EXECUTION.id = 'actionexec-test-1.id'
MOCK_ACTION_EXECUTION.name = 'actionexec-test-1.name'
MOCK_ACTION_EXECUTION.status = 'scheduled'

MOCK_RULE_1 = RuleDB()
MOCK_RULE_1.id = 'rule-test-1'
MOCK_RULE_1.trigger = reference.get_str_resource_ref_from_model(MOCK_TRIGGER)
MOCK_RULE_1.criteria = {}
MOCK_RULE_1.action = ActionExecutionSpecDB()
MOCK_RULE_1.action.ref = reference.get_ref_from_model(MOCK_ACTION)
MOCK_RULE_1.enabled = True

MOCK_RULE_2 = RuleDB()
开发者ID:bjoernbessert,项目名称:st2,代码行数:33,代码来源:test_enforce.py

示例9: TriggerDB

# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import name [as 别名]
MOCK_TRIGGER = TriggerDB()
MOCK_TRIGGER.id = bson.ObjectId()
MOCK_TRIGGER.name = "trigger-test.name"
MOCK_TRIGGER.pack = "dummy_pack_1"
MOCK_TRIGGER.type = "system.test"

MOCK_TRIGGER_INSTANCE = TriggerInstanceDB()
MOCK_TRIGGER_INSTANCE.id = bson.ObjectId()
MOCK_TRIGGER_INSTANCE.trigger = MOCK_TRIGGER.get_reference().ref
MOCK_TRIGGER_INSTANCE.payload = {"p1": "v1", "p2": "preYYYpost", "bool": True, "int": 1, "float": 0.8}
MOCK_TRIGGER_INSTANCE.occurrence_time = date_utils.get_datetime_utc_now()

MOCK_ACTION = ActionDB()
MOCK_ACTION.id = bson.ObjectId()
MOCK_ACTION.name = "action-test-1.name"

MOCK_RULE_1 = RuleDB()
MOCK_RULE_1.id = bson.ObjectId()
MOCK_RULE_1.name = "some1"
MOCK_RULE_1.trigger = reference.get_str_resource_ref_from_model(MOCK_TRIGGER)
MOCK_RULE_1.criteria = {}
MOCK_RULE_1.action = ActionExecutionSpecDB(ref="somepack.someaction")

MOCK_RULE_2 = RuleDB()
MOCK_RULE_2.id = bson.ObjectId()
MOCK_RULE_1.name = "some2"
MOCK_RULE_2.trigger = reference.get_str_resource_ref_from_model(MOCK_TRIGGER)
MOCK_RULE_2.criteria = {}
MOCK_RULE_2.action = ActionExecutionSpecDB(ref="somepack.someaction")
开发者ID:ipv1337,项目名称:st2,代码行数:31,代码来源:test_filter.py


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