The flat provider network would cause an exception when writing to
database. This is due to the fact that the DB expected an integer
and received an object instead.
Change-Id: Ib9d38711c0c2ef16d8bf74bfae44864a1bc272b1
Closes-bug: #
1324120
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'])
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:
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),
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 = utils.NetworkTypes.L3_EXT
expected = [('subnets', []), ('name', name), ('admin_state_up', True),