def update_vim(self, context, vim_id, status):
     t_admin_context = t_context.get_admin_context()
     update_time = timeutils.utcnow()
     with t_admin_context.session.begin(subtransactions=True):
         try:
             query = t_admin_context.session.query(nfvo_db.Vim)
             query.filter(
                 nfvo_db.Vim.id == vim_id).update(
                     {'status': status,
                      'updated_at': update_time})
         except orm_exc.NoResultFound:
             raise nfvo.VimNotFoundException(vim_id=vim_id)
         event_db = common_services_db.Event(
             resource_id=vim_id,
             resource_type=constants.RES_TYPE_VIM,
             resource_state=status,
             event_details="",
             event_type=constants.RES_EVT_MONITOR,
             timestamp=update_time)
         t_admin_context.session.add(event_db)
     return status
 def create_event(self,
                  context,
                  res_id,
                  res_type,
                  res_state,
                  evt_type,
                  tstamp,
                  details=""):
     try:
         with context.session.begin(subtransactions=True):
             event_db = common_services_db.Event(resource_id=res_id,
                                                 resource_type=res_type,
                                                 resource_state=res_state,
                                                 event_details=details,
                                                 event_type=evt_type,
                                                 timestamp=tstamp)
             context.session.add(event_db)
     except Exception as e:
         LOG.exception("create event error: %s", str(e))
         raise common_services.EventCreationFailureException(
             error_str=str(e))
     return self._make_event_dict(event_db)