Merge "Make 'server' property of SoftwareDeployment mandatory"

This commit is contained in:
Jenkins 2015-07-26 10:51:54 +00:00 committed by Gerrit Code Review
commit 6cfcbd902d
3 changed files with 21 additions and 0 deletions

View File

@ -126,6 +126,7 @@ class SoftwareDeployment(signal_responder.SignalResponder):
SERVER: properties.Schema( SERVER: properties.Schema(
properties.Schema.STRING, properties.Schema.STRING,
_('ID of Nova server to apply configuration to.'), _('ID of Nova server to apply configuration to.'),
required=True,
constraints=[ constraints=[
constraints.CustomConstraint('nova.server') constraints.CustomConstraint('nova.server')
] ]

View File

@ -146,6 +146,16 @@ class SoftwareDeploymentTest(common.HeatTestCase):
} }
} }
template_no_server = {
'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {
'deployment_mysql': {
'Type': 'OS::Heat::SoftwareDeployment',
'Properties': {}
}
}
}
def setUp(self): def setUp(self):
super(SoftwareDeploymentTest, self).setUp() super(SoftwareDeploymentTest, self).setUp()
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()
@ -184,6 +194,15 @@ class SoftwareDeploymentTest(common.HeatTestCase):
server = self.stack['server'] server = self.stack['server']
self.assertTrue(server.user_data_software_config()) self.assertTrue(server.user_data_software_config())
def test_validate_without_server(self):
stack = utils.parse_stack(self.template_no_server)
snip = stack.t.resource_definitions(stack)['deployment_mysql']
deployment = sd.SoftwareDeployment('deployment_mysql', snip, stack)
err = self.assertRaises(exc.StackValidationFailed, deployment.validate)
self.assertEqual("Property error: "
"Resources.deployment_mysql.Properties: "
"Property server not assigned", six.text_type(err))
def test_validate_failed(self): def test_validate_failed(self):
template = dict(self.template_with_server) template = dict(self.template_with_server)
props = template['Resources']['server']['Properties'] props = template['Resources']['server']['Properties']

View File

@ -170,6 +170,7 @@ class StructuredDeploymentDerivedTest(common.HeatTestCase):
super(StructuredDeploymentDerivedTest, self).setUp() super(StructuredDeploymentDerivedTest, self).setUp()
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()
props = { props = {
'server': '9f1f0e00-05d2-4ca5-8602-95021f19c9d0',
'input_values': {'bar': 'baz'}, 'input_values': {'bar': 'baz'},
} }
self.template['Resources']['deploy_mysql']['Properties'] = props self.template['Resources']['deploy_mysql']['Properties'] = props