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):
|
def __call__(self):
|
||||||
from neutron_api_utils import api_port
|
from neutron_api_utils import api_port
|
||||||
ctxt = super(NeutronCCContext, self).__call__()
|
ctxt = super(NeutronCCContext, self).__call__()
|
||||||
ctxt['external_network'] = config('neutron-external-network')
|
|
||||||
if config('neutron-plugin') == 'nsx':
|
if config('neutron-plugin') == 'nsx':
|
||||||
ctxt['nvp_username'] = config('nvp-username')
|
ctxt['nvp_username'] = config('nvp-username')
|
||||||
ctxt['nvp_password'] = config('nvp-password')
|
ctxt['nvp_password'] = config('nvp-password')
|
||||||
|
@ -299,6 +299,16 @@ def neutron_api_relation_changed():
|
|||||||
|
|
||||||
@hooks.hook('neutron-plugin-api-relation-joined')
|
@hooks.hook('neutron-plugin-api-relation-joined')
|
||||||
def neutron_plugin_api_relation_joined(rid=None):
|
def neutron_plugin_api_relation_joined(rid=None):
|
||||||
|
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 = {
|
relation_data = {
|
||||||
'neutron-security-groups': config('neutron-security-groups'),
|
'neutron-security-groups': config('neutron-security-groups'),
|
||||||
'l2-population': get_l2population(),
|
'l2-population': get_l2population(),
|
||||||
|
@ -122,10 +122,10 @@ class HAProxyContextTest(CharmTestCase):
|
|||||||
_open.assert_called_with('/etc/default/haproxy', 'w')
|
_open.assert_called_with('/etc/default/haproxy', 'w')
|
||||||
|
|
||||||
|
|
||||||
class NeutronAPIContextsTest(CharmTestCase):
|
class NeutronCCContextTest(CharmTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
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.relation_get.side_effect = self.test_relation.get
|
||||||
self.config.side_effect = self.test_config.get
|
self.config.side_effect = self.test_config.get
|
||||||
self.api_port = 9696
|
self.api_port = 9696
|
||||||
@ -135,9 +135,15 @@ class NeutronAPIContextsTest(CharmTestCase):
|
|||||||
self.test_config.set('debug', True)
|
self.test_config.set('debug', True)
|
||||||
self.test_config.set('verbose', True)
|
self.test_config.set('verbose', True)
|
||||||
self.test_config.set('neutron-external-network', 'bob')
|
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):
|
def tearDown(self):
|
||||||
super(NeutronAPIContextsTest, self).tearDown()
|
super(NeutronCCContextTest, self).tearDown()
|
||||||
|
|
||||||
@patch.object(context.NeutronCCContext, 'network_manager')
|
@patch.object(context.NeutronCCContext, 'network_manager')
|
||||||
@patch.object(context.NeutronCCContext, 'plugin')
|
@patch.object(context.NeutronCCContext, 'plugin')
|
||||||
@ -209,3 +215,23 @@ class NeutronAPIContextsTest(CharmTestCase):
|
|||||||
with patch.object(napi_ctxt, '_ensure_packages') as ep:
|
with patch.object(napi_ctxt, '_ensure_packages') as ep:
|
||||||
napi_ctxt._ensure_packages()
|
napi_ctxt._ensure_packages()
|
||||||
ep.assert_has_calls([])
|
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',
|
'determine_ports',
|
||||||
'do_openstack_upgrade',
|
'do_openstack_upgrade',
|
||||||
'execd_preinstall',
|
'execd_preinstall',
|
||||||
|
'filter_installed_packages',
|
||||||
'get_l2population',
|
'get_l2population',
|
||||||
'get_overlay_network_type',
|
'get_overlay_network_type',
|
||||||
'is_relation_made',
|
'is_relation_made',
|
||||||
@ -111,6 +112,7 @@ class NeutronAPIHooksTests(CharmTestCase):
|
|||||||
self.assertTrue(_id_cluster_joined.called)
|
self.assertTrue(_id_cluster_joined.called)
|
||||||
self.assertTrue(self.CONFIGS.write_all.called)
|
self.assertTrue(self.CONFIGS.write_all.called)
|
||||||
self.assertTrue(self.do_openstack_upgrade.called)
|
self.assertTrue(self.do_openstack_upgrade.called)
|
||||||
|
self.assertTrue(self.apt_install.called)
|
||||||
|
|
||||||
def test_amqp_joined(self):
|
def test_amqp_joined(self):
|
||||||
self._call_hook('amqp-relation-joined')
|
self._call_hook('amqp-relation-joined')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user