def send_update(context, old_instance, new_instance, service='compute', host=None):
 if (not CONF.notifications.notify_on_state_change):
  return
 update_with_state_change = False
 old_vm_state = old_instance['vm_state']
 new_vm_state = new_instance['vm_state']
 old_task_state = old_instance['task_state']
 new_task_state = new_instance['task_state']
 if (old_vm_state != new_vm_state):
  update_with_state_change = True
 elif ((CONF.notifications.notify_on_state_change == 'vm_and_task_state') and (old_task_state != new_task_state)):
  update_with_state_change = True
 if update_with_state_change:
  send_update_with_states(context, new_instance, old_vm_state, new_vm_state, old_task_state, new_task_state, service, host)
 else:
  try:
   old_display_name = None
   if (new_instance['display_name'] != old_instance['display_name']):
    old_display_name = old_instance['display_name']
   _send_instance_update_notification(context, new_instance, service=service, host=host, old_display_name=old_display_name)
  except exception.InstanceNotFound:
   LOG.debug('Failed to send instance update notification. The instance could not be found and was most likely deleted.', instance=new_instance)
  except Exception:
   LOG.exception(_LE('Failed to send state update notification'), instance=new_instance)

def send_update ( context , old_instance , new_instance , service = 'compute' , host = None ) : if ( not CONF . notifications . notify_on_state_change ) : return update_with_state_change = False old_vm_state = old_instance [ 'vm_state' ] new_vm_state = new_instance [ 'vm_state' ] old_task_state = old_instance [ 'task_state' ] new_task_state = new_instance [ 'task_state' ] if ( old_vm_state != new_vm_state ) : update_with_state_change = True elif ( ( CONF . notifications . notify_on_state_change == 'vm_and_task_state' ) and ( old_task_state != new_task_state ) ) : update_with_state_change = True if update_with_state_change : send_update_with_states ( context , new_instance , old_vm_state , new_vm_state , old_task_state , new_task_state , service , host ) else : try : old_display_name = None if ( new_instance [ 'display_name' ] != old_instance [ 'display_name' ] ) : old_display_name = old_instance [ 'display_name' ] _send_instance_update_notification ( context , new_instance , service = service , host = host , old_display_name = old_display_name ) except exception . InstanceNotFound : LOG . debug ( 'Failed to send instance update notification. The instance could not be found and was most likely deleted.' , instance = new_instance ) except Exception : LOG . exception ( _LE ( 'Failed to send state update notification' ) , instance = new_instance )
send compute .