Update for changes to neutron packaging

This commit is contained in:
James Page 2016-02-23 13:44:22 +00:00
commit 43b2fb3945
4 changed files with 151 additions and 55 deletions

View File

@ -102,6 +102,8 @@ NEUTRON_OVS_PLUGIN_CONF = \
"/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini"
NEUTRON_ML2_PLUGIN_CONF = \
"/etc/neutron/plugins/ml2/ml2_conf.ini"
NEUTRON_OVS_AGENT_CONF = \
"/etc/neutron/plugins/ml2/openvswitch_agent.ini"
NEUTRON_NVP_PLUGIN_CONF = \
"/etc/neutron/plugins/nicira/nvp.ini"
NEUTRON_NSX_PLUGIN_CONF = \
@ -279,6 +281,10 @@ def get_packages():
# Switch out to actual metering agent package
packages.remove('neutron-plugin-metering-agent')
packages.append('neutron-metering-agent')
if source >= 'mitaka':
# Switch out to actual ovs agent package
packages.remove('neutron-plugin-openvswitch-agent')
packages.append('neutron-openvswitch-agent')
packages.extend(determine_l3ha_packages())
if git_install_requested():
@ -452,6 +458,10 @@ NEUTRON_OVS_CONFIG_FILES = {
'hook_contexts': [NeutronGatewayContext()],
'services': ['neutron-plugin-openvswitch-agent']
},
NEUTRON_OVS_AGENT_CONF: {
'hook_contexts': [NeutronGatewayContext()],
'services': ['neutron-openvswitch-agent']
},
EXT_PORT_CONF: {
'hook_contexts': [ExternalPortContext()],
'services': ['ext-port']
@ -568,21 +578,57 @@ CONFIG_FILES = {
}
def register_configs():
''' Register config files with their respective contexts. '''
release = get_os_codename_install_source(config('openstack-origin'))
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
SERVICE_RENAMES = {
'mitaka': {
'neutron-plugin-openvswitch-agent': 'neutron-openvswitch-agent',
'neutron-plugin-metering-agent': 'neutron-metering-agent',
}
}
plugin = remap_plugin(config('plugin'))
name = networking_name()
def remap_service(service_name):
'''
Remap service names based on openstack release to deal
with changes to packaging
:param service_name: name of service to remap
:returns: remapped service name or original value
'''
source = get_os_codename_install_source(config('openstack-origin'))
for rename_source in SERVICE_RENAMES:
if (source >= rename_source and
service_name in SERVICE_RENAMES[rename_source]):
service_name = SERVICE_RENAMES[rename_source][service_name]
return service_name
def resolve_config_files(name, plugin, release):
'''
Resolve configuration files and contexts
:param name: neutron or quantum
:param plugin: shortname of plugin e.g. ovs
:param release: openstack release codename
:returns: dict of configuration files, contexts
and associated services
'''
config_files = deepcopy(CONFIG_FILES)
if plugin == 'ovs':
# NOTE: deal with switch to ML2 plugin for >= icehouse
drop_config = NEUTRON_ML2_PLUGIN_CONF
drop_config = [NEUTRON_ML2_PLUGIN_CONF,
NEUTRON_OVS_AGENT_CONF]
if release >= 'icehouse':
drop_config = NEUTRON_OVS_PLUGIN_CONF
if drop_config in CONFIG_FILES[name][plugin]:
CONFIG_FILES[name][plugin].pop(drop_config)
# ovs -> ml2
drop_config = [NEUTRON_OVS_PLUGIN_CONF,
NEUTRON_OVS_AGENT_CONF]
if release >= 'mitaka':
# ml2 -> ovs_agent
drop_config = [NEUTRON_OVS_PLUGIN_CONF,
NEUTRON_ML2_PLUGIN_CONF]
for _config in drop_config:
if _config in config_files[name][plugin]:
config_files[name][plugin].pop(_config)
if is_relation_made('amqp-nova'):
amqp_nova_ctxt = context.AMQPContext(
@ -593,20 +639,34 @@ def register_configs():
amqp_nova_ctxt = context.AMQPContext(
ssl_dir=NOVA_CONF_DIR,
rel_name='amqp')
CONFIG_FILES[name][plugin][NOVA_CONF][
config_files[name][plugin][NOVA_CONF][
'hook_contexts'].append(amqp_nova_ctxt)
for conf in CONFIG_FILES[name][plugin]:
return config_files
def register_configs():
''' Register config files with their respective contexts. '''
release = get_os_codename_install_source(config('openstack-origin'))
plugin = remap_plugin(config('plugin'))
name = networking_name()
config_files = resolve_config_files(name, plugin, release)
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
for conf in config_files[name][plugin]:
configs.register(conf,
CONFIG_FILES[name][plugin][conf]['hook_contexts'])
config_files[name][plugin][conf]['hook_contexts'])
return configs
def stop_services():
release = get_os_codename_install_source(config('openstack-origin'))
plugin = remap_plugin(config('plugin'))
name = networking_name()
config_files = resolve_config_files(name, plugin, release)
svcs = set()
for ctxt in CONFIG_FILES[name][config('plugin')].itervalues():
for ctxt in config_files[name][config('plugin')].itervalues():
for svc in ctxt['services']:
svcs.add(svc)
svcs.add(remap_service(svc))
for svc in svcs:
service_stop(svc)
@ -619,15 +679,17 @@ def restart_map():
:returns: dict: A dictionary mapping config file to lists of services
that should be restarted when file changes.
'''
_map = {}
plugin = config('plugin')
release = get_os_codename_install_source(config('openstack-origin'))
plugin = remap_plugin(config('plugin'))
name = networking_name()
for f, ctxt in CONFIG_FILES[name][plugin].iteritems():
svcs = []
config_files = resolve_config_files(name, plugin, release)
_map = {}
for f, ctxt in config_files[name][plugin].iteritems():
svcs = set()
for svc in ctxt['services']:
svcs.append(svc)
svcs.add(remap_service(svc))
if svcs:
_map[f] = svcs
_map[f] = list(svcs)
return _map

View File

@ -0,0 +1,20 @@
# mitaka
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[ovs]
enable_tunneling = True
local_ip = {{ local_ip }}
bridge_mappings = {{ bridge_mappings }}
[agent]
tunnel_types = {{ overlay_network_type }}
l2_population = {{ l2_population }}
enable_distributed_routing = {{ enable_dvr }}
{% if veth_mtu -%}
veth_mtu = {{ veth_mtu }}
{% endif %}
[securitygroup]
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver

View File

@ -185,6 +185,10 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
if self._get_openstack_release() <= self.trusty_juno:
neutron_services.append('neutron-vpn-agent')
if self._get_openstack_release() >= self.trusty_mitaka:
# neutron-plugin-openvswitch-agent -> neutron-openvswitch-agent
neutron_services.remove('neutron-plugin-openvswitch-agent')
neutron_services.append('neutron-openvswitch-agent')
nova_cc_services = ['nova-api-ec2',
'nova-api-os-compute',
@ -885,7 +889,7 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
'project_name': 'services',
'username': 'nova',
'password': nova_cc_relation['service_password'],
'auth_url': ep,
'auth_url': ep.split('/v')[0],
'region': 'RegionOne',
'service_metadata_proxy': 'True',
'metadata_proxy_shared_secret': u.not_null

View File

@ -1,4 +1,4 @@
from mock import MagicMock, call, patch
from mock import MagicMock, call, patch, ANY
import collections
import charmhelpers.contrib.openstack.templating as templating
@ -287,11 +287,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.NEUTRON_OVS_PLUGIN_CONF,
neutron_utils.EXT_PORT_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
neutron_utils.CONFIG_FILES['neutron'][neutron_utils.OVS][conf]
['hook_contexts']
)
configs.register.assert_any_call(conf, ANY)
def test_register_configs_ovs_odl(self):
self.config.side_effect = self.test_config.get
@ -306,12 +302,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.NEUTRON_L3_AGENT_CONF,
neutron_utils.EXT_PORT_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
neutron_utils.CONFIG_FILES['neutron']
[neutron_utils.OVS_ODL][conf]
['hook_contexts']
)
configs.register.assert_any_call(conf, ANY)
def test_register_configs_amqp_nova(self):
self.config.return_value = 'ovs'
@ -325,11 +316,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.NEUTRON_OVS_PLUGIN_CONF,
neutron_utils.EXT_PORT_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
neutron_utils.CONFIG_FILES['neutron'][neutron_utils.OVS][conf]
['hook_contexts']
)
configs.register.assert_any_call(conf, ANY)
def test_restart_map_ovs(self):
self.config.return_value = 'ovs'
@ -368,6 +355,41 @@ class TestQuantumUtils(CharmTestCase):
self.assertDictEqual(neutron_utils.restart_map(), ex_map)
def test_restart_map_ovs_mitaka(self):
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'mitaka'
ex_map = {
neutron_utils.NEUTRON_CONF: ['neutron-l3-agent',
'neutron-dhcp-agent',
'neutron-metadata-agent',
'neutron-openvswitch-agent',
'neutron-metering-agent',
'neutron-lbaas-agent',
'neutron-plugin-vpn-agent',
'neutron-vpn-agent'],
neutron_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'],
neutron_utils.NEUTRON_LBAAS_AGENT_CONF:
['neutron-lbaas-agent'],
neutron_utils.NEUTRON_OVS_AGENT_CONF:
['neutron-openvswitch-agent'],
neutron_utils.NEUTRON_METADATA_AGENT_CONF:
['neutron-metadata-agent'],
neutron_utils.NEUTRON_VPNAAS_AGENT_CONF: [
'neutron-plugin-vpn-agent',
'neutron-vpn-agent'],
neutron_utils.NEUTRON_L3_AGENT_CONF: ['neutron-l3-agent',
'neutron-vpn-agent'],
neutron_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'],
neutron_utils.NEUTRON_FWAAS_CONF: ['neutron-l3-agent',
'neutron-vpn-agent'],
neutron_utils.NEUTRON_METERING_AGENT_CONF:
['neutron-metering-agent'],
neutron_utils.NOVA_CONF: ['nova-api-metadata'],
neutron_utils.EXT_PORT_CONF: ['ext-port'],
neutron_utils.PHY_NIC_MTU_CONF: ['os-charm-phy-nic-mtu'],
}
self.assertEqual(ex_map, neutron_utils.restart_map())
def test_restart_map_ovs_odl(self):
self.config.return_value = 'ovs-odl'
self.get_os_codename_install_source.return_value = 'icehouse'
@ -411,11 +433,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
neutron_utils.CONFIG_FILES['neutron'][neutron_utils.NVP][conf]
['hook_contexts']
)
configs.register.assert_any_call(conf, ANY)
def test_register_configs_nsx(self):
self.config.return_value = 'nsx'
@ -425,11 +443,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF]
for conf in confs:
configs.register.assert_any_call(
conf,
neutron_utils.CONFIG_FILES['neutron'][neutron_utils.NSX][conf]
['hook_contexts']
)
configs.register.assert_any_call(conf, ANY)
def test_stop_services_nvp(self):
self.config.return_value = 'nvp'
@ -484,11 +498,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.EXT_PORT_CONF]
print configs.register.mock_calls
for conf in confs:
configs.register.assert_any_call(
conf,
neutron_utils.CONFIG_FILES['quantum'][neutron_utils.OVS][conf]
['hook_contexts']
)
configs.register.assert_any_call(conf, ANY)
def test_get_common_package_quantum(self):
self.get_os_codename_package.return_value = 'folsom'