'Verify that the availability zones exist.'

@db_api.retry_if_session_inactive()
def validate_availability_zones(self, context, resource_type, availability_zones):

    if (not availability_zones):
        return
    if (resource_type == 'network'):
        agent_type = constants.AGENT_TYPE_DHCP
    elif (resource_type == 'router'):
        agent_type = constants.AGENT_TYPE_L3
    else:
        return
    query = context.session.query(agent_model.Agent.availability_zone).filter_by(agent_type=agent_type).group_by(agent_model.Agent.availability_zone)
    query = query.filter(agent_model.Agent.availability_zone.in_(availability_zones))
    azs = [item[0] for item in query]
    diff = (set(availability_zones) - set(azs))
    if diff:
        raise az_ext.AvailabilityZoneNotFound(availability_zone=diff.pop())
