本文整理汇总了Python中st2common.persistence.action.Action.add_or_update方法的典型用法代码示例。如果您正苦于以下问题:Python Action.add_or_update方法的具体用法?Python Action.add_or_update怎么用?Python Action.add_or_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.persistence.action.Action
的用法示例。
在下文中一共展示了Action.add_or_update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
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))
示例2: setup_action_models
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [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)
示例3: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
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()
示例4: test_action_with_notify_crud
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
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.')
示例5: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
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))
示例6: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [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))
示例7: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
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))
示例8: test_request_disabled_action
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
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)
示例9: setUp
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
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)
示例10: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
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))
示例11: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [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))
示例12: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [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))
示例13: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [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()
示例14: setUpClass
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
def setUpClass(cls):
super(DSLTransformTestCase, cls).setUpClass()
runners_registrar.register_runner_types()
action_local = ActionAPI(**copy.deepcopy(FIXTURES['actions']['local.yaml']))
Action.add_or_update(ActionAPI.to_model(action_local))
for action_name in ['action1', 'action2', 'action3']:
metadata = copy.deepcopy(FIXTURES['actions']['local.yaml'])
metadata['name'] = action_name
metadata['pack'] = 'demo'
action = ActionAPI(**metadata)
Action.add_or_update(ActionAPI.to_model(action))
示例15: test_request_disabled_action
# 需要导入模块: from st2common.persistence.action import Action [as 别名]
# 或者: from st2common.persistence.action.Action import add_or_update [as 别名]
def test_request_disabled_action(self):
actiondb = self.actiondbs[ACTION['name']]
actiondb.enabled = False
Action.add_or_update(actiondb)
try:
parameters = {'hosts': 'localhost', 'cmd': 'uname -a'}
execution = LiveActionDB(action=ACTION_REF, parameters=parameters)
self.assertRaises(ValueError, action_service.request, execution)
except Exception as e:
raise e
finally:
actiondb.enabled = True
Action.add_or_update(actiondb)