Added united test and added kilo/juno condition
This commit is contained in:
parent
da212dac4f
commit
ec48ad5f90
10
config.yaml
10
config.yaml
@ -284,10 +284,16 @@ options:
|
|||||||
nuage-packages:
|
nuage-packages:
|
||||||
type: string
|
type: string
|
||||||
default: "nuage-openstack-neutron nuagenetlib"
|
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:
|
vsd-cms-name:
|
||||||
type: string
|
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:
|
vsd-server:
|
||||||
type: string
|
type: string
|
||||||
default:
|
default:
|
||||||
|
@ -185,16 +185,16 @@ class NeutronCCContext(context.NeutronContext):
|
|||||||
for unit in related_units(rid):
|
for unit in related_units(rid):
|
||||||
rdata = relation_get(rid=rid, unit=unit)
|
rdata = relation_get(rid=rid, unit=unit)
|
||||||
vsd_ip = rdata.get('vsd-ip-address')
|
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:vsd-ip-address: {}'.format(vsd_ip))
|
||||||
log('relation data:cms_id: {}'.format(cms_id_value))
|
|
||||||
if vsd_ip is not None:
|
if vsd_ip is not None:
|
||||||
ctxt['vsd_server'] = '{}:8443'.format(vsd_ip)
|
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:
|
if 'vsd_server' not in ctxt:
|
||||||
ctxt['vsd_server'] = '1.1.1.1:8443'
|
ctxt['vsd_server'] = '1.1.1.1:8443'
|
||||||
|
|
||||||
ctxt['verbose'] = config('verbose')
|
ctxt['verbose'] = config('verbose')
|
||||||
ctxt['debug'] = config('debug')
|
ctxt['debug'] = config('debug')
|
||||||
ctxt['neutron_bind_port'] = \
|
ctxt['neutron_bind_port'] = \
|
||||||
|
@ -204,11 +204,18 @@ def install():
|
|||||||
|
|
||||||
@hooks.hook('vsd-rest-api-relation-joined')
|
@hooks.hook('vsd-rest-api-relation-joined')
|
||||||
@restart_on_change(restart_map(), stopstart=True)
|
@restart_on_change(restart_map(), stopstart=True)
|
||||||
|
@os_requires_version('kilo')
|
||||||
def relation_set_nuage_cms_name(rid=None):
|
def relation_set_nuage_cms_name(rid=None):
|
||||||
relation_data = {
|
if config('vsd-cms-name') is None:
|
||||||
'vsd-cms-name': '{}'.format(config('vsd-cms-name'))
|
e ="Neutron Api hook failed as vsd-cms-name" \
|
||||||
}
|
" is not specified"
|
||||||
relation_set(relation_id=rid, **relation_data)
|
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')
|
@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:
|
if not vsd_ip_address:
|
||||||
return
|
return
|
||||||
vsd_address = '{}:8443'.format(vsd_ip_address)
|
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'),
|
nuage_config_file = neutron_plugin_attribute(config('neutron-plugin'),
|
||||||
'config', 'neutron')
|
'config', 'neutron')
|
||||||
log('vsd-rest-api-relation-changed: ip address:{}'.format(vsd_address))
|
log('vsd-rest-api-relation-changed: ip address:{}'.format(vsd_address))
|
||||||
log('vsd-rest-api-relation-changed:{}'.format(nuage_config_file))
|
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)
|
CONFIGS.write(nuage_config_file)
|
||||||
|
|
||||||
|
|
||||||
|
@ -483,16 +483,30 @@ class NeutronAPIHooksTests(CharmTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_vsd_api_relation_changed(self):
|
def test_vsd_api_relation_changed(self):
|
||||||
|
self.os_release.return_value = 'kilo'
|
||||||
self.test_config.set('neutron-plugin', 'vsp')
|
self.test_config.set('neutron-plugin', 'vsp')
|
||||||
self.test_relation.set({
|
self.test_relation.set({
|
||||||
'vsd-ip-address': '10.11.12.13',
|
'vsd-ip-address': '10.11.12.13',
|
||||||
|
'nuage-cms-id': 'abc'
|
||||||
})
|
})
|
||||||
self._call_hook('vsd-rest-api-relation-changed')
|
self._call_hook('vsd-rest-api-relation-changed')
|
||||||
|
|
||||||
config_file = '/etc/neutron/plugins/nuage/nuage_plugin.ini'
|
config_file = '/etc/neutron/plugins/nuage/nuage_plugin.ini'
|
||||||
self.assertTrue(self.CONFIGS.write.called_with(config_file))
|
self.assertTrue(self.CONFIGS.write.called_with(config_file))
|
||||||
|
|
||||||
def test_vsd_api_relation_joined(self):
|
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')
|
self.test_config.set('vsd-cms-name', '1234567890')
|
||||||
_relation_data = {
|
_relation_data = {
|
||||||
'vsd-cms-name': '1234567890',
|
'vsd-cms-name': '1234567890',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user