Add show_resource function to Mistral resources (4)
AWS resources will not be changed due to they do not support additional attributes. So 'show' attribute will be presented in their schemas, but will return always None. This patch adds show_resource method for heat (mistral) resources: - workflow - cron trigger Change-Id: I10599a0eb45c99acb44414147d04734e740afcf0
This commit is contained in:
parent
457266f4c7
commit
7369444534
@ -89,6 +89,8 @@ class CronTrigger(resource.Resource):
|
||||
|
||||
default_client_name = 'mistral'
|
||||
|
||||
entity = 'cron_triggers'
|
||||
|
||||
def _cron_trigger_name(self):
|
||||
return self.properties.get(self.NAME) or self.physical_resource_name()
|
||||
|
||||
@ -126,6 +128,13 @@ class CronTrigger(resource.Resource):
|
||||
elif name == self.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():
|
||||
return {
|
||||
|
@ -32,6 +32,8 @@ class Workflow(signal_responder.SignalResponder,
|
||||
|
||||
default_client_name = 'mistral'
|
||||
|
||||
entity = 'workflows'
|
||||
|
||||
PROPERTIES = (
|
||||
NAME, TYPE, DESCRIPTION, INPUT, OUTPUT, TASKS, PARAMS
|
||||
) = (
|
||||
@ -406,6 +408,13 @@ class Workflow(signal_responder.SignalResponder,
|
||||
elif name == self.ALARM_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():
|
||||
return {
|
||||
|
@ -41,6 +41,7 @@ class FakeCronTrigger(object):
|
||||
self.name = name
|
||||
self.next_execution_time = '2015-03-01 00:00:00'
|
||||
self.remaining_executions = 3
|
||||
self._data = {'trigger': 'info'}
|
||||
|
||||
|
||||
class MistralCronTriggerTestResource(cron_trigger.CronTrigger):
|
||||
@ -98,6 +99,7 @@ class MistralCronTriggerTest(common.HeatTestCase):
|
||||
self.assertEqual('2015-03-01 00:00:00',
|
||||
ct.FnGetAtt('next_execution_time'))
|
||||
self.assertEqual(3, ct.FnGetAtt('remaining_executions'))
|
||||
self.assertEqual({'trigger': 'info'}, ct.FnGetAtt('show'))
|
||||
|
||||
def test_delete(self):
|
||||
ct = self._create_resource('trigger', self.rsrc_defn, self.stack)
|
||||
|
@ -173,6 +173,7 @@ resources:
|
||||
class FakeWorkflow(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self._data = {'workflow': 'info'}
|
||||
|
||||
|
||||
class MistralWorkFlowTestResource(workflow.Workflow):
|
||||
@ -247,9 +248,12 @@ class TestMistralWorkflow(common.HeatTestCase):
|
||||
|
||||
def test_attributes(self):
|
||||
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',
|
||||
'input': None}, wf.FnGetAtt('data'))
|
||||
self.assertEqual([], wf.FnGetAtt('executions'))
|
||||
self.assertEqual({'workflow': 'info'}, wf.FnGetAtt('show'))
|
||||
|
||||
def test_direct_workflow_validation_error(self):
|
||||
error_msg = ("Mistral resource validation error: "
|
||||
|
Loading…
x
Reference in New Issue
Block a user