Network validation in Manila
Added new validation checks. If client is using neutron, manila expects both neutron net and neutron subnet properties OR their absense. Nova network is only expected when neutron is not used. Change-Id: I7c259d7b2c9c4ed554bca89ef3d286c25716a33b
This commit is contained in:
parent
6c9f33dade
commit
db90ea27ba
|
@ -128,6 +128,16 @@ class ManilaShareNetwork(resource.Resource):
|
|||
raise exception.ResourcePropertyConflict(self.NEUTRON_SUBNET,
|
||||
self.NOVA_NETWORK)
|
||||
|
||||
if self.is_using_neutron() and self.properties[self.NOVA_NETWORK]:
|
||||
msg = _('With Neutron enabled you need to pass Neutron network '
|
||||
'and Neutron subnet instead of Nova network')
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
||||
if (self.properties[self.NEUTRON_NETWORK] and not
|
||||
self.properties[self.NEUTRON_SUBNET]):
|
||||
raise exception.ResourcePropertyDependency(
|
||||
prop1=self.NEUTRON_NETWORK, prop2=self.NEUTRON_SUBNET)
|
||||
|
||||
if (self.properties[self.NEUTRON_NETWORK] and
|
||||
self.properties[self.NEUTRON_SUBNET]):
|
||||
plg = self.client_plugin('neutron')
|
||||
|
|
|
@ -251,6 +251,30 @@ class ManilaShareNetworkTest(common.HeatTestCase):
|
|||
self.assertRaisesRegexp(exception.ResourcePropertyConflict, msg,
|
||||
net.validate)
|
||||
|
||||
def test_nova_net_while_using_neutron(self):
|
||||
t = template_format.parse(stack_template)
|
||||
t['resources']['share_network']['properties']['nova_network'] = 'n'
|
||||
del t['resources']['share_network']['properties']['neutron_network']
|
||||
del t['resources']['share_network']['properties']['neutron_subnet']
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc_defn = stack.t.resource_definitions(stack)['share_network']
|
||||
net = self._create_network('share_network', rsrc_defn, stack)
|
||||
net.is_using_neutron = mock.Mock(return_value=True)
|
||||
msg = ('With Neutron enabled you need to pass Neutron network '
|
||||
'and Neutron subnet instead of Nova network')
|
||||
self.assertRaisesRegexp(exception.StackValidationFailed, msg,
|
||||
net.validate)
|
||||
|
||||
def test_neutron_net_without_neutron_subnet(self):
|
||||
t = template_format.parse(stack_template)
|
||||
del t['resources']['share_network']['properties']['neutron_subnet']
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc_defn = stack.t.resource_definitions(stack)['share_network']
|
||||
net = self._create_network('share_network', rsrc_defn, stack)
|
||||
msg = ('neutron_network cannot be specified without neutron_subnet.')
|
||||
self.assertRaisesRegexp(exception.ResourcePropertyDependency, msg,
|
||||
net.validate)
|
||||
|
||||
def test_nova_constraint_fail(self):
|
||||
validate = self.patchobject(nova.NetworkConstraint, 'validate')
|
||||
validate.return_value = False
|
||||
|
|
Loading…
Reference in New Issue