VIM event type fixed to be of type Monitor

This commit ensures that the event type for the VIM status
"Reachable" that is set during Monitor operation is set to be
of event type "Monitor" instead of "Update"

Change-Id: I9ab8bcba1df8d1ce4345e2b07b0565ce8e6a24da
Closes-Bug: #1623064
This commit is contained in:
vish 2016-09-19 18:16:36 +00:00
parent 3f4e899f79
commit 79cbdc6f3b
3 changed files with 14 additions and 9 deletions

View File

@ -215,13 +215,8 @@ class NfvoPluginDb(nfvo.NFVOPluginBase, db_base.CommonDbMixin):
Vim.id == vim_id).with_lockmode('update').one())
except orm_exc.NoResultFound:
raise nfvo.VimNotFoundException(vim_id=vim_id)
vim_db.update({'status': status})
self._cos_db_plg.create_event(
context, res_id=vim_db['id'],
res_type=constants.RES_TYPE_VIM,
res_state=vim_db['status'],
evt_type=constants.RES_EVT_UPDATE,
tstamp=timeutils.utcnow())
vim_db.update({'status': status,
'updated_at': timeutils.utcnow()})
return self._make_vim_dict(vim_db)
# Deprecated. Will be removed in Ocata release

View File

@ -141,10 +141,16 @@ class NfvoPlugin(nfvo_db.NfvoPluginDb, vnffg_db.VnffgPluginDbMixin):
if current_status != vim_obj["status"]:
status = current_status
with self._lock:
super(NfvoPlugin, self).update_vim_status(
t_context.get_admin_context(),
context = t_context.get_admin_context()
res = super(NfvoPlugin, self).update_vim_status(context,
vim_id, status)
self._created_vims[vim_id]["status"] = status
self._cos_db_plg.create_event(
context, res_id=res['id'],
res_type=constants.RES_TYPE_VIM,
res_state=res['status'],
evt_type=constants.RES_EVT_MONITOR,
tstamp=res[constants.RES_EVT_UPDATED_FLD])
@log.log
def validate_tosca(self, template):

View File

@ -186,6 +186,10 @@ class TestNfvoPlugin(db_base.SqlTestCase):
self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY,
res_state=mock.ANY, res_type=constants.RES_TYPE_VIM,
tstamp=mock.ANY)
self._cos_db_plugin.create_event.assert_any_call(
mock.ANY, evt_type=constants.RES_EVT_MONITOR, res_id=mock.ANY,
res_state=mock.ANY, res_type=constants.RES_TYPE_VIM,
tstamp=mock.ANY)
self._driver_manager.invoke.assert_any_call(vim_type,
'register_vim', vim_obj=vim_dict['vim'])
self._driver_manager.invoke.assert_any_call('openstack', 'vim_status',