Skip to content

Commit

Permalink
neutron: remove deprecated allow_duplicate_networks config option
Browse files Browse the repository at this point in the history
Commit 4306d91 deprecated the
allow_duplicate_networks config option in Kilo and marked it for removal
in Liberty where the default behavior is to just allow duplicate
networks.

This simply removes the option and checks/tests around it being False.

DocImpact: Removed neutron.allow_duplicate_networks config option. The
           behavior in Liberty is now to simply allow duplicate
           networks.

Change-Id: Icb3510bcf0c30e11d0304a86ead91a43f37602ec
  • Loading branch information
Matt Riedemann committed Jun 18, 2015
1 parent 045ee03 commit b06867c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 74 deletions.
16 changes: 0 additions & 16 deletions nova/network/neutronv2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@
default=600,
help='Number of seconds before querying neutron for'
' extensions'),
cfg.BoolOpt('allow_duplicate_networks',
default=False,
help='DEPRECATED: Allow an instance to have multiple vNICs '
'attached to the same Neutron network. This option is '
'deprecated in the 2015.1 release and will be removed '
'in the 2015.2 release where the default behavior will '
'be to always allow multiple ports from the same network '
'to be attached to an instance.',
deprecated_for_removal=True),
]

NEUTRON_GROUP = 'neutron'
Expand Down Expand Up @@ -1049,7 +1040,6 @@ def _ports_needed_per_instance(self, context, neutron, requested_networks):
else:
ports_needed_per_instance = 1
else:
instance_on_net_ids = []
net_ids_requested = []

# TODO(danms): Remove me when all callers pass an object
Expand Down Expand Up @@ -1095,12 +1085,6 @@ def _ports_needed_per_instance(self, context, neutron, requested_networks):
address=request.address,
instance_uuid=i_uuid)

if (not CONF.neutron.allow_duplicate_networks and
request.network_id in instance_on_net_ids):
raise exception.NetworkDuplicated(
network_id=request.network_id)
instance_on_net_ids.append(request.network_id)

# Now check to see if all requested networks exist
if net_ids_requested:
nets = self._get_available_networks(
Expand Down
62 changes: 4 additions & 58 deletions nova/tests/unit/network/test_neutronv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,27 +1497,9 @@ def test_validate_networks_ex_2(self):
self.assertIn("my_netid2", six.text_type(ex))
self.assertIn("my_netid3", six.text_type(ex))

def test_validate_networks_duplicate_disable(self):
"""Verify that the correct exception is thrown when duplicate
network ids are passed to validate_networks, when nova config flag
allow_duplicate_networks is set to its default value: False
"""
requested_networks = [('my_netid1', None, None, None),
('my_netid1', None, None, None)]
self.mox.ReplayAll()
# Expected call from setUp.
neutronapi.get_client(None)
api = neutronapi.API()
self.assertRaises(exception.NetworkDuplicated,
api.validate_networks,
self.context, requested_networks, 1)

def test_validate_networks_duplicate_enable(self):
"""Verify that no duplicateNetworks exception is thrown when duplicate
network ids are passed to validate_networks, when nova config flag
allow_duplicate_networks is set to its non default value: True
"""
self.flags(allow_duplicate_networks=True, group='neutron')
# Verify that no duplicateNetworks exception is thrown when duplicate
# network ids are passed to validate_networks.
requested_networks = objects.NetworkRequestList(
objects=[objects.NetworkRequest(network_id='my_netid1'),
objects.NetworkRequest(network_id='my_netid1')])
Expand All @@ -1537,7 +1519,6 @@ def test_validate_networks_duplicate_enable(self):

def test_allocate_for_instance_with_requested_networks_duplicates(self):
# specify a duplicate network to allocate to instance
self.flags(allow_duplicate_networks=True, group='neutron')
requested_networks = objects.NetworkRequestList(
objects=[objects.NetworkRequest(network_id=net['id'])
for net in (self.nets6[0], self.nets6[1])])
Expand All @@ -1546,7 +1527,6 @@ def test_allocate_for_instance_with_requested_networks_duplicates(self):

def test_allocate_for_instance_requested_networks_duplicates_port(self):
# specify first port and last port that are in same network
self.flags(allow_duplicate_networks=True, group='neutron')
requested_networks = objects.NetworkRequestList(
objects=[objects.NetworkRequest(port_id=port['id'])
for port in (self.port_data1[0], self.port_data3[0])])
Expand All @@ -1555,7 +1535,6 @@ def test_allocate_for_instance_requested_networks_duplicates_port(self):

def test_allocate_for_instance_requested_networks_duplicates_combo(self):
# specify a combo net_idx=7 : net2, port in net1, net2, port in net1
self.flags(allow_duplicate_networks=True, group='neutron')
requested_networks = objects.NetworkRequestList(
objects=[objects.NetworkRequest(network_id='my_netid2'),
objects.NetworkRequest(port_id=self.port_data1[0]['id']),
Expand Down Expand Up @@ -1661,42 +1640,9 @@ def test_validate_networks_no_subnet_id(self):
api.validate_networks,
self.context, requested_networks, 1)

def test_validate_networks_ports_in_same_network_disable(self):
"""Verify that duplicateNetworks exception is thrown when ports on same
duplicate network are passed to validate_networks, when nova config
flag allow_duplicate_networks is set to its default False
"""
self.flags(allow_duplicate_networks=False, group='neutron')
port_a = self.port_data3[0]
port_a['fixed_ips'] = {'ip_address': '10.0.0.2',
'subnet_id': 'subnet_id'}
port_b = self.port_data1[0]
self.assertEqual(port_a['network_id'], port_b['network_id'])
for port in [port_a, port_b]:
port['device_id'] = None
port['device_owner'] = None

requested_networks = objects.NetworkRequestList(
objects=[objects.NetworkRequest(port_id=port_a['id']),
objects.NetworkRequest(port_id=port_b['id'])])
self.moxed_client.show_port(port_a['id']).AndReturn(
{'port': port_a})
self.moxed_client.show_port(port_b['id']).AndReturn(
{'port': port_b})

self.mox.ReplayAll()

api = neutronapi.API()
self.assertRaises(exception.NetworkDuplicated,
api.validate_networks,
self.context, requested_networks, 1)

def test_validate_networks_ports_in_same_network_enable(self):
"""Verify that duplicateNetworks exception is not thrown when ports
on same duplicate network are passed to validate_networks, when nova
config flag allow_duplicate_networks is set to its True
"""
self.flags(allow_duplicate_networks=True, group='neutron')
# Verify that duplicateNetworks exception is not thrown when ports
# on same duplicate network are passed to validate_networks.
port_a = self.port_data3[0]
port_a['fixed_ips'] = {'ip_address': '10.0.0.2',
'subnet_id': 'subnet_id'}
Expand Down

0 comments on commit b06867c

Please sign in to comment.