Merge "NSX: fix bug for flat provider network" into stable/icehouse

This commit is contained in:
Jenkins 2014-06-09 02:56:23 +00:00 committed by Gerrit Code Review
commit 7bb64b3e63
3 changed files with 20 additions and 3 deletions

View File

@ -1003,11 +1003,15 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
isinstance(provider_type, bool)):
net_bindings = []
for tz in net_data[mpnet.SEGMENTS]:
segmentation_id = tz.get(pnet.SEGMENTATION_ID, 0)
segmentation_id_set = attr.is_attr_set(segmentation_id)
if not segmentation_id_set:
segmentation_id = 0
net_bindings.append(nsx_db.add_network_binding(
context.session, new_net['id'],
tz.get(pnet.NETWORK_TYPE),
tz.get(pnet.PHYSICAL_NETWORK),
tz.get(pnet.SEGMENTATION_ID, 0)))
segmentation_id))
if provider_type:
nsx_db.set_multiprovider_network(context.session,
new_net['id'])

View File

@ -68,6 +68,19 @@ class TestMultiProviderNetworks(NsxPluginV2TestCase):
self.assertEqual(network['network'][pnet.SEGMENTATION_ID], 1)
self.assertNotIn(mpnet.SEGMENTS, network['network'])
def test_create_network_provider_flat(self):
data = {'network': {'name': 'net1',
pnet.NETWORK_TYPE: 'flat',
pnet.PHYSICAL_NETWORK: 'physnet1',
'tenant_id': 'tenant_one'}}
network_req = self.new_create_request('networks', data)
network = self.deserialize(self.fmt,
network_req.get_response(self.api))
self.assertEqual('flat', network['network'][pnet.NETWORK_TYPE])
self.assertEqual('physnet1', network['network'][pnet.PHYSICAL_NETWORK])
self.assertEqual(0, network['network'][pnet.SEGMENTATION_ID])
self.assertNotIn(mpnet.SEGMENTS, network['network'])
def test_create_network_single_multiple_provider(self):
data = {'network': {'name': 'net1',
mpnet.SEGMENTS:

View File

@ -242,7 +242,7 @@ class TestPortsV2(NsxPluginV2TestCase,
class TestNetworksV2(test_plugin.TestNetworksV2, NsxPluginV2TestCase):
def _test_create_bridge_network(self, vlan_id=None):
def _test_create_bridge_network(self, vlan_id=0):
net_type = vlan_id and 'vlan' or 'flat'
name = 'bridge_net'
expected = [('subnets', []), ('name', name), ('admin_state_up', True),
@ -478,7 +478,7 @@ class TestL3NatTestCase(L3NatTest,
test_l3_plugin.L3NatDBIntTestCase,
NsxPluginV2TestCase):
def _test_create_l3_ext_network(self, vlan_id=None):
def _test_create_l3_ext_network(self, vlan_id=0):
name = 'l3_ext_net'
net_type = NetworkTypes.L3_EXT
expected = [('subnets', []), ('name', name), ('admin_state_up', True),