Add nova.network constraint to ManilaShareNetwork
Add nova.network constraint for nova_network property validation. Change-Id: I9ae4f7f08ea2954f9fe35919602a5888a07636cf
This commit is contained in:
parent
c360efb2ac
commit
fb208526af
|
@ -63,7 +63,8 @@ class ManilaShareNetwork(resource.Resource):
|
|||
NOVA_NETWORK: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('Nova network id.'),
|
||||
update_allowed=True
|
||||
update_allowed=True,
|
||||
constraints=[constraints.CustomConstraint('nova.network')]
|
||||
),
|
||||
DESCRIPTION: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
|
|
|
@ -236,3 +236,7 @@ class HeatTestCase(testscenarios.WithScenarios,
|
|||
def stub_RouterConstraint_validate(self):
|
||||
validate = self.patchobject(neutron.RouterConstraint, 'validate')
|
||||
validate.return_value = True
|
||||
|
||||
def stub_NovaNetworkConstraint(self):
|
||||
validate = self.patchobject(nova.NetworkConstraint, 'validate')
|
||||
validate.return_value = True
|
||||
|
|
|
@ -17,7 +17,7 @@ import mock
|
|||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
from heat.engine import properties
|
||||
from heat.engine.clients.os import nova
|
||||
from heat.engine.resources.openstack.manila import share_network
|
||||
from heat.engine import scheduler
|
||||
from heat.tests import common
|
||||
|
@ -65,8 +65,9 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
|||
self.client_plugin = mock.Mock()
|
||||
self.patchobject(share_network.ManilaShareNetwork, 'client_plugin',
|
||||
return_value=self.client_plugin)
|
||||
self.patchobject(properties.Properties, 'validate',
|
||||
return_value=mock.Mock)
|
||||
self.stub_NetworkConstraint_validate()
|
||||
self.stub_NovaNetworkConstraint()
|
||||
self.stub_SubnetConstraint_validate()
|
||||
|
||||
def _create_network(self, name, snippet, stack):
|
||||
net = share_network.ManilaShareNetwork(name, snippet, stack)
|
||||
|
@ -189,6 +190,17 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
|||
self.assertRaisesRegexp(exception.ResourcePropertyConflict, msg,
|
||||
net.validate)
|
||||
|
||||
def test_nova_constraint_fail(self):
|
||||
validate = self.patchobject(nova.NetworkConstraint, 'validate')
|
||||
validate.return_value = False
|
||||
t = template_format.parse(stack_template)
|
||||
t['resources']['share_network']['properties']['nova_network'] = 1
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc_defn = stack.t.resource_definitions(stack)['share_network']
|
||||
self.assertRaises(exception.ResourceFailure,
|
||||
self._create_network, 'share_network',
|
||||
rsrc_defn, stack)
|
||||
|
||||
def test_attributes(self):
|
||||
net = self._create_network('share_network', self.rsrc_defn,
|
||||
self.stack)
|
||||
|
|
Loading…
Reference in New Issue