Merge "Add show_resource function to Mistral resources (4)"
This commit is contained in:
commit
f1d76c07f6
@ -89,6 +89,8 @@ class CronTrigger(resource.Resource):
|
|||||||
|
|
||||||
default_client_name = 'mistral'
|
default_client_name = 'mistral'
|
||||||
|
|
||||||
|
entity = 'cron_triggers'
|
||||||
|
|
||||||
def _cron_trigger_name(self):
|
def _cron_trigger_name(self):
|
||||||
return self.properties.get(self.NAME) or self.physical_resource_name()
|
return self.properties.get(self.NAME) or self.physical_resource_name()
|
||||||
|
|
||||||
@ -126,6 +128,13 @@ class CronTrigger(resource.Resource):
|
|||||||
elif name == self.REMAINING_EXECUTIONS:
|
elif name == self.REMAINING_EXECUTIONS:
|
||||||
return trigger.remaining_executions
|
return trigger.remaining_executions
|
||||||
|
|
||||||
|
# TODO(tlashchova): remove this method when mistralclient>1.0.0 is used.
|
||||||
|
def _show_resource(self):
|
||||||
|
cron_trigger = self.client().cron_triggers.get(self.resource_id)
|
||||||
|
if hasattr(cron_trigger, 'to_dict'):
|
||||||
|
super(CronTrigger, self)._show_resource()
|
||||||
|
return cron_trigger._data
|
||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
return {
|
return {
|
||||||
|
@ -32,6 +32,8 @@ class Workflow(signal_responder.SignalResponder,
|
|||||||
|
|
||||||
default_client_name = 'mistral'
|
default_client_name = 'mistral'
|
||||||
|
|
||||||
|
entity = 'workflows'
|
||||||
|
|
||||||
PROPERTIES = (
|
PROPERTIES = (
|
||||||
NAME, TYPE, DESCRIPTION, INPUT, OUTPUT, TASKS, PARAMS
|
NAME, TYPE, DESCRIPTION, INPUT, OUTPUT, TASKS, PARAMS
|
||||||
) = (
|
) = (
|
||||||
@ -406,6 +408,13 @@ class Workflow(signal_responder.SignalResponder,
|
|||||||
elif name == self.ALARM_URL:
|
elif name == self.ALARM_URL:
|
||||||
return six.text_type(self._get_ec2_signed_url())
|
return six.text_type(self._get_ec2_signed_url())
|
||||||
|
|
||||||
|
# TODO(tlashchova): remove this method when mistralclient>1.0.0 is used.
|
||||||
|
def _show_resource(self):
|
||||||
|
workflow = self.client().workflows.get(self.resource_id)
|
||||||
|
if hasattr(workflow, 'to_dict'):
|
||||||
|
super(Workflow, self)._show_resource()
|
||||||
|
return workflow._data
|
||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
return {
|
return {
|
||||||
|
@ -41,6 +41,7 @@ class FakeCronTrigger(object):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.next_execution_time = '2015-03-01 00:00:00'
|
self.next_execution_time = '2015-03-01 00:00:00'
|
||||||
self.remaining_executions = 3
|
self.remaining_executions = 3
|
||||||
|
self._data = {'trigger': 'info'}
|
||||||
|
|
||||||
|
|
||||||
class MistralCronTriggerTestResource(cron_trigger.CronTrigger):
|
class MistralCronTriggerTestResource(cron_trigger.CronTrigger):
|
||||||
@ -98,6 +99,7 @@ class MistralCronTriggerTest(common.HeatTestCase):
|
|||||||
self.assertEqual('2015-03-01 00:00:00',
|
self.assertEqual('2015-03-01 00:00:00',
|
||||||
ct.FnGetAtt('next_execution_time'))
|
ct.FnGetAtt('next_execution_time'))
|
||||||
self.assertEqual(3, ct.FnGetAtt('remaining_executions'))
|
self.assertEqual(3, ct.FnGetAtt('remaining_executions'))
|
||||||
|
self.assertEqual({'trigger': 'info'}, ct.FnGetAtt('show'))
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
ct = self._create_resource('trigger', self.rsrc_defn, self.stack)
|
ct = self._create_resource('trigger', self.rsrc_defn, self.stack)
|
||||||
|
@ -173,6 +173,7 @@ resources:
|
|||||||
class FakeWorkflow(object):
|
class FakeWorkflow(object):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self._data = {'workflow': 'info'}
|
||||||
|
|
||||||
|
|
||||||
class MistralWorkFlowTestResource(workflow.Workflow):
|
class MistralWorkFlowTestResource(workflow.Workflow):
|
||||||
@ -247,9 +248,12 @@ class TestMistralWorkflow(common.HeatTestCase):
|
|||||||
|
|
||||||
def test_attributes(self):
|
def test_attributes(self):
|
||||||
wf = self._create_resource('workflow', self.rsrc_defn, self.stack)
|
wf = self._create_resource('workflow', self.rsrc_defn, self.stack)
|
||||||
|
self.mistral.workflows.get.return_value = \
|
||||||
|
FakeWorkflow('test_stack-workflow-b5fiekfci3yc')
|
||||||
self.assertEqual({'name': 'test_stack-workflow-b5fiekfci3yc',
|
self.assertEqual({'name': 'test_stack-workflow-b5fiekfci3yc',
|
||||||
'input': None}, wf.FnGetAtt('data'))
|
'input': None}, wf.FnGetAtt('data'))
|
||||||
self.assertEqual([], wf.FnGetAtt('executions'))
|
self.assertEqual([], wf.FnGetAtt('executions'))
|
||||||
|
self.assertEqual({'workflow': 'info'}, wf.FnGetAtt('show'))
|
||||||
|
|
||||||
def test_direct_workflow_validation_error(self):
|
def test_direct_workflow_validation_error(self):
|
||||||
error_msg = ("Mistral resource validation error: "
|
error_msg = ("Mistral resource validation error: "
|
||||||
|
Loading…
Reference in New Issue
Block a user