def refresh_cache(f):
 argspec = inspect.getargspec(f)
 @functools.wraps(f)
 def wrapper(self, context, *args, **kwargs):
  res = f(self, context, *args, **kwargs)
  try:
   instance = kwargs.get('instance')
   if (not instance):
    instance = args[(argspec.args.index('instance') - 2)]
  except ValueError:
   msg = _('instance is a required argument to use @refresh_cache')
   raise Exception(msg)
  update_instance_cache_with_nw_info(self, context, instance, nw_info=res, conductor_api=kwargs.get('conductor_api'))
  return res
 return wrapper

def refresh_cache ( f ) : argspec = inspect . getargspec ( f ) @ functools . wraps ( f ) def wrapper ( self , context , * args , ** kwargs ) : res = f ( self , context , * args , ** kwargs ) try : instance = kwargs . get ( 'instance' ) if ( not instance ) : instance = args [ ( argspec . args . index ( 'instance' ) - 2 ) ] except ValueError : msg = _ ( 'instance is a required argument to use @refresh_cache' ) raise Exception ( msg ) update_instance_cache_with_nw_info ( self , context , instance , nw_info = res , conductor_api = kwargs . get ( 'conductor_api' ) ) return res return wrapper
decorator to update the instance_info_cache requires context and instance as function args .