def get_instance_availability_zone(context, instance):
 host = instance.get('host')
 if (not host):
  az = instance.get('availability_zone')
  return az
 cache_key = _make_cache_key(host)
 cache = _get_cache()
 az = cache.get(cache_key)
 az_inst = instance.get('availability_zone')
 if ((az_inst is not None) and (az != az_inst)):
  az = None
 if (not az):
  elevated = context.elevated()
  az = get_host_availability_zone(elevated, host)
  cache.set(cache_key, az)
 return az

def get_instance_availability_zone ( context , instance ) : host = instance . get ( 'host' ) if ( not host ) : az = instance . get ( 'availability_zone' ) return az cache_key = _make_cache_key ( host ) cache = _get_cache ( ) az = cache . get ( cache_key ) az_inst = instance . get ( 'availability_zone' ) if ( ( az_inst is not None ) and ( az != az_inst ) ) : az = None if ( not az ) : elevated = context . elevated ( ) az = get_host_availability_zone ( elevated , host ) cache . set ( cache_key , az ) return az
return availability zone of specified instance .