Updates for nvp->nsx rename in icehouse

This commit is contained in:
James Page 2014-05-03 08:28:30 +01:00
parent 0fc8a2a313
commit f7ffeee2ed
6 changed files with 81 additions and 14 deletions

View File

@ -7,7 +7,7 @@ options:
Supported values include:
.
ovs - OpenVSwitch
nvp - Nicira NVP
nvp|nsx - Nicira NVP/VMware NSX
ext-port:
type: string
description: |

View File

@ -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,29 @@ 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':
# Remap nvp plugin to nsx for releases >= icehouse
plugin = 'nsx'
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):

View File

@ -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):

View File

@ -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')
@ -318,6 +325,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 +338,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

View File

@ -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,27 @@ 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')
def test_remap_plugin_icehouse(self):
self.get_os_codename_install_source.return_value = 'icehouse'
self.assertEquals(quantum_contexts.remap_plugin('nvp'), '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)

View File

@ -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()