Added united test and added kilo/juno condition

This commit is contained in:
Sunny Verma 2016-02-19 19:01:11 -05:00
parent da212dac4f
commit ec48ad5f90
4 changed files with 43 additions and 14 deletions

View File

@ -284,10 +284,16 @@ options:
nuage-packages:
type: string
default: "nuage-openstack-neutron nuagenetlib"
description: Its [nuage-openstack-neutron nuagenetlib] for Nuage VSP >=3.2R4 and [nuage-neutron python-nuagenetlib] of Nuage VSP <=3.2R3
description: |
Its [nuage-openstack-neutron nuagenetlib] for Nuage VSP >=3.2R4 & KILO
and [nuage-neutron python-nuagenetlib] of Nuage VSP <=3.0 & JUNO
vsd-cms-name:
type: string
description: Please give Maas env id so that it is unique per openstack env.
description: |
This is required only for 3.2 R4 and above releases of Nuage and Kilo.
Please give Maas env id so that it is unique per openstack cluster.
This name is used to create th CMS ID on Nuage-VSD which should be unique per OSP cluster.
Your Deployment will fail if this config is not provided.
vsd-server:
type: string
default:

View File

@ -185,16 +185,16 @@ class NeutronCCContext(context.NeutronContext):
for unit in related_units(rid):
rdata = relation_get(rid=rid, unit=unit)
vsd_ip = rdata.get('vsd-ip-address')
cms_id_value = rdata.get('nuage-cms-id')
if os_release('neutron-server') >= 'kilo':
cms_id_value = rdata.get('nuage-cms-id')
log('relation data:cms_id: {}'.format(cms_id_value))
if cms_id_value is not None:
ctxt['cms_id'] = '{}'.format(cms_id_value)
log('relation data:vsd-ip-address: {}'.format(vsd_ip))
log('relation data:cms_id: {}'.format(cms_id_value))
if vsd_ip is not None:
ctxt['vsd_server'] = '{}:8443'.format(vsd_ip)
if cms_id_value is not None:
ctxt['cms_id'] = '{}'.format(cms_id_value)
if 'vsd_server' not in ctxt:
ctxt['vsd_server'] = '1.1.1.1:8443'
ctxt['verbose'] = config('verbose')
ctxt['debug'] = config('debug')
ctxt['neutron_bind_port'] = \

View File

@ -204,11 +204,18 @@ def install():
@hooks.hook('vsd-rest-api-relation-joined')
@restart_on_change(restart_map(), stopstart=True)
@os_requires_version('kilo')
def relation_set_nuage_cms_name(rid=None):
relation_data = {
'vsd-cms-name': '{}'.format(config('vsd-cms-name'))
}
relation_set(relation_id=rid, **relation_data)
if config('vsd-cms-name') is None:
e ="Neutron Api hook failed as vsd-cms-name" \
" is not specified"
status_set('blocked', e)
else:
relation_data = {
'vsd-cms-name': '{}'.
format(config('vsd-cms-name'))
}
relation_set(relation_id=rid, **relation_data)
@hooks.hook('vsd-rest-api-relation-changed')
@ -219,12 +226,14 @@ def vsd_changed(relation_id=None, remote_unit=None):
if not vsd_ip_address:
return
vsd_address = '{}:8443'.format(vsd_ip_address)
cms_id = relation_get('nuage-cms-id')
if os_release('neutron') >= 'kilo':
cms_id = relation_get('nuage-cms-id')
log("nuage-vsd-api-relation-changed : cms_id:{}".format(cms_id))
nuage_config_file = neutron_plugin_attribute(config('neutron-plugin'),
'config', 'neutron')
log('vsd-rest-api-relation-changed: ip address:{}'.format(vsd_address))
log('vsd-rest-api-relation-changed:{}'.format(nuage_config_file))
log("nuage-vsd-api-relation-changed : cms_id:{}".format(cms_id))
CONFIGS.write(nuage_config_file)

View File

@ -483,16 +483,30 @@ class NeutronAPIHooksTests(CharmTestCase):
)
def test_vsd_api_relation_changed(self):
self.os_release.return_value = 'kilo'
self.test_config.set('neutron-plugin', 'vsp')
self.test_relation.set({
'vsd-ip-address': '10.11.12.13',
'nuage-cms-id': 'abc'
})
self._call_hook('vsd-rest-api-relation-changed')
config_file = '/etc/neutron/plugins/nuage/nuage_plugin.ini'
self.assertTrue(self.CONFIGS.write.called_with(config_file))
def test_vsd_api_relation_joined(self):
self.os_release.return_value = 'juno'
with self.assertRaises(Exception) as context:
self._call_hook('vsd-rest-api-relation-joined')
self.assertEqual(
context.exception.message,
"This hook is not supported on releases before kilo"
)
self.os_release.return_value = 'kilo'
self._call_hook('vsd-rest-api-relation-joined')
e ="Neutron Api hook failed as vsd-cms-name" \
" is not specified"
self.status_set.assert_called_with(
'blocked', e)
self.test_config.set('vsd-cms-name', '1234567890')
_relation_data = {
'vsd-cms-name': '1234567890',