diff --git a/config.yaml b/config.yaml index 814aa1ec..1c542d2a 100644 --- a/config.yaml +++ b/config.yaml @@ -7,7 +7,7 @@ options: Supported values include: . ovs - OpenVSwitch - nvp - Nicira NVP + nvp|nsx - Nicira NVP/VMware NSX ext-port: type: string description: | diff --git a/hooks/quantum_contexts.py b/hooks/quantum_contexts.py index 5aa472fd..c8b635aa 100644 --- a/hooks/quantum_contexts.py +++ b/hooks/quantum_contexts.py @@ -44,6 +44,8 @@ NEUTRON_ML2_PLUGIN = \ "neutron.plugins.ml2.plugin.Ml2Plugin" NEUTRON_NVP_PLUGIN = \ "neutron.plugins.nicira.nicira_nvp_plugin.NeutronPlugin.NvpPluginV2" +NEUTRON_NSX_PLUGIN = "vmware" + NEUTRON = 'neutron' QUANTUM = 'quantum' @@ -57,6 +59,7 @@ def networking_name(): OVS = 'ovs' NVP = 'nvp' +NSX = 'nsx' CORE_PLUGIN = { QUANTUM: { @@ -65,18 +68,30 @@ CORE_PLUGIN = { }, NEUTRON: { OVS: NEUTRON_OVS_PLUGIN, - NVP: NEUTRON_NVP_PLUGIN + NVP: NEUTRON_NVP_PLUGIN, + NSX: NEUTRON_NSX_PLUGIN }, } +def remap_plugin(plugin): + ''' Remaps plugin name for renames/switches in packaging ''' + release = get_os_codename_install_source(config('openstack-origin')) + if plugin == 'nvp' and release >= 'icehouse': + plugin = 'nsx' + elif plugin == 'nsx' and release < 'icehouse': + plugin = 'nvp' + return plugin + + def core_plugin(): + plugin = remap_plugin(config('plugin')) if (get_os_codename_install_source(config('openstack-origin')) >= 'icehouse' - and config('plugin') == OVS): + and plugin == OVS): return NEUTRON_ML2_PLUGIN else: - return CORE_PLUGIN[networking_name()][config('plugin')] + return CORE_PLUGIN[networking_name()][plugin] class NetworkServiceContext(OSContextGenerator): diff --git a/hooks/quantum_hooks.py b/hooks/quantum_hooks.py index 8d0cac66..a7496802 100755 --- a/hooks/quantum_hooks.py +++ b/hooks/quantum_hooks.py @@ -161,8 +161,9 @@ def nm_changed(): @hooks.hook("cluster-relation-departed") @restart_on_change(restart_map()) def cluster_departed(): - if config('plugin') == 'nvp': - log('Unable to re-assign agent resources for failed nodes with nvp', + if config('plugin') in ['nvp', 'nsx']: + log('Unable to re-assign agent resources for' + ' failed nodes with nvp|nsx', level=WARNING) return if eligible_leader(None): diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 0da00f79..a70c224e 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -37,13 +37,14 @@ from charmhelpers.contrib.openstack.context import ( import charmhelpers.contrib.openstack.templating as templating from charmhelpers.contrib.openstack.neutron import headers_package from quantum_contexts import ( - CORE_PLUGIN, OVS, NVP, + CORE_PLUGIN, OVS, NVP, NSX, NEUTRON, QUANTUM, networking_name, QuantumGatewayContext, NetworkServiceContext, L3AgentContext, ExternalPortContext, + remap_plugin ) from copy import deepcopy @@ -71,9 +72,13 @@ NEUTRON_ML2_PLUGIN_CONF = \ "/etc/neutron/plugins/ml2/ml2_conf.ini" NEUTRON_NVP_PLUGIN_CONF = \ "/etc/neutron/plugins/nicira/nvp.ini" +NEUTRON_NSX_PLUGIN_CONF = \ + "/etc/neutron/plugins/vmware/nsx.ini" + NEUTRON_PLUGIN_CONF = { OVS: NEUTRON_OVS_PLUGIN_CONF, - NVP: NEUTRON_NVP_PLUGIN_CONF + NVP: NEUTRON_NVP_PLUGIN_CONF, + NSX: NEUTRON_NSX_PLUGIN_CONF, } QUANTUM_GATEWAY_PKGS = { @@ -116,6 +121,7 @@ NEUTRON_GATEWAY_PKGS = { "nova-api-metadata" ] } +NEUTRON_GATEWAY_PKGS[NSX] = NEUTRON_GATEWAY_PKGS[NVP] GATEWAY_PKGS = { QUANTUM: QUANTUM_GATEWAY_PKGS, @@ -138,9 +144,10 @@ def get_early_packages(): def get_packages(): '''Return a list of packages for install based on the configured plugin''' - packages = deepcopy(GATEWAY_PKGS[networking_name()][config('plugin')]) + plugin = remap_plugin(config('plugin')) + packages = deepcopy(GATEWAY_PKGS[networking_name()][plugin]) if (get_os_codename_install_source(config('openstack-origin')) - >= 'icehouse' and config('plugin') == 'ovs'): + >= 'icehouse' and plugin == 'ovs'): # NOTE(jamespage) neutron-vpn-agent supercedes l3-agent for icehouse packages.remove('neutron-l3-agent') packages.append('neutron-vpn-agent') @@ -298,7 +305,9 @@ NEUTRON_OVS_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) QUANTUM_NVP_CONFIG_FILES = { QUANTUM_CONF: { - 'hook_contexts': [context.AMQPContext(ssl_dir=QUANTUM_CONF_DIR)], + 'hook_contexts': [context.AMQPContext(ssl_dir=QUANTUM_CONF_DIR), + QuantumGatewayContext(), + SyslogContext()], 'services': ['quantum-dhcp-agent', 'quantum-metadata-agent'] }, } @@ -306,7 +315,9 @@ QUANTUM_NVP_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES) NEUTRON_NVP_CONFIG_FILES = { NEUTRON_CONF: { - 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR)], + 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR), + QuantumGatewayContext(), + SyslogContext()], 'services': ['neutron-dhcp-agent', 'neutron-metadata-agent'] }, } @@ -318,6 +329,7 @@ CONFIG_FILES = { OVS: QUANTUM_OVS_CONFIG_FILES, }, NEUTRON: { + NSX: NEUTRON_NVP_CONFIG_FILES, NVP: NEUTRON_NVP_CONFIG_FILES, OVS: NEUTRON_OVS_CONFIG_FILES, }, @@ -330,7 +342,7 @@ def register_configs(): configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, openstack_release=release) - plugin = config('plugin') + plugin = remap_plugin(config('plugin')) name = networking_name() if plugin == 'ovs': # NOTE: deal with switch to ML2 plugin for >= icehouse diff --git a/templates/havana/dhcp_agent.ini b/templates/havana/dhcp_agent.ini index 85e93864..059b26be 100644 --- a/templates/havana/dhcp_agent.ini +++ b/templates/havana/dhcp_agent.ini @@ -11,7 +11,7 @@ ovs_use_veth = True {% if instance_mtu -%} dnsmasq_config_file = /etc/neutron/dnsmasq.conf {% endif -%} -{% if plugin == 'nvp' -%} +{% if plugin == 'nvp' or plugin == 'nsx' -%} enable_metadata_network = True enable_isolated_metadata = True {% endif -%} diff --git a/unit_tests/test_quantum_contexts.py b/unit_tests/test_quantum_contexts.py index d5b79e43..3a6b48cc 100644 --- a/unit_tests/test_quantum_contexts.py +++ b/unit_tests/test_quantum_contexts.py @@ -290,10 +290,10 @@ class TestHostIP(CharmTestCase): _query.assert_called_with('myhost.example.com', 'A') -class TestNetworkingName(CharmTestCase): +class TestMisc(CharmTestCase): def setUp(self): - super(TestNetworkingName, + super(TestMisc, self).setUp(quantum_contexts, TO_PATCH) @@ -304,3 +304,29 @@ class TestNetworkingName(CharmTestCase): def test_ge_havana(self): self.get_os_codename_install_source.return_value = 'havana' self.assertEquals(quantum_contexts.networking_name(), 'neutron') + + def test_remap_plugin(self): + self.get_os_codename_install_source.return_value = 'havana' + self.assertEquals(quantum_contexts.remap_plugin('nvp'), 'nvp') + self.assertEquals(quantum_contexts.remap_plugin('nsx'), 'nvp') + + def test_remap_plugin_icehouse(self): + self.get_os_codename_install_source.return_value = 'icehouse' + self.assertEquals(quantum_contexts.remap_plugin('nvp'), 'nsx') + self.assertEquals(quantum_contexts.remap_plugin('nsx'), 'nsx') + + def test_remap_plugin_noop(self): + self.get_os_codename_install_source.return_value = 'icehouse' + self.assertEquals(quantum_contexts.remap_plugin('ovs'), 'ovs') + + def test_core_plugin(self): + self.get_os_codename_install_source.return_value = 'havana' + self.config.return_value = 'ovs' + self.assertEquals(quantum_contexts.core_plugin(), + quantum_contexts.NEUTRON_OVS_PLUGIN) + + def test_core_plugin_ml2(self): + self.get_os_codename_install_source.return_value = 'icehouse' + self.config.return_value = 'ovs' + self.assertEquals(quantum_contexts.core_plugin(), + quantum_contexts.NEUTRON_ML2_PLUGIN) diff --git a/unit_tests/test_quantum_utils.py b/unit_tests/test_quantum_utils.py index f6841693..64f248e6 100644 --- a/unit_tests/test_quantum_utils.py +++ b/unit_tests/test_quantum_utils.py @@ -41,7 +41,8 @@ TO_PATCH = [ 'relations_of_type', 'service_stop', 'determine_dkms_package', - 'service_restart' + 'service_restart', + 'remap_plugin' ] @@ -61,6 +62,9 @@ class TestQuantumUtils(CharmTestCase): super(TestQuantumUtils, self).setUp(quantum_utils, TO_PATCH) self.networking_name.return_value = 'neutron' self.headers_package.return_value = 'linux-headers-2.6.18' + def noop(value): + return value + self.remap_plugin.side_effect = noop def tearDown(self): # Reset cached cache @@ -71,6 +75,8 @@ class TestQuantumUtils(CharmTestCase): self.assertTrue(quantum_utils.valid_plugin()) self.config.return_value = 'nvp' self.assertTrue(quantum_utils.valid_plugin()) + self.config.return_value = 'nsx' + self.assertTrue(quantum_utils.valid_plugin()) def test_invalid_plugin(self): self.config.return_value = 'invalid' @@ -212,6 +218,20 @@ class TestQuantumUtils(CharmTestCase): ['hook_contexts'] ) + def test_register_configs_nsx(self): + self.config.return_value = 'nsx' + configs = quantum_utils.register_configs() + confs = [quantum_utils.NEUTRON_DHCP_AGENT_CONF, + quantum_utils.NEUTRON_METADATA_AGENT_CONF, + quantum_utils.NOVA_CONF, + quantum_utils.NEUTRON_CONF] + for conf in confs: + configs.register.assert_any_call( + conf, + quantum_utils.CONFIG_FILES['neutron'][quantum_utils.NSX][conf] + ['hook_contexts'] + ) + def test_stop_services_nvp(self): self.config.return_value = 'nvp' quantum_utils.stop_services()