phy-nic* > get value from data-port config param
This commit is contained in:
parent
f011eb3dd2
commit
df0a727987
12
config.yaml
12
config.yaml
@ -173,15 +173,3 @@ options:
|
||||
description: |
|
||||
Default multicast port number that will be used to communicate between
|
||||
HA Cluster nodes.
|
||||
phy-nics:
|
||||
type: string
|
||||
default:
|
||||
description: |
|
||||
A space-separated list of NICs that we want phy-nic-mtu applied to.
|
||||
phy-nic-mtu:
|
||||
type: int
|
||||
default:
|
||||
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).
|
||||
|
@ -191,27 +191,14 @@ class ExternalPortContext(NeutronPortContext):
|
||||
ports = self.resolve_ports(ports)
|
||||
if ports:
|
||||
ctxt = {"ext_port": ports[0]}
|
||||
mtu = config('phy-nic-mtu')
|
||||
neutron_api_settings = _neutron_api_settings()
|
||||
mtu = neutron_api_settings.get('network_device_mtu')
|
||||
if mtu:
|
||||
ctxt['ext_port_mtu'] = mtu
|
||||
|
||||
return ctxt
|
||||
|
||||
|
||||
class PhyNICMTUContext(OSContextGenerator):
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
port = config('phy-nics')
|
||||
if port:
|
||||
ctxt = {"devs": port.replace(' ', '\\n')}
|
||||
mtu = config('phy-nic-mtu')
|
||||
if mtu:
|
||||
ctxt['mtu'] = mtu
|
||||
|
||||
return ctxt
|
||||
|
||||
|
||||
class DataPortContext(NeutronPortContext):
|
||||
|
||||
def __call__(self):
|
||||
@ -231,6 +218,22 @@ class DataPortContext(NeutronPortContext):
|
||||
return None
|
||||
|
||||
|
||||
class PhyNICMTUContext(DataPortContext):
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
mappings = super(PhyNICMTUContext, self).__call__()
|
||||
if mappings and mappings.values():
|
||||
ports = mappings.values()
|
||||
neutron_api_settings = _neutron_api_settings()
|
||||
mtu = neutron_api_settings.get('network_device_mtu')
|
||||
if mtu:
|
||||
ctxt["devs"] = '\\n'.join(ports)
|
||||
ctxt['mtu'] = mtu
|
||||
|
||||
return ctxt
|
||||
|
||||
|
||||
class QuantumGatewayContext(OSContextGenerator):
|
||||
|
||||
def __call__(self):
|
||||
|
@ -181,6 +181,7 @@ class TestNeutronPortContext(CharmTestCase):
|
||||
|
||||
self.assertEquals(quantum_contexts.ExternalPortContext()(), {})
|
||||
|
||||
@patch.object(quantum_contexts, '_neutron_api_settings')
|
||||
@patch('charmhelpers.contrib.openstack.context.get_nic_hwaddr')
|
||||
@patch('charmhelpers.contrib.openstack.context.list_nics')
|
||||
@patch('charmhelpers.contrib.openstack.context.get_ipv6_addr')
|
||||
@ -189,8 +190,10 @@ class TestNeutronPortContext(CharmTestCase):
|
||||
def test_ext_port_mac_one_used_nic(self, mock_config,
|
||||
mock_get_ipv4_addr,
|
||||
mock_get_ipv6_addr, mock_list_nics,
|
||||
mock_get_nic_hwaddr):
|
||||
mock_get_nic_hwaddr,
|
||||
mock_neutron_api_settings):
|
||||
|
||||
mock_neutron_api_settings.return_value = {'network_device_mtu': 1234}
|
||||
config_macs = "%s %s" % (self.machine_macs['eth1'],
|
||||
self.machine_macs['eth2'])
|
||||
|
||||
@ -199,8 +202,7 @@ class TestNeutronPortContext(CharmTestCase):
|
||||
mock_list_nics.return_value = self.machine_macs.keys()
|
||||
mock_get_nic_hwaddr.side_effect = self._fake_get_hwaddr
|
||||
|
||||
config = self.fake_config({'ext-port': config_macs,
|
||||
'phy-nic-mtu': 1234})
|
||||
config = self.fake_config({'ext-port': config_macs})
|
||||
self.config.side_effect = config
|
||||
mock_config.side_effect = config
|
||||
self.assertEquals(quantum_contexts.ExternalPortContext()(),
|
||||
|
Loading…
Reference in New Issue
Block a user