Merge "set default for gw conn info in nvp_networkgw extension"

This commit is contained in:
Jenkins 2013-06-16 10:18:48 +00:00 committed by Gerrit Code Review
commit f87f0bd7c2
2 changed files with 10 additions and 0 deletions

View File

@ -153,7 +153,14 @@ class NetworkGatewayMixin(nvp_networkgw.NetworkGatewayPluginBase):
for conn in network_gateway.network_connections] for conn in network_gateway.network_connections]
return self._fields(res, fields) return self._fields(res, fields)
def _set_mapping_info_defaults(self, mapping_info):
if not mapping_info.get('segmentation_type'):
mapping_info['segmentation_type'] = 'flat'
if not mapping_info.get('segmentation_id'):
mapping_info['segmentation_id'] = 0
def _validate_network_mapping_info(self, network_mapping_info): def _validate_network_mapping_info(self, network_mapping_info):
self._set_mapping_info_defaults(network_mapping_info)
network_id = network_mapping_info.get(NETWORK_ID) network_id = network_mapping_info.get(NETWORK_ID)
if not network_id: if not network_id:
raise exceptions.InvalidInput( raise exceptions.InvalidInput(

View File

@ -422,6 +422,9 @@ class NetworkGatewayDbTestCase(test_db_plugin.QuantumDbPluginV2TestCase):
def test_connect_and_disconnect_network(self): def test_connect_and_disconnect_network(self):
self._test_connect_and_disconnect_network('flat') self._test_connect_and_disconnect_network('flat')
def test_connect_and_disconnect_network_no_seg_type(self):
self._test_connect_and_disconnect_network(None)
def test_connect_and_disconnect_network_with_segmentation_id(self): def test_connect_and_disconnect_network_with_segmentation_id(self):
self._test_connect_and_disconnect_network('vlan', 999) self._test_connect_and_disconnect_network('vlan', 999)