From: Salvatore Orlando Date: Thu, 23 May 2013 14:31:36 +0000 (+0200) Subject: set default for gw conn info in nvp_networkgw extension X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8761cf1e74cd0f4d7f01e19a9e225c932e6dd61e;p=openstack-build%2Fneutron-build.git set default for gw conn info in nvp_networkgw extension Bug 1183285 This patch simply guarantees default segmentation type and id in gateway connection info for the 'connect' and 'disconnect' actions are correctly set respectively to 'flat' and 0. Change-Id: I1b4e8274651e05f4681878ab70daef990ece901b --- diff --git a/quantum/plugins/nicira/nicira_networkgw_db.py b/quantum/plugins/nicira/nicira_networkgw_db.py index 9a89e8b93..1cca562a1 100644 --- a/quantum/plugins/nicira/nicira_networkgw_db.py +++ b/quantum/plugins/nicira/nicira_networkgw_db.py @@ -153,7 +153,14 @@ class NetworkGatewayMixin(nvp_networkgw.NetworkGatewayPluginBase): for conn in network_gateway.network_connections] 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): + self._set_mapping_info_defaults(network_mapping_info) network_id = network_mapping_info.get(NETWORK_ID) if not network_id: raise exceptions.InvalidInput( diff --git a/quantum/tests/unit/nicira/test_networkgw.py b/quantum/tests/unit/nicira/test_networkgw.py index 35a3a05dc..5e8ddfc14 100644 --- a/quantum/tests/unit/nicira/test_networkgw.py +++ b/quantum/tests/unit/nicira/test_networkgw.py @@ -422,6 +422,9 @@ class NetworkGatewayDbTestCase(test_db_plugin.QuantumDbPluginV2TestCase): def test_connect_and_disconnect_network(self): 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): self._test_connect_and_disconnect_network('vlan', 999)