From f9f95ae0ac8e737210df6d21ed80699c1f4861c2 Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Tue, 10 Feb 2015 12:00:24 +0000 Subject: [PATCH] default to no network-device-mtu --- config.yaml | 4 ++-- hooks/quantum_contexts.py | 11 +++++++---- templates/ext-port.conf | 2 +- unit_tests/test_quantum_contexts.py | 10 +++++----- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/config.yaml b/config.yaml index ac543d3c..580987cd 100644 --- a/config.yaml +++ b/config.yaml @@ -156,8 +156,8 @@ options: HA Cluster nodes. phy-nic-mtu: type: int - default: 1500 + default: 0 description: | To improve network performance of VM, sometimes we should keep VM MTU as 1500 and use charm to modify MTU of tunnel nic more than 1500 (e.g. 1546 - for GRE). + for GRE). A value of zero means no mtu will be set/modified. diff --git a/hooks/quantum_contexts.py b/hooks/quantum_contexts.py index eb52dca4..6e8769a1 100644 --- a/hooks/quantum_contexts.py +++ b/hooks/quantum_contexts.py @@ -176,12 +176,15 @@ class L3AgentContext(OSContextGenerator): class ExternalPortContext(NeutronPortContext): def __call__(self): + ctxt = {} port = self.resolve_port('ext-port') if port: - return {"ext_port": port, - "mtu": config('phy-nic-mtu')} - else: - return None + ctxt = {"ext_port": port} + mtu = config('phy-nic-mtu') + if mtu: + ctxt['ext_port_mtu'] = mtu + + return ctxt class DataPortContext(NeutronPortContext): diff --git a/templates/ext-port.conf b/templates/ext-port.conf index 41bafc49..1d850240 100644 --- a/templates/ext-port.conf +++ b/templates/ext-port.conf @@ -6,7 +6,7 @@ task script EXT_PORT="{{ ext_port }}" - MTU="{{ mtu }}" + MTU="{{ ext_port_mtu }}" if [ -n "$EXT_PORT" ]; then ip link set $EXT_PORT up if [ -n "$MTU" ]; then diff --git a/unit_tests/test_quantum_contexts.py b/unit_tests/test_quantum_contexts.py index be8c23bb..f3f8b00e 100644 --- a/unit_tests/test_quantum_contexts.py +++ b/unit_tests/test_quantum_contexts.py @@ -144,7 +144,7 @@ class TestNeutronPortContext(CharmTestCase): def test_no_ext_port(self, mock_config): self.config.side_effect = config = self.fake_config({}) mock_config.side_effect = config - self.assertIsNone(quantum_contexts.ExternalPortContext()()) + self.assertEquals(quantum_contexts.ExternalPortContext()(), {}) @patch('charmhelpers.contrib.openstack.context.config') def test_ext_port_eth(self, mock_config): @@ -152,7 +152,7 @@ class TestNeutronPortContext(CharmTestCase): self.config.side_effect = config mock_config.side_effect = config self.assertEquals(quantum_contexts.ExternalPortContext()(), - {'ext_port': 'eth1010', 'mtu': None}) + {'ext_port': 'eth1010'}) @patch('charmhelpers.contrib.openstack.context.get_nic_hwaddr') @patch('charmhelpers.contrib.openstack.context.list_nics') @@ -173,13 +173,13 @@ class TestNeutronPortContext(CharmTestCase): mock_get_nic_hwaddr.side_effect = self._fake_get_hwaddr self.assertEquals(quantum_contexts.ExternalPortContext()(), - {'ext_port': 'eth2', 'mtu': None}) + {'ext_port': 'eth2'}) config = self.fake_config({'ext-port': self.absent_macs}) self.config.side_effect = config mock_config.side_effect = config - self.assertIsNone(quantum_contexts.ExternalPortContext()()) + self.assertEquals(quantum_contexts.ExternalPortContext()(), {}) self.assertTrue(mock_config.called) @patch('charmhelpers.contrib.openstack.context.get_nic_hwaddr') @@ -205,7 +205,7 @@ class TestNeutronPortContext(CharmTestCase): self.config.side_effect = config mock_config.side_effect = config self.assertEquals(quantum_contexts.ExternalPortContext()(), - {'ext_port': 'eth2', 'mtu': 1234}) + {'ext_port': 'eth2', 'ext_port_mtu': 1234}) @patch('charmhelpers.contrib.openstack.context.config') def test_data_port_eth(self, mock_config):