def action_event_finish(context, values):
 convert_datetimes(values, 'start_time', 'finish_time')
 session = get_session()
 with session.begin():
  action = _action_get_by_request_id(context, values['instance_uuid'], values['request_id'], session)
  if (not action):
   raise exception.InstanceActionNotFound(request_id=values['request_id'], instance_uuid=values['instance_uuid'])
  event_ref = model_query(context, models.InstanceActionEvent, session=session).filter_by(action_id=action['id']).filter_by(event=values['event']).first()
  if (not event_ref):
   raise exception.InstanceActionEventNotFound(action_id=action['id'], event=values['event'])
  event_ref.update(values)
  if (values['result'].lower() == 'error'):
   action.update({'message': 'Error'})
 return event_ref

def action_event_finish ( context , values ) : convert_datetimes ( values , 'start_time' , 'finish_time' ) session = get_session ( ) with session . begin ( ) : action = _action_get_by_request_id ( context , values [ 'instance_uuid' ] , values [ 'request_id' ] , session ) if ( not action ) : raise exception . InstanceActionNotFound ( request_id = values [ 'request_id' ] , instance_uuid = values [ 'instance_uuid' ] ) event_ref = model_query ( context , models . InstanceActionEvent , session = session ) . filter_by ( action_id = action [ 'id' ] ) . filter_by ( event = values [ 'event' ] ) . first ( ) if ( not event_ref ) : raise exception . InstanceActionEventNotFound ( action_id = action [ 'id' ] , event = values [ 'event' ] ) event_ref . update ( values ) if ( values [ 'result' ] . lower ( ) == 'error' ) : action . update ( { 'message' : 'Error' } ) return event_ref
finish an event on an instance action .