Fix translated required properties

In the recent refactoring done in
I953a52e9b165d3ea4fb2fc57ceea8083c7f8f30c, we didn't handle translated
require properties correctly, forgetting to raise an error when the
property was required. This fixes that path.

Change-Id: If335ca193301d304963738773d10e7370d5b5d85
Closes-Bug: #1685808
This commit is contained in:
Thomas Herve 2017-04-26 15:08:34 +02:00
parent 7672c73eda
commit 536e26f31c
2 changed files with 9 additions and 0 deletions

View File

@ -503,6 +503,8 @@ class Properties(collections.Mapping):
template=template)
if value is not None or prop.has_default():
return prop.get_value(value)
elif prop.required():
raise ValueError(_('Property %s not assigned') % key)
elif prop.has_default():
return prop.get_value(None, validate, template=template,
translation=self.translation)

View File

@ -83,6 +83,13 @@ class NeutronPortTest(common.HeatTestCase):
self.find_mock = self.patchobject(
neutronV20, 'find_resourceid_by_name_or_id')
def test_missing_network(self):
t = template_format.parse(neutron_port_template)
t['resources']['port']['properties'] = {}
stack = utils.parse_stack(t)
port = stack['port']
self.assertRaises(exception.StackValidationFailed, port.validate)
def test_missing_subnet_id(self):
t = template_format.parse(neutron_port_template)
t['resources']['port']['properties']['fixed_ips'][0].pop('subnet')