default to no network-device-mtu

This commit is contained in:
Edward Hope-Morley 2015-02-10 12:00:24 +00:00
parent a39353d623
commit f9f95ae0ac
4 changed files with 15 additions and 12 deletions

View File

@ -156,8 +156,8 @@ options:
HA Cluster nodes. HA Cluster nodes.
phy-nic-mtu: phy-nic-mtu:
type: int type: int
default: 1500 default: 0
description: | description: |
To improve network performance of VM, sometimes we should keep VM MTU as 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 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.

View File

@ -176,12 +176,15 @@ class L3AgentContext(OSContextGenerator):
class ExternalPortContext(NeutronPortContext): class ExternalPortContext(NeutronPortContext):
def __call__(self): def __call__(self):
ctxt = {}
port = self.resolve_port('ext-port') port = self.resolve_port('ext-port')
if port: if port:
return {"ext_port": port, ctxt = {"ext_port": port}
"mtu": config('phy-nic-mtu')} mtu = config('phy-nic-mtu')
else: if mtu:
return None ctxt['ext_port_mtu'] = mtu
return ctxt
class DataPortContext(NeutronPortContext): class DataPortContext(NeutronPortContext):

View File

@ -6,7 +6,7 @@ task
script script
EXT_PORT="{{ ext_port }}" EXT_PORT="{{ ext_port }}"
MTU="{{ mtu }}" MTU="{{ ext_port_mtu }}"
if [ -n "$EXT_PORT" ]; then if [ -n "$EXT_PORT" ]; then
ip link set $EXT_PORT up ip link set $EXT_PORT up
if [ -n "$MTU" ]; then if [ -n "$MTU" ]; then

View File

@ -144,7 +144,7 @@ class TestNeutronPortContext(CharmTestCase):
def test_no_ext_port(self, mock_config): def test_no_ext_port(self, mock_config):
self.config.side_effect = config = self.fake_config({}) self.config.side_effect = config = self.fake_config({})
mock_config.side_effect = config mock_config.side_effect = config
self.assertIsNone(quantum_contexts.ExternalPortContext()()) self.assertEquals(quantum_contexts.ExternalPortContext()(), {})
@patch('charmhelpers.contrib.openstack.context.config') @patch('charmhelpers.contrib.openstack.context.config')
def test_ext_port_eth(self, mock_config): def test_ext_port_eth(self, mock_config):
@ -152,7 +152,7 @@ class TestNeutronPortContext(CharmTestCase):
self.config.side_effect = config self.config.side_effect = config
mock_config.side_effect = config mock_config.side_effect = config
self.assertEquals(quantum_contexts.ExternalPortContext()(), 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.get_nic_hwaddr')
@patch('charmhelpers.contrib.openstack.context.list_nics') @patch('charmhelpers.contrib.openstack.context.list_nics')
@ -173,13 +173,13 @@ class TestNeutronPortContext(CharmTestCase):
mock_get_nic_hwaddr.side_effect = self._fake_get_hwaddr mock_get_nic_hwaddr.side_effect = self._fake_get_hwaddr
self.assertEquals(quantum_contexts.ExternalPortContext()(), self.assertEquals(quantum_contexts.ExternalPortContext()(),
{'ext_port': 'eth2', 'mtu': None}) {'ext_port': 'eth2'})
config = self.fake_config({'ext-port': self.absent_macs}) config = self.fake_config({'ext-port': self.absent_macs})
self.config.side_effect = config self.config.side_effect = config
mock_config.side_effect = config mock_config.side_effect = config
self.assertIsNone(quantum_contexts.ExternalPortContext()()) self.assertEquals(quantum_contexts.ExternalPortContext()(), {})
self.assertTrue(mock_config.called) self.assertTrue(mock_config.called)
@patch('charmhelpers.contrib.openstack.context.get_nic_hwaddr') @patch('charmhelpers.contrib.openstack.context.get_nic_hwaddr')
@ -205,7 +205,7 @@ class TestNeutronPortContext(CharmTestCase):
self.config.side_effect = config self.config.side_effect = config
mock_config.side_effect = config mock_config.side_effect = config
self.assertEquals(quantum_contexts.ExternalPortContext()(), self.assertEquals(quantum_contexts.ExternalPortContext()(),
{'ext_port': 'eth2', 'mtu': 1234}) {'ext_port': 'eth2', 'ext_port_mtu': 1234})
@patch('charmhelpers.contrib.openstack.context.config') @patch('charmhelpers.contrib.openstack.context.config')
def test_data_port_eth(self, mock_config): def test_data_port_eth(self, mock_config):