diff --git a/hooks/quantum_contexts.py b/hooks/quantum_contexts.py index e07b0ab9..a42357c4 100644 --- a/hooks/quantum_contexts.py +++ b/hooks/quantum_contexts.py @@ -17,25 +17,54 @@ from charmhelpers.contrib.openstack.context import ( OSContextGenerator, context_complete ) +from charmhelpers.contrib.openstack.utils import ( + get_os_codename_install_source +) DB_USER = "quantum" QUANTUM_DB = "quantum" NOVA_DB_USER = "nova" NOVA_DB = "nova" -OVS = "ovs" -NVP = "nvp" - -OVS_PLUGIN = \ +QUANTUM_OVS_PLUGIN = \ "quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2" -NVP_PLUGIN = \ +QUANTUM_NVP_PLUGIN = \ "quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin.NvpPluginV2" +NEUTRON_OVS_PLUGIN = \ + "neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2" +NEUTRON_NVP_PLUGIN = \ + "neutron.plugins.nicira.nicira_nvp_plugin.NeutronPlugin.NvpPluginV2" +NEUTRON = 'neutron' +QUANTUM = 'quantum' + + +@cached +def networking_name(): + ''' Determine whether neutron or quantum should be used for name ''' + if get_os_codename_install_source(config('openstack-origin')) >= 'havana': + return NEUTRON + else: + return QUANTUM + +OVS = 'ovs' +NVP = 'nvp' + CORE_PLUGIN = { - OVS: OVS_PLUGIN, - NVP: NVP_PLUGIN + QUANTUM: { + OVS: QUANTUM_OVS_PLUGIN, + NVP: QUANTUM_NVP_PLUGIN + }, + NEUTRON: { + OVS: NEUTRON_OVS_PLUGIN, + NVP: NEUTRON_NVP_PLUGIN + }, } +def core_plugin(): + return CORE_PLUGIN[networking_name()][config('plugin')] + + class NetworkServiceContext(OSContextGenerator): interfaces = ['quantum-network-service'] @@ -84,7 +113,7 @@ class QuantumGatewayContext(OSContextGenerator): ctxt = { 'shared_secret': get_shared_secret(), 'local_ip': get_host_ip(), - 'core_plugin': CORE_PLUGIN[config('plugin')], + 'core_plugin': core_plugin(), 'plugin': config('plugin') } return ctxt diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index d2b9b1c2..e659a766 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -1,6 +1,7 @@ from charmhelpers.core.hookenv import ( log, config, + cached, ) from charmhelpers.fetch import ( apt_install, @@ -12,36 +13,53 @@ from charmhelpers.contrib.network.ovs import ( ) from charmhelpers.contrib.openstack.utils import ( configure_installation_source, - get_os_codename_package, get_os_codename_install_source ) import charmhelpers.contrib.openstack.context as context import charmhelpers.contrib.openstack.templating as templating from quantum_contexts import ( - CORE_PLUGIN, - OVS, NVP, + CORE_PLUGIN, OVS, NVP, QuantumGatewayContext, NetworkServiceContext, QuantumSharedDBContext, ExternalPortContext, ) -from collections import OrderedDict + +NEUTRON = 'neutron' +QUANTUM = 'quantum' + + +@cached +def networking_name(): + ''' Determine whether neutron or quantum should be used for name ''' + if get_os_codename_install_source(config('openstack-origin')) >= 'havana': + return NEUTRON + else: + return QUANTUM def valid_plugin(): - print config('plugin') - return config('plugin') in CORE_PLUGIN + return config('plugin') in CORE_PLUGIN[networking_name()] -OVS_PLUGIN_CONF = \ +QUANTUM_OVS_PLUGIN_CONF = \ "/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini" -NVP_PLUGIN_CONF = \ +QUANTUM_NVP_PLUGIN_CONF = \ "/etc/quantum/plugins/nicira/nvp.ini" -PLUGIN_CONF = { - OVS: OVS_PLUGIN_CONF, - NVP: NVP_PLUGIN_CONF +QUANTUM_PLUGIN_CONF = { + OVS: QUANTUM_OVS_PLUGIN_CONF, + NVP: QUANTUM_NVP_PLUGIN_CONF } -GATEWAY_PKGS = { +NEUTRON_OVS_PLUGIN_CONF = \ + "/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini" +NEUTRON_NVP_PLUGIN_CONF = \ + "/etc/neutron/plugins/nicira/nvp.ini" +NEUTRON_PLUGIN_CONF = { + OVS: NEUTRON_OVS_PLUGIN_CONF, + NVP: NEUTRON_NVP_PLUGIN_CONF +} + +QUANTUM_GATEWAY_PKGS = { OVS: [ "quantum-plugin-openvswitch-agent", "quantum-l3-agent", @@ -57,6 +75,27 @@ GATEWAY_PKGS = { ] } +NEUTRON_GATEWAY_PKGS = { + OVS: [ + "neutron-plugin-openvswitch-agent", + "neutron-l3-agent", + "neutron-dhcp-agent", + 'python-mysqldb', + "nova-api-metadata" + ], + NVP: [ + "openvswitch-switch", + "neutron-dhcp-agent", + 'python-mysqldb', + "nova-api-metadata" + ] +} + +GATEWAY_PKGS = { + QUANTUM: QUANTUM_GATEWAY_PKGS, + NEUTRON: NEUTRON_GATEWAY_PKGS, +} + EARLY_PACKAGES = { OVS: ['openvswitch-datapath-dkms'] } @@ -72,26 +111,24 @@ def get_early_packages(): def get_packages(): '''Return a list of packages for install based on the configured plugin''' - return GATEWAY_PKGS[config('plugin')] + return GATEWAY_PKGS[networking_name()][config('plugin')] EXT_PORT_CONF = '/etc/init/ext-port.conf' TEMPLATES = 'templates' QUANTUM_CONF = "/etc/quantum/quantum.conf" -L3_AGENT_CONF = "/etc/quantum/l3_agent.ini" -DHCP_AGENT_CONF = "/etc/quantum/dhcp_agent.ini" -METADATA_AGENT_CONF = "/etc/quantum/metadata_agent.ini" +QUANTUM_L3_AGENT_CONF = "/etc/quantum/l3_agent.ini" +QUANTUM_DHCP_AGENT_CONF = "/etc/quantum/dhcp_agent.ini" +QUANTUM_METADATA_AGENT_CONF = "/etc/quantum/metadata_agent.ini" + +NEUTRON_CONF = "/etc/neutron/neutron.conf" +NEUTRON_L3_AGENT_CONF = "/etc/neutron/l3_agent.ini" +NEUTRON_DHCP_AGENT_CONF = "/etc/neutron/dhcp_agent.ini" +NEUTRON_METADATA_AGENT_CONF = "/etc/neutron/metadata_agent.ini" + NOVA_CONF = "/etc/nova/nova.conf" -SHARED_CONFIG_FILES = { - DHCP_AGENT_CONF: { - 'hook_contexts': [QuantumGatewayContext()], - 'services': ['quantum-dhcp-agent'] - }, - METADATA_AGENT_CONF: { - 'hook_contexts': [NetworkServiceContext()], - 'services': ['quantum-metadata-agent'] - }, +NOVA_CONFIG_FILES = { NOVA_CONF: { 'hook_contexts': [context.AMQPContext(), QuantumSharedDBContext(), @@ -101,7 +138,31 @@ SHARED_CONFIG_FILES = { }, } -OVS_CONFIG_FILES = { +QUANTUM_SHARED_CONFIG_FILES = { + QUANTUM_DHCP_AGENT_CONF: { + 'hook_contexts': [QuantumGatewayContext()], + 'services': ['quantum-dhcp-agent'] + }, + QUANTUM_METADATA_AGENT_CONF: { + 'hook_contexts': [NetworkServiceContext()], + 'services': ['quantum-metadata-agent'] + }, +} +QUANTUM_SHARED_CONFIG_FILES.update(NOVA_CONFIG_FILES) + +NEUTRON_SHARED_CONFIG_FILES = { + NEUTRON_DHCP_AGENT_CONF: { + 'hook_contexts': [QuantumGatewayContext()], + 'services': ['neutron-dhcp-agent'] + }, + NEUTRON_METADATA_AGENT_CONF: { + 'hook_contexts': [NetworkServiceContext()], + 'services': ['neutron-metadata-agent'] + }, +} +NEUTRON_SHARED_CONFIG_FILES.update(NOVA_CONFIG_FILES) + +QUANTUM_OVS_CONFIG_FILES = { QUANTUM_CONF: { 'hook_contexts': [context.AMQPContext(), QuantumGatewayContext()], @@ -110,12 +171,12 @@ OVS_CONFIG_FILES = { 'quantum-metadata-agent', 'quantum-plugin-openvswitch-agent'] }, - L3_AGENT_CONF: { + QUANTUM_L3_AGENT_CONF: { 'hook_contexts': [NetworkServiceContext()], 'services': ['quantum-l3-agent'] }, # TODO: Check to see if this is actually required - OVS_PLUGIN_CONF: { + QUANTUM_OVS_PLUGIN_CONF: { 'hook_contexts': [QuantumSharedDBContext(), QuantumGatewayContext()], 'services': ['quantum-plugin-openvswitch-agent'] @@ -125,32 +186,73 @@ OVS_CONFIG_FILES = { 'services': [] } } -OVS_CONFIG_FILES.update(SHARED_CONFIG_FILES) +QUANTUM_OVS_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES) -NVP_CONFIG_FILES = { +NEUTRON_OVS_CONFIG_FILES = { + NEUTRON_CONF: { + 'hook_contexts': [context.AMQPContext(), + QuantumGatewayContext()], + 'services': ['neutron-l3-agent', + 'neutron-dhcp-agent', + 'neutron-metadata-agent', + 'neutron-plugin-openvswitch-agent'] + }, + NEUTRON_L3_AGENT_CONF: { + 'hook_contexts': [NetworkServiceContext()], + 'services': ['neutron-l3-agent'] + }, + # TODO: Check to see if this is actually required + NEUTRON_OVS_PLUGIN_CONF: { + 'hook_contexts': [QuantumSharedDBContext(), + QuantumGatewayContext()], + 'services': ['neutron-plugin-openvswitch-agent'] + }, + EXT_PORT_CONF: { + 'hook_contexts': [ExternalPortContext()], + 'services': [] + } +} +NEUTRON_OVS_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) + +QUANTUM_NVP_CONFIG_FILES = { QUANTUM_CONF: { 'hook_contexts': [context.AMQPContext()], 'services': ['quantum-dhcp-agent', 'quantum-metadata-agent'] }, } -NVP_CONFIG_FILES.update(SHARED_CONFIG_FILES) +QUANTUM_NVP_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES) + +NEUTRON_NVP_CONFIG_FILES = { + NEUTRON_CONF: { + 'hook_contexts': [context.AMQPContext()], + 'services': ['neutron-dhcp-agent', 'neutron-metadata-agent'] + }, +} +NEUTRON_NVP_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) CONFIG_FILES = { - NVP: NVP_CONFIG_FILES, - OVS: OVS_CONFIG_FILES, + QUANTUM: { + NVP: QUANTUM_NVP_CONFIG_FILES, + OVS: QUANTUM_OVS_CONFIG_FILES, + }, + NEUTRON: { + NVP: NEUTRON_NVP_CONFIG_FILES, + OVS: NEUTRON_OVS_CONFIG_FILES, + }, } def register_configs(): ''' Register config files with their respective contexts. ''' - release = get_os_codename_package('quantum-common', fatal=False) or \ - 'essex' + release = get_os_codename_install_source(config('openstack-origin')) configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, openstack_release=release) plugin = config('plugin') - for conf in CONFIG_FILES[plugin]: - configs.register(conf, CONFIG_FILES[plugin][conf]['hook_contexts']) + name = networking_name() + for conf in CONFIG_FILES[name][plugin]: + configs.register(conf, + CONFIG_FILES[name][plugin][conf]['hook_contexts']) return configs @@ -163,14 +265,16 @@ def restart_map(): :returns: dict: A dictionary mapping config file to lists of services that should be restarted when file changes. ''' - _map = [] - for f, ctxt in CONFIG_FILES[config('plugin')].iteritems(): + _map = {} + name = networking_name() + print CONFIG_FILES[name][config('plugin')] + for f, ctxt in CONFIG_FILES[name][config('plugin')].iteritems(): svcs = [] for svc in ctxt['services']: svcs.append(svc) if svcs: - _map.append((f, svcs)) - return OrderedDict(_map) + _map[f] = svcs + return _map INT_BRIDGE = "br-int" @@ -180,6 +284,7 @@ DHCP_AGENT = "DHCP Agent" L3_AGENT = "L3 Agent" +# TODO: make work with neutron def reassign_agent_resources(): ''' Use agent scheduler API to detect down agents and re-schedule ''' env = NetworkServiceContext()() @@ -266,7 +371,8 @@ def do_openstack_upgrade(configs): '--option', 'Dpkg::Options::=--force-confdef', ] apt_update(fatal=True) - apt_install(packages=GATEWAY_PKGS[config('plugin')], options=dpkg_opts, + apt_install(packages=get_packages(), + options=dpkg_opts, fatal=True) # set CONFIGS to load templates from new release diff --git a/templates/dhcp_agent.ini b/templates/folsom/dhcp_agent.ini similarity index 100% rename from templates/dhcp_agent.ini rename to templates/folsom/dhcp_agent.ini diff --git a/templates/l3_agent.ini b/templates/folsom/l3_agent.ini similarity index 100% rename from templates/l3_agent.ini rename to templates/folsom/l3_agent.ini diff --git a/templates/metadata_agent.ini b/templates/folsom/metadata_agent.ini similarity index 100% rename from templates/metadata_agent.ini rename to templates/folsom/metadata_agent.ini diff --git a/templates/nova.conf b/templates/folsom/nova.conf similarity index 100% rename from templates/nova.conf rename to templates/folsom/nova.conf diff --git a/templates/ovs_quantum_plugin.ini b/templates/folsom/ovs_quantum_plugin.ini similarity index 100% rename from templates/ovs_quantum_plugin.ini rename to templates/folsom/ovs_quantum_plugin.ini diff --git a/templates/quantum.conf b/templates/folsom/quantum.conf similarity index 100% rename from templates/quantum.conf rename to templates/folsom/quantum.conf diff --git a/templates/havana/dhcp_agent.ini b/templates/havana/dhcp_agent.ini new file mode 100644 index 00000000..0a2699f3 --- /dev/null +++ b/templates/havana/dhcp_agent.ini @@ -0,0 +1,10 @@ +[DEFAULT] +state_path = /var/lib/neutron +interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver +dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq +root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf +{% if plugin == 'nvp' %} +ovs_use_veth = True +enable_metadata_network = True +enable_isolated_metadata = True +{% endif %} diff --git a/templates/havana/l3_agent.ini b/templates/havana/l3_agent.ini new file mode 100644 index 00000000..1eb6ffd0 --- /dev/null +++ b/templates/havana/l3_agent.ini @@ -0,0 +1,8 @@ +[DEFAULT] +interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver +auth_url = {{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0 +auth_region = {{ region }} +admin_tenant_name = {{ service_tenant }} +admin_user = {{ service_username }} +admin_password = {{ service_password }} +root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf diff --git a/templates/havana/metadata_agent.ini b/templates/havana/metadata_agent.ini new file mode 100644 index 00000000..ed549b1e --- /dev/null +++ b/templates/havana/metadata_agent.ini @@ -0,0 +1,17 @@ +[DEFAULT] +debug = True +auth_url = {{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0 +auth_region = {{ region }} +admin_tenant_name = {{ service_tenant }} +admin_user = {{ service_username }} +admin_password = {{ service_password }} +root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf +state_path = /var/lib/neutron +# Gateway runs a metadata API server locally +nova_metadata_ip = {{ local_ip }} +nova_metadata_port = 8775 +# When proxying metadata requests, Quantum signs the Instance-ID header with a +# shared secret to prevent spoofing. You may select any string for a secret, +# but it must match here and in the configuration used by the Nova Metadata +# Server. NOTE: Nova uses a different key: neutron_metadata_proxy_shared_secret +metadata_proxy_shared_secret = {{ shared_secret }} diff --git a/templates/havana/neutron.conf b/templates/havana/neutron.conf new file mode 100644 index 00000000..74d99763 --- /dev/null +++ b/templates/havana/neutron.conf @@ -0,0 +1,20 @@ +[DEFAULT] +verbose = True +rabbit_userid = {{ rabbitmq_user }} +rabbit_virtual_host = {{ rabbitmq_virtual_host }} +rabbit_host = {{ rabbitmq_host }} +rabbit_password = {{ rabbitmq_password }} +debug = True +bind_host = 0.0.0.0 +bind_port = 9696 +core_plugin = {{ core_plugin }} +api_paste_config = /etc/neutron/api-paste.ini +control_exchange = neutron +notification_driver = neutron.openstack.common.notifier.list_notifier +list_notifier_drivers = neutron.openstack.common.notifier.rabbit_notifier +lock_path = /var/lock/neutron +# Ensure that netns cleanup operations kill processes and remove ports +# force = true +[AGENT] +root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf +[QUOTAS] diff --git a/templates/havana/nova.conf b/templates/havana/nova.conf new file mode 100644 index 00000000..df66747c --- /dev/null +++ b/templates/havana/nova.conf @@ -0,0 +1,25 @@ +[DEFAULT] +logdir=/var/log/nova +state_path=/var/lib/nova +lock_path=/var/lock/nova +root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf +verbose=True +api_paste_config=/etc/nova/api-paste.ini +enabled_apis=metadata +multi_host=True +sql_connection=mysql://{{ nova_user }}:{{ nova_password }}@{{ database_host }}/{{ nova_db }} +neutron_metadata_proxy_shared_secret={{ shared_secret }} +service_neutron_metadata_proxy=True +# Access to message bus +rabbit_userid={{ rabbitmq_user }} +rabbit_virtual_host={{ rabbitmq_virtual_host }} +rabbit_host={{ rabbitmq_host }} +rabbit_password={{ rabbitmq_password }} +# Access to neutron API services +network_api_class=nova.network.neutronv2.api.API +neutron_auth_strategy=keystone +neutron_url={{ quantum_url }} +neutron_admin_tenant_name={{ service_tenant }} +neutron_admin_username={{ service_username }} +neutron_admin_password={{ service_password }} +neutron_admin_auth_url={{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0 diff --git a/templates/havana/ovs_neutron_plugin.ini b/templates/havana/ovs_neutron_plugin.ini new file mode 100644 index 00000000..95bf0a9a --- /dev/null +++ b/templates/havana/ovs_neutron_plugin.ini @@ -0,0 +1,11 @@ +[DATABASE] +sql_connection = mysql://{{ quantum_user }}:{{ quantum_password }}@{{ database_host }}/{{ quantum_db }}?charset=utf8 +reconnect_interval = 2 +[OVS] +local_ip = {{ local_ip }} +tenant_network_type = gre +enable_tunneling = True +tunnel_id_ranges = 1:1000 +[AGENT] +polling_interval = 10 +root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf diff --git a/unit_tests/test_quantum_utils.py b/unit_tests/test_quantum_utils.py index f5a45adc..febce805 100644 --- a/unit_tests/test_quantum_utils.py +++ b/unit_tests/test_quantum_utils.py @@ -1,4 +1,4 @@ -from mock import MagicMock, patch, call +from mock import MagicMock, call import charmhelpers.contrib.openstack.templating as templating templating.OSConfigRenderer = MagicMock() import quantum_utils @@ -8,8 +8,9 @@ from test_utils import ( CharmTestCase ) +import charmhelpers.core.hookenv as hookenv + TO_PATCH = [ - 'get_os_codename_package', 'config', 'get_os_codename_install_source', 'apt_update', @@ -25,6 +26,10 @@ class TestQuantumUtils(CharmTestCase): def setUp(self): super(TestQuantumUtils, self).setUp(quantum_utils, TO_PATCH) + def tearDown(self): + # Reset cached cache + hookenv.cache = {} + def test_valid_plugin(self): self.config.return_value = 'ovs' self.assertTrue(quantum_utils.valid_plugin()) @@ -81,7 +86,7 @@ class TestQuantumUtils(CharmTestCase): '--option', 'Dpkg::Options::=--force-confdef', ] self.apt_install.assert_called_with( - packages=quantum_utils.GATEWAY_PKGS['ovs'], + packages=quantum_utils.GATEWAY_PKGS['neutron']['ovs'], options=dpkg_opts, fatal=True ) self.configure_installation_source.assert_called_with( @@ -90,80 +95,84 @@ class TestQuantumUtils(CharmTestCase): def test_register_configs_ovs(self): self.config.return_value = 'ovs' - self.get_os_codename_package.return_value = 'havana' + self.get_os_codename_install_source.return_value = 'havana' configs = quantum_utils.register_configs() - confs = [quantum_utils.DHCP_AGENT_CONF, - quantum_utils.METADATA_AGENT_CONF, + confs = [quantum_utils.NEUTRON_DHCP_AGENT_CONF, + quantum_utils.NEUTRON_METADATA_AGENT_CONF, quantum_utils.NOVA_CONF, - quantum_utils.QUANTUM_CONF, - quantum_utils.L3_AGENT_CONF, - quantum_utils.OVS_PLUGIN_CONF, + quantum_utils.NEUTRON_CONF, + quantum_utils.NEUTRON_L3_AGENT_CONF, + quantum_utils.NEUTRON_OVS_PLUGIN_CONF, quantum_utils.EXT_PORT_CONF] + print configs.register.calls() for conf in confs: configs.register.assert_any_call( conf, - quantum_utils.CONFIG_FILES[quantum_utils.OVS][conf] + quantum_utils.CONFIG_FILES['neutron'][quantum_utils.OVS][conf] ['hook_contexts'] ) def test_restart_map_ovs(self): self.config.return_value = 'ovs' - ex_map = OrderedDict([ - (quantum_utils.L3_AGENT_CONF, ['quantum-l3-agent']), - (quantum_utils.OVS_PLUGIN_CONF, - ['quantum-plugin-openvswitch-agent']), - (quantum_utils.NOVA_CONF, ['nova-api-metadata']), - (quantum_utils.METADATA_AGENT_CONF, ['quantum-metadata-agent']), - (quantum_utils.DHCP_AGENT_CONF, ['quantum-dhcp-agent']), - (quantum_utils.QUANTUM_CONF, ['quantum-l3-agent', - 'quantum-dhcp-agent', - 'quantum-metadata-agent', - 'quantum-plugin-openvswitch-agent']) - ]) + self.get_os_codename_install_source.return_value = 'havana' + ex_map = { + quantum_utils.NEUTRON_L3_AGENT_CONF: ['neutron-l3-agent'], + quantum_utils.NEUTRON_OVS_PLUGIN_CONF: + ['neutron-plugin-openvswitch-agent'], + quantum_utils.NOVA_CONF: ['nova-api-metadata'], + quantum_utils.NEUTRON_METADATA_AGENT_CONF: + ['neutron-metadata-agent'], + quantum_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'], + quantum_utils.NEUTRON_CONF: ['neutron-l3-agent', + 'neutron-dhcp-agent', + 'neutron-metadata-agent', + 'neutron-plugin-openvswitch-agent'] + } self.assertEquals(quantum_utils.restart_map(), ex_map) def test_register_configs_nvp(self): self.config.return_value = 'nvp' - self.get_os_codename_package.return_value = 'havana' + self.get_os_codename_install_source.return_value = 'havana' configs = quantum_utils.register_configs() - confs = [quantum_utils.DHCP_AGENT_CONF, - quantum_utils.METADATA_AGENT_CONF, + confs = [quantum_utils.NEUTRON_DHCP_AGENT_CONF, + quantum_utils.NEUTRON_METADATA_AGENT_CONF, quantum_utils.NOVA_CONF, - quantum_utils.QUANTUM_CONF] + quantum_utils.NEUTRON_CONF] for conf in confs: configs.register.assert_any_call( conf, - quantum_utils.CONFIG_FILES[quantum_utils.NVP][conf] + quantum_utils.CONFIG_FILES['neutron'][quantum_utils.NVP][conf] ['hook_contexts'] ) def test_restart_map_nvp(self): self.config.return_value = 'nvp' - ex_map = OrderedDict([ - (quantum_utils.DHCP_AGENT_CONF, ['quantum-dhcp-agent']), - (quantum_utils.NOVA_CONF, ['nova-api-metadata']), - (quantum_utils.QUANTUM_CONF, ['quantum-dhcp-agent', - 'quantum-metadata-agent']), - (quantum_utils.METADATA_AGENT_CONF, ['quantum-metadata-agent']), - ]) + self.get_os_codename_install_source.return_value = 'havana' + ex_map = { + quantum_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'], + quantum_utils.NOVA_CONF: ['nova-api-metadata'], + quantum_utils.NEUTRON_CONF: ['neutron-dhcp-agent', + 'neutron-metadata-agent'], + quantum_utils.NEUTRON_METADATA_AGENT_CONF: + ['neutron-metadata-agent'], + } self.assertEquals(quantum_utils.restart_map(), ex_map) def test_register_configs_pre_install(self): self.config.return_value = 'ovs' - self.get_os_codename_package.return_value = None + self.get_os_codename_install_source.return_value = 'folsom' configs = quantum_utils.register_configs() - confs = [quantum_utils.DHCP_AGENT_CONF, - quantum_utils.METADATA_AGENT_CONF, + confs = [quantum_utils.QUANTUM_DHCP_AGENT_CONF, + quantum_utils.QUANTUM_METADATA_AGENT_CONF, quantum_utils.NOVA_CONF, quantum_utils.QUANTUM_CONF, - quantum_utils.L3_AGENT_CONF, - quantum_utils.OVS_PLUGIN_CONF, + quantum_utils.QUANTUM_L3_AGENT_CONF, + quantum_utils.QUANTUM_OVS_PLUGIN_CONF, quantum_utils.EXT_PORT_CONF] + print configs.register.mock_calls for conf in confs: configs.register.assert_any_call( conf, - quantum_utils.CONFIG_FILES[quantum_utils.OVS][conf] + quantum_utils.CONFIG_FILES['quantum'][quantum_utils.OVS][conf] ['hook_contexts'] ) - -