//CreateAZs : Creates Azure availability zone configuration based on the provided context
341371
func (c *azureCloudConfig) CreateAZs() ([]enaml.AZ, error) {
	azNames := c.Context.StringSlice("az")
	azs := []enaml.AZ{}
	for _, azName := range azNames {
		az := enaml.AZ{
			Name: azName,
		}
		azs = append(azs, az)
	}
	return azs, nil
}
1352503
func (d *driver) createVolumeEnsureAvailabilityZone(
	opts *types.VolumeCreateOpts, server *awsec2.Instance) {

	if opts.AvailabilityZone == nil || *opts.AvailabilityZone == "" {
		opts.AvailabilityZone = server.Placement.AvailabilityZone
	}
}
806387
func (env *environ) AvailabilityZones(ctx context.ProviderCallContext) (zones []common.AvailabilityZone, err error) {
	err = env.withSession(ctx, func(env *sessionEnviron) error {
		zones, err = env.AvailabilityZones(ctx)
		return err
	})
	return zones, err
}
711016
func (s *PoolService) NewCreateStoragePoolParams(name string, url string, zoneid string) *CreateStoragePoolParams {
	p := &CreateStoragePoolParams{}
	p.p = make(map[string]interface{})
	p.p["name"] = name
	p.p["url"] = url
	p.p["zoneid"] = zoneid
	return p
}
34643
func (env *sessionEnviron) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) {
	if env.zones == nil {
		computeResources, err := env.client.ComputeResources(env.ctx)
		if err != nil {
			HandleCredentialError(err, ctx)
			return nil, errors.Trace(err)
		}
		var zones []common.AvailabilityZone
		for _, cr := range computeResources {
			if cr.Summary.GetComputeResourceSummary().EffectiveCpu == 0 {
				logger.Debugf("skipping empty compute resource %q", cr.Name)
				continue
			}
			pools, err := env.client.ResourcePools(env.ctx, cr.Name+"/...")
			if err != nil {
				HandleCredentialError(err, ctx)
				return nil, errors.Trace(err)
			}
			for _, pool := range pools {
				zone := &vmwareAvailZone{
					r:    *cr,
					pool: pool,
				}
				logger.Tracef("zone: %q", zone.Name())
				zones = append(zones, zone)
			}
		}
		env.zones = zones
	}
	return env.zones, nil
}
1017817
func (s *VPCDerivedInfo) SetAvailabilityZones(v []*string) *VPCDerivedInfo {
	s.AvailabilityZones = v
	return s
}
669316
func (v *azureVolumeSource) CreateVolumes(ctx context.ProviderCallContext, params []storage.VolumeParams) (_ []storage.CreateVolumesResult, err error) {
	results := make([]storage.CreateVolumesResult, len(params))
	for i, p := range params {
		if err := v.ValidateVolumeParams(p); err != nil {
			results[i].Error = err
			continue
		}
	}
	if v.maybeStorageClient == nil {
		v.createManagedDiskVolumes(ctx, params, results)
		return results, nil
	}
	return results, v.createUnmanagedDiskVolumes(ctx, params, results)
}
1084095
func (s *DecreaseReplicationFactorInput) SetAvailabilityZones(v []*string) *DecreaseReplicationFactorInput {
	s.AvailabilityZones = v
	return s
}
584823
func (gce *Cloud) CreateSnapshot(diskName string, zone string, snapshotName string, tags map[string]string) error {
	isManaged := false
	for _, managedZone := range gce.managedZones {
		if zone == managedZone {
			isManaged = true
			break
		}
	}
	if !isManaged {
		return fmt.Errorf("kubernetes does not manage zone %q", zone)
	}
	tagsStr, err := gce.encodeDiskTags(tags)
	if err != nil {
		glog.Infof("CreateSnapshot err %v", err)
		return err
	}

	snapshotToCreate := &compute.Snapshot{
		Name:        snapshotName,
		Description: tagsStr,
	}
	glog.V(4).Infof("Create snapshot project %s, zone %s, diskName %s, snapshotToCreate %+v", gce.projectID, zone, diskName, snapshotToCreate)
	createOp, err := gce.service.Disks.CreateSnapshot(gce.projectID, zone, diskName, snapshotToCreate).Do()
	glog.V(4).Infof("Create snapshot operation %v", createOp)
	return err
}
986858
func (env *maasEnviron) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) {
	env.availabilityZonesMutex.Lock()
	defer env.availabilityZonesMutex.Unlock()
	if env.availabilityZones == nil {
		var availabilityZones []common.AvailabilityZone
		var err error
		if env.usingMAAS2() {
			availabilityZones, err = env.availabilityZones2(ctx)
			if err != nil {
				return nil, errors.Trace(err)
			}
		} else {
			availabilityZones, err = env.availabilityZones1(ctx)
			if err != nil {
				return nil, errors.Trace(err)
			}
		}
		env.availabilityZones = availabilityZones
	}
	return env.availabilityZones, nil
}
831206
func (gc *Connection) AvailabilityZones(region string) ([]AvailabilityZone, error) {
	rawZones, err := gc.raw.ListAvailabilityZones(gc.projectID, region)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var zones []AvailabilityZone
	for _, rawZone := range rawZones {
		zones = append(zones, AvailabilityZone{rawZone})
	}
	return zones, nil
}
575063
func (s *DBCluster) SetAvailabilityZones(v []*string) *DBCluster {
	s.AvailabilityZones = v
	return s
}
1036527
func (env *environ) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) {
	// TODO(dimitern): Fix this properly.
	return []common.AvailabilityZone{
		azShim{"zone1", true},
		azShim{"zone2", false},
		azShim{"zone3", true},
		azShim{"zone4", true},
	}, nil
}
296429
func (g *Cloud) CreateNetworkEndpointGroup(neg *computebeta.NetworkEndpointGroup, zone string) error {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newNetworkEndpointGroupMetricContext("create", zone)
	return mc.Observe(g.c.BetaNetworkEndpointGroups().Insert(ctx, meta.ZonalKey(neg.Name, zone), neg))
}
323354
func (env *environ) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) {
	zones, err := env.gce.AvailabilityZones(env.cloud.Region)
	if err != nil {
		return nil, google.HandleCredentialError(errors.Trace(err), ctx)
	}

	var result []common.AvailabilityZone
	for _, zone := range zones {
		if zone.Deprecated() {
			continue
		}
		// We make a copy since the loop var keeps the same pointer.
		zoneCopy := zone
		result = append(result, &zoneCopy)
	}
	return result, nil
}
537305
func CreateLease(c *cli.Context) {
	// inspect env for auth env var
	authToken := os.Getenv("AUTH_TOKEN")
	if authToken == "" {
		log.Fatal("An authorization token is required in the form of an env var AUTH_TOKEN")
	}
	server := c.GlobalString("server")
	if server == "" {
		log.Fatal("Server missing")
	}
	durationSec := c.Int("duration")
	if durationSec <= 0 {
		log.Fatalf("Invalid duration %d", durationSec)
	}
	envPrefix := c.String("env-prefix")
	clusterRegex := c.String("cluster-regex")
	clusterVersion := c.String("cluster-version")
	cloudProvider := c.String("provider")
	if cloudProvider == "" {
		log.Fatal("Cloud Provider not provided")
	}
	if cloudProvider == "azure" && clusterVersion != "" {
		log.Fatal("Finding clusters by version is currently not supported with Azure!")
	}

	kcfgFile := c.String("kubeconfig-file")
	if len(kcfgFile) < 1 {
		log.Fatal("Missing kubeconfig-file")
	}

	fd, err := os.Create(kcfgFile)
	if err != nil {
		log.Fatalf("Error opening %s: %s", kcfgFile, err)
	}
	defer fd.Close()

	resp, err := client.CreateLease(server, authToken, cloudProvider, clusterVersion, clusterRegex, durationSec)
	if err != nil {
		log.Fatalf("Error returned from server when creating lease: %s", err)
	}

	kcfg, err := resp.KubeConfigBytes()
	if err != nil {
		log.Fatalf("Error decoding kubeconfig: %s", err)
	}
	fmt.Println(exportVar(envPrefix, ipEnvVarName, resp.IP))
	fmt.Println(exportVar(envPrefix, tokenEnvVarName, resp.Token))
	fmt.Println(exportVar(envPrefix, clusterNameEnvVarName, resp.ClusterName))

	if _, err := io.Copy(fd, bytes.NewBuffer(kcfg)); err != nil {
		log.Fatalf("Error writing new Kubeconfig file to %s: %s", kcfgFile, err)
	}
}
157831
func (s *ElasticsearchClusterConfig) SetZoneAwarenessConfig(v *ZoneAwarenessConfig) *ElasticsearchClusterConfig {
	s.ZoneAwarenessConfig = v
	return s
}