added vlan-ranges config
This commit is contained in:
parent
d049c7e5e1
commit
42270d52ee
@ -118,17 +118,16 @@ def _neutron_api_settings():
|
|||||||
for rid in relation_ids('neutron-plugin-api'):
|
for rid in relation_ids('neutron-plugin-api'):
|
||||||
for unit in related_units(rid):
|
for unit in related_units(rid):
|
||||||
rdata = relation_get(rid=rid, unit=unit)
|
rdata = relation_get(rid=rid, unit=unit)
|
||||||
if 'l2-population' not in rdata:
|
if 'l2-population' in rdata:
|
||||||
continue
|
neutron_settings.update({
|
||||||
neutron_settings = {
|
'l2_population': rdata['l2-population'],
|
||||||
'l2_population': rdata['l2-population'],
|
'overlay_network_type': rdata['overlay-network-type'],
|
||||||
'overlay_network_type': rdata['overlay-network-type'],
|
})
|
||||||
}
|
|
||||||
net_dev_mtu = rdata.get('network-device-mtu')
|
net_dev_mtu = rdata.get('network-device-mtu')
|
||||||
if net_dev_mtu:
|
if net_dev_mtu:
|
||||||
neutron_settings['network_device_mtu'] = net_dev_mtu
|
neutron_settings['network_device_mtu'] = net_dev_mtu
|
||||||
|
|
||||||
return neutron_settings
|
|
||||||
return neutron_settings
|
return neutron_settings
|
||||||
|
|
||||||
|
|
||||||
@ -258,9 +257,10 @@ class QuantumGatewayContext(OSContextGenerator):
|
|||||||
ctxt['bridge_mappings'] = mappings
|
ctxt['bridge_mappings'] = mappings
|
||||||
|
|
||||||
vlan_ranges = config('vlan-ranges')
|
vlan_ranges = config('vlan-ranges')
|
||||||
vlan_range_mappings = parse_vlan_range_mappings(config('vlan-ranges'))
|
vlan_range_mappings = parse_vlan_range_mappings(vlan_ranges)
|
||||||
if vlan_ranges:
|
if vlan_range_mappings:
|
||||||
ctxt['network_providers'] = ' '.join(vlan_range_mappings.keys())
|
providers = sorted(vlan_range_mappings.keys())
|
||||||
|
ctxt['network_providers'] = ' '.join(providers)
|
||||||
ctxt['vlan_ranges'] = vlan_ranges
|
ctxt['vlan_ranges'] = vlan_ranges
|
||||||
|
|
||||||
net_dev_mtu = neutron_api_settings.get('network_device_mtu')
|
net_dev_mtu = neutron_api_settings.get('network_device_mtu')
|
||||||
|
@ -620,7 +620,8 @@ def configure_ovs():
|
|||||||
|
|
||||||
add_bridge_port(br, portmaps[br], promisc=True)
|
add_bridge_port(br, portmaps[br], promisc=True)
|
||||||
|
|
||||||
# Ensure this runs so that any new bridges have correct mtu
|
# Ensure this runs so that mtu is applied to data-port interfaces if
|
||||||
|
# provided.
|
||||||
service_restart('os-charm-phy-nic-mtu')
|
service_restart('os-charm-phy-nic-mtu')
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,10 +266,19 @@ class TestQuantumGatewayContext(CharmTestCase):
|
|||||||
self.test_config.set('debug', False)
|
self.test_config.set('debug', False)
|
||||||
self.test_config.set('verbose', True)
|
self.test_config.set('verbose', True)
|
||||||
self.test_config.set('instance-mtu', 1420)
|
self.test_config.set('instance-mtu', 1420)
|
||||||
|
self.test_config.set('vlan-ranges',
|
||||||
|
'physnet1:1000:2000 physnet2:2001:3000')
|
||||||
|
# Provided by neutron-api relation
|
||||||
|
self.relation_ids.return_value = ['neutron-plugin-api:0']
|
||||||
|
self.related_units.return_value = ['neutron-api/0']
|
||||||
|
rdata = {'network-device-mtu': 9000}
|
||||||
|
self.relation_get.side_effect = lambda *args, **kwargs: rdata
|
||||||
self.get_os_codename_install_source.return_value = 'folsom'
|
self.get_os_codename_install_source.return_value = 'folsom'
|
||||||
_host_ip.return_value = '10.5.0.1'
|
_host_ip.return_value = '10.5.0.1'
|
||||||
_secret.return_value = 'testsecret'
|
_secret.return_value = 'testsecret'
|
||||||
self.assertEquals(quantum_contexts.QuantumGatewayContext()(), {
|
ctxt = quantum_contexts.QuantumGatewayContext()()
|
||||||
|
self.relation_ids.assert_called_with('neutron-plugin-api')
|
||||||
|
self.assertEquals(ctxt, {
|
||||||
'shared_secret': 'testsecret',
|
'shared_secret': 'testsecret',
|
||||||
'local_ip': '10.5.0.1',
|
'local_ip': '10.5.0.1',
|
||||||
'instance_mtu': 1420,
|
'instance_mtu': 1420,
|
||||||
@ -281,8 +290,10 @@ class TestQuantumGatewayContext(CharmTestCase):
|
|||||||
'l2_population': False,
|
'l2_population': False,
|
||||||
'overlay_network_type': 'gre',
|
'overlay_network_type': 'gre',
|
||||||
'bridge_mappings': 'physnet1:br-data',
|
'bridge_mappings': 'physnet1:br-data',
|
||||||
'network_providers': 'physnet1',
|
'network_providers': 'physnet1 physnet2',
|
||||||
'vlan_ranges': 'physnet1:1000:2000'
|
'vlan_ranges': 'physnet1:1000:2000 physnet2:2001:3000',
|
||||||
|
'network_device_mtu': 9000,
|
||||||
|
'veth_mtu': 9000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ TO_PATCH = [
|
|||||||
'service_running',
|
'service_running',
|
||||||
'NetworkServiceContext',
|
'NetworkServiceContext',
|
||||||
'ExternalPortContext',
|
'ExternalPortContext',
|
||||||
'DataPortContext',
|
|
||||||
'unit_private_ip',
|
'unit_private_ip',
|
||||||
'relations_of_type',
|
'relations_of_type',
|
||||||
'service_stop',
|
'service_stop',
|
||||||
@ -139,7 +138,9 @@ class TestQuantumUtils(CharmTestCase):
|
|||||||
self.get_os_codename_install_source.return_value = 'kilo'
|
self.get_os_codename_install_source.return_value = 'kilo'
|
||||||
self.assertTrue('python-neutron-fwaas' in quantum_utils.get_packages())
|
self.assertTrue('python-neutron-fwaas' in quantum_utils.get_packages())
|
||||||
|
|
||||||
def test_configure_ovs_starts_service_if_required(self):
|
@patch('quantum_contexts.config')
|
||||||
|
def test_configure_ovs_starts_service_if_required(self, mock_config):
|
||||||
|
mock_config.side_effect = self.test_config.get
|
||||||
self.config.return_value = 'ovs'
|
self.config.return_value = 'ovs'
|
||||||
self.service_running.return_value = False
|
self.service_running.return_value = False
|
||||||
quantum_utils.configure_ovs()
|
quantum_utils.configure_ovs()
|
||||||
@ -150,14 +151,14 @@ class TestQuantumUtils(CharmTestCase):
|
|||||||
quantum_utils.configure_ovs()
|
quantum_utils.configure_ovs()
|
||||||
self.assertFalse(self.full_restart.called)
|
self.assertFalse(self.full_restart.called)
|
||||||
|
|
||||||
def test_configure_ovs_ovs_ext_port(self):
|
@patch('quantum_contexts.config')
|
||||||
|
def test_configure_ovs_ovs_ext_port(self, mock_config):
|
||||||
|
mock_config.side_effect = self.test_config.get
|
||||||
self.config.side_effect = self.test_config.get
|
self.config.side_effect = self.test_config.get
|
||||||
self.test_config.set('plugin', 'ovs')
|
self.test_config.set('plugin', 'ovs')
|
||||||
self.test_config.set('ext-port', 'eth0')
|
self.test_config.set('ext-port', 'eth0')
|
||||||
self.ExternalPortContext.return_value = \
|
self.ExternalPortContext.return_value = \
|
||||||
DummyExternalPortContext(return_value={'ext_port': 'eth0'})
|
DummyExternalPortContext(return_value={'ext_port': 'eth0'})
|
||||||
self.DataPortContext.return_value = \
|
|
||||||
DummyExternalPortContext(return_value=None)
|
|
||||||
quantum_utils.configure_ovs()
|
quantum_utils.configure_ovs()
|
||||||
self.add_bridge.assert_has_calls([
|
self.add_bridge.assert_has_calls([
|
||||||
call('br-int'),
|
call('br-int'),
|
||||||
@ -166,20 +167,35 @@ class TestQuantumUtils(CharmTestCase):
|
|||||||
])
|
])
|
||||||
self.add_bridge_port.assert_called_with('br-ex', 'eth0')
|
self.add_bridge_port.assert_called_with('br-ex', 'eth0')
|
||||||
|
|
||||||
def test_configure_ovs_ovs_data_port(self):
|
@patch('quantum_contexts.config')
|
||||||
|
def test_configure_ovs_ovs_data_port(self, mock_config):
|
||||||
|
mock_config.side_effect = self.test_config.get
|
||||||
self.config.side_effect = self.test_config.get
|
self.config.side_effect = self.test_config.get
|
||||||
self.test_config.set('plugin', 'ovs')
|
self.test_config.set('plugin', 'ovs')
|
||||||
self.test_config.set('data-port', 'eth0')
|
|
||||||
self.ExternalPortContext.return_value = \
|
self.ExternalPortContext.return_value = \
|
||||||
DummyExternalPortContext(return_value=None)
|
DummyExternalPortContext(return_value=None)
|
||||||
self.DataPortContext.return_value = \
|
# Test back-compatibility i.e. port but no bridge (so br-data is
|
||||||
DummyExternalPortContext(return_value={'data_port': 'eth0'})
|
# assumed)
|
||||||
|
self.test_config.set('data-port', 'eth0')
|
||||||
quantum_utils.configure_ovs()
|
quantum_utils.configure_ovs()
|
||||||
self.add_bridge.assert_has_calls([
|
self.add_bridge.assert_has_calls([
|
||||||
call('br-int'),
|
call('br-int'),
|
||||||
call('br-ex'),
|
call('br-ex'),
|
||||||
call('br-data')
|
call('br-data')
|
||||||
])
|
])
|
||||||
|
self.assertTrue(self.add_bridge_port.called)
|
||||||
|
|
||||||
|
# Now test with bridge:port format
|
||||||
|
self.test_config.set('data-port', 'br-foo:eth0')
|
||||||
|
self.add_bridge.reset_mock()
|
||||||
|
self.add_bridge_port.reset_mock()
|
||||||
|
quantum_utils.configure_ovs()
|
||||||
|
self.add_bridge.assert_has_calls([
|
||||||
|
call('br-int'),
|
||||||
|
call('br-ex'),
|
||||||
|
call('br-data')
|
||||||
|
])
|
||||||
|
# Not called since we have a bogus bridge in data-ports
|
||||||
self.assertFalse(self.add_bridge_port.called)
|
self.assertFalse(self.add_bridge_port.called)
|
||||||
|
|
||||||
def test_do_openstack_upgrade(self):
|
def test_do_openstack_upgrade(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user