def get_availability_zones(context, get_only_available=False, with_hosts=False):
 enabled_services = objects.ServiceList.get_all(context, disabled=False, set_zones=True)
 available_zones = []
 for (zone, host) in [(service['availability_zone'], service['host']) for service in enabled_services]:
  if ((not with_hosts) and (zone not in available_zones)):
   available_zones.append(zone)
  elif with_hosts:
   _available_zones = dict(available_zones)
   zone_hosts = _available_zones.setdefault(zone, set())
   zone_hosts.add(host)
   available_zones = list(_available_zones.items())
 if (not get_only_available):
  disabled_services = objects.ServiceList.get_all(context, disabled=True, set_zones=True)
  not_available_zones = []
  azs = (available_zones if (not with_hosts) else dict(available_zones))
  zones = [(service['availability_zone'], service['host']) for service in disabled_services if (service['availability_zone'] not in azs)]
  for (zone, host) in zones:
   if ((not with_hosts) and (zone not in not_available_zones)):
    not_available_zones.append(zone)
   elif with_hosts:
    _not_available_zones = dict(not_available_zones)
    zone_hosts = _not_available_zones.setdefault(zone, set())
    zone_hosts.add(host)
    not_available_zones = list(_not_available_zones.items())
  return (available_zones, not_available_zones)
 else:
  return available_zones

def get_availability_zones ( context , get_only_available = False , with_hosts = False ) : enabled_services = objects . ServiceList . get_all ( context , disabled = False , set_zones = True ) available_zones = [ ] for ( zone , host ) in [ ( service [ 'availability_zone' ] , service [ 'host' ] ) for service in enabled_services ] : if ( ( not with_hosts ) and ( zone not in available_zones ) ) : available_zones . append ( zone ) elif with_hosts : _available_zones = dict ( available_zones ) zone_hosts = _available_zones . setdefault ( zone , set ( ) ) zone_hosts . add ( host ) available_zones = list ( _available_zones . items ( ) ) if ( not get_only_available ) : disabled_services = objects . ServiceList . get_all ( context , disabled = True , set_zones = True ) not_available_zones = [ ] azs = ( available_zones if ( not with_hosts ) else dict ( available_zones ) ) zones = [ ( service [ 'availability_zone' ] , service [ 'host' ] ) for service in disabled_services if ( service [ 'availability_zone' ] not in azs ) ] for ( zone , host ) in zones : if ( ( not with_hosts ) and ( zone not in not_available_zones ) ) : not_available_zones . append ( zone ) elif with_hosts : _not_available_zones = dict ( not_available_zones ) zone_hosts = _not_available_zones . setdefault ( zone , set ( ) ) zone_hosts . add ( host ) not_available_zones = list ( _not_available_zones . items ( ) ) return ( available_zones , not_available_zones ) else : return available_zones
return available and unavailable zones .