// Zones returns cloud provider zones
971823
func (os *OpenStack) Zones() (cloudprovider.Zones, bool) {
	glog.V(1).Info("Claiming to support Zones")

	return os, true
}
314533
func (d *dnsCache) ListZones(validity time.Duration) ([]dnsprovider.Zone, error) {
	d.mutex.Lock()
	defer d.mutex.Unlock()

	now := nanoTime()

	if d.cachedZones != nil {
		if (d.cachedZonesTimestamp + validity.Nanoseconds()) > now {
			return d.cachedZones, nil
		}
		glog.V(2).Infof("querying all DNS zones (cache expired)")
	} else {
		glog.V(2).Infof("querying all DNS zones (no cached results)")
	}

	var allZones []dnsprovider.Zone
	for _, zonesProvider := range d.zonesProviders {
		zones, err := zonesProvider.List()
		if err != nil {
			return nil, fmt.Errorf("error querying for DNS zones: %v", err)
		}

		allZones = append(allZones, zones...)
	}
	d.cachedZones = allZones
	d.cachedZonesTimestamp = now

	return allZones, nil
}
300593
func (s Session) AddTimeZones(zones ...TimeZone) Session {
	v := make([]byte, 0, 512)
	for i, zone := range zones {
		v = zone.append(v)
		if i != len(zones)-1 {
			v = appendSpace(v)
		}
	}
	return s.append(TypeTimeZones, v)
}
633336
func (ud *UltraDns) GetAllZones() ([]Zone, error) {
	var Res struct {
		QInfo QueryInfo  `json:"queryInfo"`
		RInfo ResultInfo `json:"resultInfo"`
		Zones []Zone     `json:"zones"`
	}

	_, body, err := ud.Client.Get(UltraHost+"/v1/zones").
		Set("Authorization", ud.tokenHeader).End()
	if err != nil {
		return Res.Zones, errors.New("Authentication Failed")
	}

	errr := json.Unmarshal([]byte(body), &Res)
	if errr != nil {
		return Res.Zones, errors.New("Unmarshal Error")
	}

	return Res.Zones, nil
}
395494
func (api *API) ListLoadBalancers(zoneID string) ([]LoadBalancer, error) {
	uri := "/zones/" + zoneID + "/load_balancers"
	res, err := api.makeRequest("GET", uri, nil)
	if err != nil {
		return nil, errors.Wrap(err, errMakeRequestError)
	}
	var r loadBalancerListResponse
	if err := json.Unmarshal(res, &r); err != nil {
		return nil, errors.Wrap(err, errUnmarshalError)
	}
	return r.Result, nil
}
48070
func getRegionFromZones(zones []string) (string, error) {
	regions := sets.String{}
	if len(zones) < 1 {
		return "", fmt.Errorf("no zones specified")
	}
	for _, zone := range zones {
		// Zone expected format {locale}-{region}-{zone}
		splitZone := strings.Split(zone, "-")
		if len(splitZone) != 3 {
			return "", fmt.Errorf("zone in unexpected format, expected: {locale}-{region}-{zone}, got: %v", zone)
		}
		regions.Insert(strings.Join(splitZone[0:2], "-"))
	}
	if regions.Len() != 1 {
		return "", fmt.Errorf("multiple or no regions gotten from zones, got: %v", regions)
	}
	return regions.UnsortedList()[0], nil
}
758812
func (a azMachineFilterSort) FilterZones(cons constraints.Value) azMachineFilterSort {
	if !cons.HasZones() {
		return a
	}

	logger.Debugf("applying availability zone constraints: %s", strings.Join(*cons.Zones, ", "))
	filtered := a[:0]
	for _, azm := range a {
		for _, zone := range *cons.Zones {
			if azm.ZoneName == zone {
				filtered = append(filtered, azm)
				break
			}
		}
	}
	return filtered
}
1149407
func (e *Environ) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) {
	e.availabilityZonesMutex.Lock()
	defer e.availabilityZonesMutex.Unlock()
	if e.availabilityZones == nil {
		zones, err := novaListAvailabilityZones(e.nova())
		if gooseerrors.IsNotImplemented(err) {
			return nil, errors.NotImplementedf("availability zones")
		}
		if err != nil {
			common.HandleCredentialError(IsAuthorisationFailure, err, ctx)
			return nil, err
		}
		e.availabilityZones = make([]common.AvailabilityZone, len(zones))
		for i, z := range zones {
			e.availabilityZones[i] = &openstackAvailabilityZone{z}
		}
	}
	return e.availabilityZones, nil
}
380099
func (v *VPCRouter) Zone() string {
	if v.Switch != nil {
		return v.Switch.GetZoneName()
	}

	if len(v.Interfaces) > 0 && v.Interfaces[0].Switch != nil {
		return v.Interfaces[0].Switch.GetZoneName()
	}

	return ""
}
1339130
func (api *ZonesAPI) GetAll() (result *Zones, err error) {
	uri := api.client.Endpoint + zoneUrl
	res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions)
	if err != nil {
		return
	}

	result = &Zones{}
	err = json.Unmarshal(res, result)
	return
}
794720
func (m *metadata) GetZone(ctx context.Context) (cloudprovider.Zone, error) {
	zone := cloudprovider.Zone{}

	if m.zone == "" {
		zoneName, err := m.get(metadataTypeZone)
		if err != nil {
			return zone, fmt.Errorf("could not get zone: %v", err)
		}

		m.zone = zoneName
	}

	klog.V(2).Infof("Current zone is %v", zone)
	zone.FailureDomain = m.zone
	zone.Region = m.zone

	return zone, nil
}
175679
func ZonesOfRegion(hc *http.Client, project, region string) (zones []string, err error) {
	s, err := compute.New(hc)
	if err != nil {
		return nil, err
	}
	zl, err := compute.NewZonesService(s).List(project).Do()
	if err != nil {
		return nil, fmt.Errorf("could not get a list of zones: %v", err)
	}
	if zl.NextPageToken != "" {
		return nil, errors.New("TODO: more than one page of zones found; use NextPageToken")
	}
	for _, z := range zl.Items {
		if path.Base(z.Region) != region {
			continue
		}
		zones = append(zones, z.Name)
	}
	return zones, nil
}
81042
func (client *AuroraDNSClient) GetZones() ([]zones.ZoneRecord, error) {
	logrus.Debugf("GetZones")
	response, err := client.requestor.Request("zones", "GET", []byte(""))

	if err != nil {
		logrus.Errorf("Failed to get zones: %s", err)
		return nil, err
	}

	var respData []zones.ZoneRecord
	err = json.Unmarshal(response, &respData)
	if err != nil {
		logrus.Errorf("Failed to unmarshall response: %s", err)
		return nil, err
	}

	logrus.Debugf("Unmarshalled response: %+v", respData)
	return respData, nil
}
362139
func Zone() (string, error) {
	zone, err := getTrimmed("instance/zone")
	// zone is of the form "projects/<projNum>/zones/<zoneName>".
	if err != nil {
		return "", err
	}
	return zone[strings.LastIndex(zone, "/")+1:], nil
}
789
func (az *Cloud) GetZone(ctx context.Context) (cloudprovider.Zone, error) {
	if az.UseInstanceMetadata {
		metadata, err := az.metadata.GetMetadata()
		if err != nil {
			return cloudprovider.Zone{}, err
		}

		if metadata.Compute == nil {
			return cloudprovider.Zone{}, fmt.Errorf("failure of getting compute information from instance metadata")
		}

		zone := ""
		if metadata.Compute.Zone != "" {
			zoneID, err := strconv.Atoi(metadata.Compute.Zone)
			if err != nil {
				return cloudprovider.Zone{}, fmt.Errorf("failed to parse zone ID %q: %v", metadata.Compute.Zone, err)
			}
			zone = az.makeZone(zoneID)
		} else {
			klog.V(3).Infof("Availability zone is not enabled for the node, falling back to fault domain")
			zone = metadata.Compute.FaultDomain
		}

		return cloudprovider.Zone{
			FailureDomain: zone,
			Region:        az.Location,
		}, nil
	}
	// if UseInstanceMetadata is false, get Zone name by calling ARM
	hostname, err := os.Hostname()
	if err != nil {
		return cloudprovider.Zone{}, fmt.Errorf("failure getting hostname from kernel")
	}
	return az.vmSet.GetZoneByNodeName(strings.ToLower(hostname))
}
1091226
func (m *MockZonedEnviron) AvailabilityZones(arg0 context.ProviderCallContext) ([]common.AvailabilityZone, error) {
	ret := m.ctrl.Call(m, "AvailabilityZones", arg0)
	ret0, _ := ret[0].([]common.AvailabilityZone)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
471986
func (api *API) ZoneSettings(zoneID string) (*ZoneSettingResponse, error) {
	uri := "/zones/" + zoneID + "/settings"
	res, err := api.makeRequest("GET", uri, nil)
	if err != nil {
		return nil, errors.Wrap(err, errMakeRequestError)
	}

	response := &ZoneSettingResponse{}
	err = json.Unmarshal(res, &response)
	if err != nil {
		return nil, errors.Wrap(err, errUnmarshalError)
	}

	return response, nil
}