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


Python RunnerTypeAPI.to_model方法代码示例

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


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

示例1: setup_runner

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
 def setup_runner(cls):
     test_runner = {
         'name': 'test-runner',
         'description': 'A test runner.',
         'enabled': True,
         'runner_parameters': {
             'runnerstr': {
                 'description': 'Foo str param.',
                 'type': 'string',
                 'default': 'defaultfoo'
             },
             'runnerint': {
                 'description': 'Foo int param.',
                 'type': 'number'
             },
             'runnerdummy': {
                 'description': 'Dummy param.',
                 'type': 'string',
                 'default': 'runnerdummy'
             },
             'runnerimmutable': {
                 'description': 'Immutable param.',
                 'type': 'string',
                 'default': 'runnerimmutable',
                 'immutable': True
             }
         },
         'runner_module': 'tests.test_runner'
     }
     runnertype_api = RunnerTypeAPI(**test_runner)
     RunnerContainerTest.runnertype_db = RunnerType.add_or_update(
         RunnerTypeAPI.to_model(runnertype_api))
     test_failingrunner = {
         'name': 'test-failingrunner',
         'description': 'A failing test runner.',
         'enabled': True,
         'runner_parameters': {
             'raise': {
                 'description': 'Foo str param.',
                 'type': 'boolean',
                 'default': True,
                 'immutable': True
             }
         },
         'runner_module': 'tests.test_runner'
     }
     runnertype_api = RunnerTypeAPI(**test_failingrunner)
     RunnerContainerTest.runnertype_db = RunnerType.add_or_update(
         RunnerTypeAPI.to_model(runnertype_api))
开发者ID:ojacques,项目名称:st2,代码行数:51,代码来源:test_runner_container.py

示例2: setup_runner

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
 def setup_runner(cls):
     test_runner = {
         'name': 'test-runner',
         'description': 'A test runner.',
         'enabled': True,
         'runner_parameters': {
             'runnerstr': {
                 'description': 'Foo str param.',
                 'type': 'string',
                 'default': 'defaultfoo'
             },
             'runnerint': {
                 'description': 'Foo int param.',
                 'type': 'number'
             },
             'runnerdummy': {
                 'description': 'Dummy param.',
                 'type': 'string',
                 'default': 'runnerdummy'
             }
         },
         'runner_module': 'tests.test_runner'
     }
     runnertype_api = RunnerTypeAPI(**test_runner)
     ActionDBUtilsTestCase.runnertype_db = RunnerType.add_or_update(
         RunnerTypeAPI.to_model(runnertype_api))
开发者ID:StackStorm,项目名称:st2,代码行数:28,代码来源:test_action_db_utils.py

示例3: setUpClass

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
 def setUpClass(cls):
     super(TestActionExecutionService, cls).setUpClass()
     cls.runner = RunnerTypeAPI(**RUNNER)
     cls.runnerdb = RunnerType.add_or_update(RunnerTypeAPI.to_model(cls.runner))
     cls.action = ActionAPI(**ACTION)
     cls.actiondb = Action.add_or_update(ActionAPI.to_model(cls.action))
     cls.container = RunnerContainer()
开发者ID:hejin,项目名称:st2,代码行数:9,代码来源:test_action.py

示例4: _setup_runner_models

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
 def _setup_runner_models(cls):
     test_runner = {
         'name': 'test-runner',
         'description': 'A test runner.',
         'enabled': True,
         'runner_parameters': {
             'runnerstr': {
                 'description': 'Foo str param.',
                 'type': 'string',
                 'default': 'defaultfoo'
             },
             'runnerint': {
                 'description': 'Foo int param.',
                 'type': 'number'
             },
             'runnerdummy': {
                 'description': 'Dummy param.',
                 'type': 'string',
                 'default': 'runnerdummy'
             },
             'runnerimmutable': {
                 'description': 'Immutable param.',
                 'type': 'string',
                 'default': 'runnerimmutable',
                 'immutable': True
             }
         },
         'runner_module': 'tests.test_runner'
     }
     runnertype_api = RunnerTypeAPI(**test_runner)
     ParamsUtilsTest.runnertype_db = RunnerTypeAPI.to_model(runnertype_api)
开发者ID:bjoernbessert,项目名称:st2,代码行数:33,代码来源:test_param_utils.py

示例5: register_runner_types

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
def register_runner_types():
    LOG.debug('Start : register default RunnerTypes.')

    for runnertype in RUNNER_TYPES:
        try:
            runnertype_db = get_runnertype_by_name(runnertype['name'])
            update = True
        except StackStormDBObjectNotFoundError:
            runnertype_db = None
            update = False

        runnertype_api = RunnerTypeAPI(**runnertype)
        runnertype_api.validate()
        runner_type_model = RunnerTypeAPI.to_model(runnertype_api)

        if runnertype_db:
            runner_type_model.id = runnertype_db.id

        try:
            runnertype_db = RunnerType.add_or_update(runner_type_model)

            extra = {'runnertype_db': runnertype_db}
            if update:
                LOG.audit('RunnerType updated. RunnerType %s', runnertype_db, extra=extra)
            else:
                LOG.audit('RunnerType created. RunnerType %s', runnertype_db, extra=extra)
        except Exception:
            LOG.exception('Unable to register runner type %s.', runnertype['name'])

    LOG.debug('End : register default RunnerTypes.')
开发者ID:BlazeMediaGroup,项目名称:st2,代码行数:32,代码来源:runnersregistrar.py

示例6: setUpClass

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
    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,代码行数:10,代码来源:test_stream.py

示例7: setUpClass

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
    def setUpClass(cls):
        super(TestActionAPIValidator, cls).setUpClass()

        runner_api_dict = fixture.ARTIFACTS['runners']['run-local']
        runner_api = RunnerTypeAPI(**runner_api_dict)
        runner_model = RunnerTypeAPI.to_model(runner_api)

        RunnerType.add_or_update(runner_model)
开发者ID:bjoernbessert,项目名称:st2,代码行数:10,代码来源:test_action_api_validator.py

示例8: register_runner_types

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
def register_runner_types(experimental=False):
    """
    :param experimental: True to also register experimental runners.
    :type experimental: ``bool``
    """
    LOG.debug('Start : register default RunnerTypes.')

    for runner_type in RUNNER_TYPES:
        runner_type = copy.deepcopy(runner_type)

        # For backward compatibility reasons, we also register runners under the old names
        runner_names = [runner_type['name']] + runner_type.get('aliases', [])
        for runner_name in runner_names:
            runner_type['name'] = runner_name
            runner_experimental = runner_type.get('experimental', False)

            if runner_experimental and not experimental:
                LOG.debug('Skipping experimental runner "%s"' % (runner_name))
                continue

            # Remove additional, non db-model attributes
            non_db_attributes = ['experimental', 'aliases']
            for attribute in non_db_attributes:
                if attribute in runner_type:
                    del runner_type[attribute]

            try:
                runner_type_db = get_runnertype_by_name(runner_name)
                update = True
            except StackStormDBObjectNotFoundError:
                runner_type_db = None
                update = False

            # Note: We don't want to overwrite "enabled" attribute which is already in the database
            # (aka we don't want to re-enable runner which has been disabled by the user)
            if runner_type_db and runner_type_db['enabled'] != runner_type['enabled']:
                runner_type['enabled'] = runner_type_db['enabled']

            runner_type_api = RunnerTypeAPI(**runner_type)
            runner_type_api.validate()
            runner_type_model = RunnerTypeAPI.to_model(runner_type_api)

            if runner_type_db:
                runner_type_model.id = runner_type_db.id

            try:
                runner_type_db = RunnerType.add_or_update(runner_type_model)

                extra = {'runner_type_db': runner_type_db}
                if update:
                    LOG.audit('RunnerType updated. RunnerType %s', runner_type_db, extra=extra)
                else:
                    LOG.audit('RunnerType created. RunnerType %s', runner_type_db, extra=extra)
            except Exception:
                LOG.exception('Unable to register runner type %s.', runner_type['name'])

    LOG.debug('End : register default RunnerTypes.')
开发者ID:Bala96,项目名称:st2,代码行数:59,代码来源:runnersregistrar.py

示例9: setUpClass

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
    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,代码行数:12,代码来源:test_util_mistral_dsl_transform.py

示例10: setUpClass

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
    def setUpClass(cls):
        super(MistralValidationControllerTest, 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:AlexeyDeyneko,项目名称:st2,代码行数:12,代码来源:test_validator_mistral.py

示例11: register_runner

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
def register_runner(runner_type, experimental):
    # For backward compatibility reasons, we also register runners under the old names
    runner_names = [runner_type['name']] + runner_type.get('aliases', [])
    for runner_name in runner_names:
        runner_type['name'] = runner_name
        runner_experimental = runner_type.get('experimental', False)

        if runner_experimental and not experimental:
            LOG.debug('Skipping experimental runner "%s"' % (runner_name))
            continue

        # Remove additional, non db-model attributes
        non_db_attributes = ['experimental', 'aliases']
        for attribute in non_db_attributes:
            if attribute in runner_type:
                del runner_type[attribute]

        try:
            runner_type_db = get_runnertype_by_name(runner_name)
            update = True
        except StackStormDBObjectNotFoundError:
            runner_type_db = None
            update = False

        # Note: We don't want to overwrite "enabled" attribute which is already in the database
        # (aka we don't want to re-enable runner which has been disabled by the user)
        if runner_type_db and runner_type_db['enabled'] != runner_type['enabled']:
            runner_type['enabled'] = runner_type_db['enabled']

        # If package is not provided, assume it's the same as module name for backward
        # compatibility reasons
        if not runner_type.get('runner_package', None):
            runner_type['runner_package'] = runner_type['runner_module']

        runner_type_api = RunnerTypeAPI(**runner_type)
        runner_type_api.validate()
        runner_type_model = RunnerTypeAPI.to_model(runner_type_api)

        if runner_type_db:
            runner_type_model.id = runner_type_db.id

        try:

            runner_type_db = RunnerType.add_or_update(runner_type_model)

            extra = {'runner_type_db': runner_type_db}
            if update:
                LOG.audit('RunnerType updated. RunnerType %s', runner_type_db, extra=extra)
            else:
                LOG.audit('RunnerType created. RunnerType %s', runner_type_db, extra=extra)
        except Exception:
            LOG.exception('Unable to register runner type %s.', runner_type['name'])
            return 0
    return 1
开发者ID:lyandut,项目名称:st2,代码行数:56,代码来源:runnersregistrar.py

示例12: setUpClass

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
    def setUpClass(cls):
        super(MistralValidationTest, 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))

        cls.validator = wf_validation_utils.get_validator()
开发者ID:azamsheriff,项目名称:st2,代码行数:14,代码来源:test_validator_mistral.py

示例13: register_runner_types

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
def register_runner_types(experimental=False):
    """
    :param experimental: True to also register experimental runners.
    :type experimental: ``bool``
    """
    LOG.debug("Start : register default RunnerTypes.")

    for runner_type in RUNNER_TYPES:
        runner_type = copy.deepcopy(runner_type)

        # For backward compatibility reasons, we also register runners under the old names
        runner_names = [runner_type["name"]] + runner_type.get("aliases", [])
        for runner_name in runner_names:
            runner_type["name"] = runner_name
            runner_experimental = runner_type.get("experimental", False)

            if runner_experimental and not experimental:
                LOG.debug('Skipping experimental runner "%s"' % (runner_name))
                continue

            # Remove additional, non db-model attributes
            non_db_attributes = ["experimental", "aliases"]
            for attribute in non_db_attributes:
                if attribute in runner_type:
                    del runner_type[attribute]

            try:
                runner_type_db = get_runnertype_by_name(runner_name)
                update = True
            except StackStormDBObjectNotFoundError:
                runner_type_db = None
                update = False

            runner_type_api = RunnerTypeAPI(**runner_type)
            runner_type_api.validate()
            runner_type_model = RunnerTypeAPI.to_model(runner_type_api)

            if runner_type_db:
                runner_type_model.id = runner_type_db.id

            try:
                runner_type_db = RunnerType.add_or_update(runner_type_model)

                extra = {"runner_type_db": runner_type_db}
                if update:
                    LOG.audit("RunnerType updated. RunnerType %s", runner_type_db, extra=extra)
                else:
                    LOG.audit("RunnerType created. RunnerType %s", runner_type_db, extra=extra)
            except Exception:
                LOG.exception("Unable to register runner type %s.", runner_type["name"])

    LOG.debug("End : register default RunnerTypes.")
开发者ID:ruslantum,项目名称:st2,代码行数:54,代码来源:runnersregistrar.py

示例14: setUpClass

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
    def setUpClass(cls):
        super(TestActionExecutionService, cls).setUpClass()
        cls.runner = RunnerTypeAPI(**RUNNER)
        cls.runnerdb = RunnerType.add_or_update(RunnerTypeAPI.to_model(cls.runner))

        runner_api = RunnerTypeAPI(**RUNNER_ACTION_CHAIN)
        RunnerType.add_or_update(RunnerTypeAPI.to_model(runner_api))

        cls.actions = {
            ACTION['name']: ActionAPI(**ACTION),
            ACTION_WORKFLOW['name']: ActionAPI(**ACTION_WORKFLOW),
            ACTION_OVR_PARAM['name']: ActionAPI(**ACTION_OVR_PARAM),
            ACTION_OVR_PARAM_MUTABLE['name']: ActionAPI(**ACTION_OVR_PARAM_MUTABLE),
            ACTION_OVR_PARAM_IMMUTABLE['name']: ActionAPI(**ACTION_OVR_PARAM_IMMUTABLE),
            ACTION_OVR_PARAM_BAD_ATTR['name']: ActionAPI(**ACTION_OVR_PARAM_BAD_ATTR),
            ACTION_OVR_PARAM_BAD_ATTR_NOOP['name']: ActionAPI(**ACTION_OVR_PARAM_BAD_ATTR_NOOP)
        }

        cls.actiondbs = {name: Action.add_or_update(ActionAPI.to_model(action))
                         for name, action in six.iteritems(cls.actions)}

        cls.container = RunnerContainer()
开发者ID:LindsayHill,项目名称:st2,代码行数:24,代码来源:test_action.py

示例15: setUpClass

# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import to_model [as 别名]
    def setUpClass(cls):
        super(ActionParamsUtilsTest, cls).setUpClass()

        cls.runnertype_dbs = {}
        cls.action_dbs = {}

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

        for _, fixture in six.iteritems(FIXTURES['actions']):
            instance = ActionAPI(**fixture)
            action_db = Action.add_or_update(ActionAPI.to_model(instance))
            cls.action_dbs[action_db.name] = action_db
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:17,代码来源:test_action_param_utils.py


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