Merge "Fixes name generation for Heat stack"
This commit is contained in:
commit
17bd293076
@ -41,13 +41,16 @@ Properties:
|
||||
Methods:
|
||||
initialize:
|
||||
Body:
|
||||
- $heatStackName: $.getAttr(heatStackName)
|
||||
- If: $heatStackName = null
|
||||
- $generatedEnvironmentName: $.getAttr(generatedEnvironmentName)
|
||||
- If: $generatedEnvironmentName = null
|
||||
Then:
|
||||
- $heatStackName: randomName()
|
||||
- $.setAttr(heatStackName, $heatStackName)
|
||||
- $this.agentListener: new(sys:AgentListener, name => $heatStackName)
|
||||
- $this.stack: new(sys:HeatStack, name => $.name)
|
||||
- $generatedEnvironmentName: randomName()
|
||||
- $.setAttr(generatedEnvironmentName, $generatedEnvironmentName)
|
||||
- $this.agentListener: new(sys:AgentListener, name => $generatedEnvironmentName)
|
||||
- $stackDescriptionFormat: 'This stack was generated by Murano for environment {0} (ID: {1})'
|
||||
- $this.stack: new(sys:HeatStack,
|
||||
name => 'murano-' + $generatedEnvironmentName,
|
||||
description => $stackDescriptionFormat.format($.name, $.id()))
|
||||
- $this.instanceNotifier: new(sys:InstanceNotifier, environment => $this)
|
||||
- $this.reporter: new(sys:StatusReporter, environment => $this)
|
||||
- $this.securityGroupManager: new(sys:SecurityGroupManager, environment => $this)
|
||||
|
@ -35,11 +35,12 @@ class HeatStackError(Exception):
|
||||
|
||||
@murano_class.classname('io.murano.system.HeatStack')
|
||||
class HeatStack(murano_object.MuranoObject):
|
||||
def initialize(self, _context, name):
|
||||
def initialize(self, _context, name, description=None):
|
||||
self._name = name
|
||||
self._template = None
|
||||
self._parameters = {}
|
||||
self._applied = True
|
||||
self._description = description
|
||||
environment = helpers.get_environment(_context)
|
||||
keystone_settings = config.CONF.keystone
|
||||
heat_settings = config.CONF.heat
|
||||
@ -184,6 +185,9 @@ class HeatStack(murano_object.MuranoObject):
|
||||
if 'heat_template_version' not in self._template:
|
||||
self._template['heat_template_version'] = HEAT_TEMPLATE_VERSION
|
||||
|
||||
if 'description' not in self._template and self._description:
|
||||
self._template['description'] = self._description
|
||||
|
||||
LOG.info('Pushing: {0}'.format(self._template))
|
||||
|
||||
current_status = self._get_status()
|
||||
|
@ -45,6 +45,41 @@ class TestHeatStack(base.MuranoTestCase):
|
||||
None, None, None)
|
||||
hs._heat_client = mock_heat_client
|
||||
hs._name = 'test-stack'
|
||||
hs._description = 'Generated by TestHeatStack'
|
||||
hs._template = {'resources': {'test': 1}}
|
||||
hs._parameters = {}
|
||||
hs._applied = False
|
||||
hs.push()
|
||||
|
||||
expected_template = {
|
||||
'heat_template_version': '2013-05-23',
|
||||
'description': 'Generated by TestHeatStack',
|
||||
'resources': {'test': 1}
|
||||
}
|
||||
mock_heat_client.stacks.create.assert_called_with(
|
||||
stack_name='test-stack',
|
||||
disable_rollback=False,
|
||||
parameters={},
|
||||
template=expected_template
|
||||
)
|
||||
self.assertTrue(hs._applied)
|
||||
|
||||
@mock.patch('heatclient.client.Client')
|
||||
def test_description_is_optional(self, mock_heat_client):
|
||||
"""Assert that if heat_template_version is omitted, it's added"""
|
||||
# Note that the 'with x as y, a as b:' syntax was introduced in
|
||||
# python 2.7, and contextlib.nested was deprecated in py2.7
|
||||
with mock.patch(MOD_NAME + '.HeatStack._get_status') as status_get:
|
||||
with mock.patch(MOD_NAME + '.HeatStack._wait_state') as wait_st:
|
||||
|
||||
status_get.return_value = 'NOT_FOUND'
|
||||
wait_st.return_value = {}
|
||||
|
||||
hs = heat_stack.HeatStack(self.mock_murano_obj,
|
||||
None, None, None)
|
||||
hs._heat_client = mock_heat_client
|
||||
hs._name = 'test-stack'
|
||||
hs._description = None
|
||||
hs._template = {'resources': {'test': 1}}
|
||||
hs._parameters = {}
|
||||
hs._applied = False
|
||||
@ -68,6 +103,7 @@ class TestHeatStack(base.MuranoTestCase):
|
||||
hs = heat_stack.HeatStack(self.mock_murano_obj,
|
||||
None, None, None)
|
||||
hs._name = 'test-stack'
|
||||
hs._description = 'Generated by TestHeatStack'
|
||||
hs._template = {'resources': {'test': 1}}
|
||||
hs.type.properties = {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user