@utils.expects_func_args('migration')
def errors_out_migration(function):
 @functools.wraps(function)
 def decorated_function(self, context, *args, **kwargs):
  try:
   return function(self, context, *args, **kwargs)
  except Exception as ex:
   with excutils.save_and_reraise_exception():
    wrapped_func = safe_utils.get_wrapped_function(function)
    keyed_args = inspect.getcallargs(wrapped_func, self, context, *args, **kwargs)
    migration = keyed_args['migration']
    if (not isinstance(ex, exception.InstanceNotFound)):
     status = migration.status
     if (status not in ['migrating', 'post-migrating']):
      return
    migration.status = 'error'
    try:
     with migration.obj_as_admin():
      migration.save()
    except Exception:
     LOG.debug('Error setting migration status for instance %s.', migration.instance_uuid, exc_info=True)
 return decorated_function

@ utils . expects_func_args ( 'migration' ) def errors_out_migration ( function ) : @ functools . wraps ( function ) def decorated_function ( self , context , * args , ** kwargs ) : try : return function ( self , context , * args , ** kwargs ) except Exception as ex : with excutils . save_and_reraise_exception ( ) : wrapped_func = safe_utils . get_wrapped_function ( function ) keyed_args = inspect . getcallargs ( wrapped_func , self , context , * args , ** kwargs ) migration = keyed_args [ 'migration' ] if ( not isinstance ( ex , exception . InstanceNotFound ) ) : status = migration . status if ( status not in [ 'migrating' , 'post-migrating' ] ) : return migration . status = 'error' try : with migration . obj_as_admin ( ) : migration . save ( ) except Exception : LOG . debug ( 'Error setting migration status for instance %s.' , migration . instance_uuid , exc_info = True ) return decorated_function
decorator to error out migration on failure .