Update unit tests and pass nsx settings to nsx plugin
This commit is contained in:
parent
993cf0ae49
commit
620f738ddb
@ -80,7 +80,6 @@ class NeutronCCContext(context.NeutronContext):
|
||||
def __call__(self):
|
||||
from neutron_api_utils import api_port
|
||||
ctxt = super(NeutronCCContext, self).__call__()
|
||||
ctxt['external_network'] = config('neutron-external-network')
|
||||
if config('neutron-plugin') == 'nsx':
|
||||
ctxt['nvp_username'] = config('nvp-username')
|
||||
ctxt['nvp_password'] = config('nvp-password')
|
||||
|
@ -299,11 +299,21 @@ def neutron_api_relation_changed():
|
||||
|
||||
@hooks.hook('neutron-plugin-api-relation-joined')
|
||||
def neutron_plugin_api_relation_joined(rid=None):
|
||||
relation_data = {
|
||||
'neutron-security-groups': config('neutron-security-groups'),
|
||||
'l2-population': get_l2population(),
|
||||
'overlay-network-type': get_overlay_network_type(),
|
||||
}
|
||||
if config('neutron-plugin') == 'nsx':
|
||||
relation_data = {
|
||||
'nvp-username': config('nvp-username'),
|
||||
'nvp-password': config('nvp-password'),
|
||||
'nvp-cluster-name': config('nvp-cluster-name'),
|
||||
'nvp-tz-uuid': config('nvp-tz-uuid'),
|
||||
'nvp-l3-uuid': config('nvp-l3-uuid'),
|
||||
'nvp-controllers': config('nvp-controllers'),
|
||||
}
|
||||
else:
|
||||
relation_data = {
|
||||
'neutron-security-groups': config('neutron-security-groups'),
|
||||
'l2-population': get_l2population(),
|
||||
'overlay-network-type': get_overlay_network_type(),
|
||||
}
|
||||
relation_set(relation_id=rid, **relation_data)
|
||||
|
||||
|
||||
|
@ -122,10 +122,10 @@ class HAProxyContextTest(CharmTestCase):
|
||||
_open.assert_called_with('/etc/default/haproxy', 'w')
|
||||
|
||||
|
||||
class NeutronAPIContextsTest(CharmTestCase):
|
||||
class NeutronCCContextTest(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NeutronAPIContextsTest, self).setUp(context, TO_PATCH)
|
||||
super(NeutronCCContextTest, self).setUp(context, TO_PATCH)
|
||||
self.relation_get.side_effect = self.test_relation.get
|
||||
self.config.side_effect = self.test_config.get
|
||||
self.api_port = 9696
|
||||
@ -135,9 +135,15 @@ class NeutronAPIContextsTest(CharmTestCase):
|
||||
self.test_config.set('debug', True)
|
||||
self.test_config.set('verbose', True)
|
||||
self.test_config.set('neutron-external-network', 'bob')
|
||||
self.test_config.set('nvp-username', 'bob')
|
||||
self.test_config.set('nvp-password', 'hardpass')
|
||||
self.test_config.set('nvp-cluster-name', 'nsxclus')
|
||||
self.test_config.set('nvp-tz-uuid', 'tzuuid')
|
||||
self.test_config.set('nvp-l3-uuid', 'l3uuid')
|
||||
self.test_config.set('nvp-controllers', 'ctrl1 ctrl2')
|
||||
|
||||
def tearDown(self):
|
||||
super(NeutronAPIContextsTest, self).tearDown()
|
||||
super(NeutronCCContextTest, self).tearDown()
|
||||
|
||||
@patch.object(context.NeutronCCContext, 'network_manager')
|
||||
@patch.object(context.NeutronCCContext, 'plugin')
|
||||
@ -209,3 +215,23 @@ class NeutronAPIContextsTest(CharmTestCase):
|
||||
with patch.object(napi_ctxt, '_ensure_packages') as ep:
|
||||
napi_ctxt._ensure_packages()
|
||||
ep.assert_has_calls([])
|
||||
|
||||
@patch.object(context.NeutronCCContext, 'network_manager')
|
||||
@patch.object(context.NeutronCCContext, 'plugin')
|
||||
@patch('__builtin__.__import__')
|
||||
def test_neutroncc_context_nsx(self, _import, plugin, nm):
|
||||
plugin.return_value = 'nsx'
|
||||
self.related_units.return_value = []
|
||||
self.test_config.set('neutron-plugin', 'nsx')
|
||||
napi_ctxt = context.NeutronCCContext()()
|
||||
expect = {
|
||||
'nvp_cluster_name': 'nsxclus',
|
||||
'nvp_controllers': 'ctrl1,ctrl2',
|
||||
'nvp_controllers_list': ['ctrl1', 'ctrl2'],
|
||||
'nvp_l3_uuid': 'l3uuid',
|
||||
'nvp_password': 'hardpass',
|
||||
'nvp_tz_uuid': 'tzuuid',
|
||||
'nvp_username': 'bob',
|
||||
}
|
||||
for key in expect.iterkeys():
|
||||
self.assertEquals(napi_ctxt[key], expect[key])
|
||||
|
@ -33,6 +33,7 @@ TO_PATCH = [
|
||||
'determine_ports',
|
||||
'do_openstack_upgrade',
|
||||
'execd_preinstall',
|
||||
'filter_installed_packages',
|
||||
'get_l2population',
|
||||
'get_overlay_network_type',
|
||||
'is_relation_made',
|
||||
@ -111,6 +112,7 @@ class NeutronAPIHooksTests(CharmTestCase):
|
||||
self.assertTrue(_id_cluster_joined.called)
|
||||
self.assertTrue(self.CONFIGS.write_all.called)
|
||||
self.assertTrue(self.do_openstack_upgrade.called)
|
||||
self.assertTrue(self.apt_install.called)
|
||||
|
||||
def test_amqp_joined(self):
|
||||
self._call_hook('amqp-relation-joined')
|
||||
|
Loading…
x
Reference in New Issue
Block a user