本文整理汇总了Python中st2common.models.db.action.ActionDB.parameters方法的典型用法代码示例。如果您正苦于以下问题:Python ActionDB.parameters方法的具体用法?Python ActionDB.parameters怎么用?Python ActionDB.parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.models.db.action.ActionDB
的用法示例。
在下文中一共展示了ActionDB.parameters方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_action_models
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [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)
示例2: _register_action
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [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
示例3: setup_action_models
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [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)
示例4: _register_action
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [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
示例5: _create_save_action
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [as 别名]
def _create_save_action(runnertype, metadata=False):
name = 'action-1'
pack = 'wolfpack'
ref = ResourceReference(pack=pack, name=name).ref
created = ActionDB(name=name, description='awesomeness', enabled=True,
entry_point='/tmp/action.py', pack=pack,
ref=ref,
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)
示例6: _create_save_action
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [as 别名]
def _create_save_action(runnertype, metadata=False):
name = "action-1"
pack = "wolfpack"
ref = ResourceReference(pack=pack, name=name).ref
created = ActionDB(
name=name,
description="awesomeness",
enabled=True,
entry_point="/tmp/action.py",
pack=pack,
ref=ref,
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)
示例7: _setup_action_models
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [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
示例8: test_format_secret_action_parameters_are_masked
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [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)
示例9: test_command_construction_correct_default_parameter_values_are_used
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import parameters [as 别名]
def test_command_construction_correct_default_parameter_values_are_used(self):
runner_parameters = {}
action_db_parameters = {
'project': {
'type': 'string',
'default': 'st2',
'position': 0,
},
'version': {
'type': 'string',
'position': 1,
'required': True
},
'fork': {
'type': 'string',
'position': 2,
'default': 'StackStorm',
},
'branch': {
'type': 'string',
'position': 3,
'default': 'master',
},
'update_mistral': {
'type': 'boolean',
'position': 4,
'default': False
},
'update_changelog': {
'type': 'boolean',
'position': 5,
'default': False
},
'local_repo': {
'type': 'string',
'position': 6,
}
}
context = {}
action_db = ActionDB(pack='dummy', name='action')
runner = LocalShellScriptRunner('id')
runner.runner_parameters = {}
runner.action = action_db
# 1. All default values used
live_action_db_parameters = {
'project': 'st2flow',
'version': '3.0.0',
'fork': 'StackStorm',
'local_repo': '/tmp/repo'
}
runner_params, action_params = param_utils.render_final_params(runner_parameters,
action_db_parameters,
live_action_db_parameters,
context)
self.assertDictEqual(action_params, {
'project': 'st2flow',
'version': '3.0.0',
'fork': 'StackStorm',
'branch': 'master', # default value used
'update_mistral': False, # default value used
'update_changelog': False, # default value used
'local_repo': '/tmp/repo'
})
action_db.parameters = action_db_parameters
positional_args, named_args = runner._get_script_args(action_params)
named_args = runner._transform_named_args(named_args)
shell_script_action = ShellScriptAction(name='dummy', action_exec_id='dummy',
script_local_path_abs='/tmp/local.sh',
named_args=named_args,
positional_args=positional_args)
command_string = shell_script_action.get_full_command_string()
expected = '/tmp/local.sh st2flow 3.0.0 StackStorm master 0 0 /tmp/repo'
self.assertEqual(command_string, expected)
# 2. Some default values used
live_action_db_parameters = {
'project': 'st2web',
'version': '3.1.0',
'fork': 'StackStorm1',
'update_changelog': True,
'local_repo': '/tmp/repob'
}
runner_params, action_params = param_utils.render_final_params(runner_parameters,
action_db_parameters,
live_action_db_parameters,
context)
self.assertDictEqual(action_params, {
'project': 'st2web',
'version': '3.1.0',
'fork': 'StackStorm1',
#.........这里部分代码省略.........