//Change the compute offering of the instance with the specified id exists in the current environment
//Note: This will reboot your instance if running
543251
func (instanceApi *InstanceApi) ChangeComputeOffering(instance Instance) (bool, error) {
	send, merr := json.Marshal(instance)
	if merr != nil {
		return false, merr
	}
	_, err := instanceApi.entityService.Execute(instance.Id, INSTANCE_CHANGE_COMPUTE_OFFERING_OPERATION, send, map[string]string{})
	return err == nil, err
}
32229
func InstanceID(ctx context.Context) (*types.InstanceID, bool) {
	v, ok := ctx.Value(InstanceIDKey).(*types.InstanceID)
	return v, ok
}
877710
func (s *FakeAWSServices) Compute(region string) (EC2, error) {
	return s.ec2, nil
}
50993
func (d *Deployer) Create(ctx context.Context) (*compute.Instance, error) {
	if err := d.enableAPIs(); err != nil {
		return nil, projectIDError{
			id:    d.Conf.Project,
			cause: err,
		}
	}
	if err := d.checkProjectID(); err != nil {
		return nil, err
	}

	computeService, _ := compute.New(d.Client)
	storageService, _ := storage.New(d.Client)

	fwc := make(chan error, 1)
	go func() {
		fwc <- d.setFirewall(ctx, computeService)
	}()

	config := cloudConfig(d.Conf)
	const maxCloudConfig = 32 << 10 // per compute API docs
	if len(config) > maxCloudConfig {
		return nil, fmt.Errorf("cloud config length of %d bytes is over %d byte limit", len(config), maxCloudConfig)
	}

	if zone, err := d.projectHasInstance(); zone != "" {
		return nil, instanceExistsError{
			project: d.Conf.Project,
			zone:    zone,
		}
	} else if err != nil {
		return nil, fmt.Errorf("could not scan project for existing instances: %v", err)
	}

	if err := d.setBuckets(ctx, storageService); err != nil {
		return nil, fmt.Errorf("could not create buckets: %v", err)
	}

	if err := d.createInstance(ctx, computeService); err != nil {
		return nil, fmt.Errorf("could not create compute instance: %v", err)
	}

	inst, err := computeService.Instances.Get(d.Conf.Project, d.Conf.Zone, d.Conf.Name).Do()
	if err != nil {
		return nil, fmt.Errorf("error getting instance after creation: %v", err)
	}
	if Verbose {
		ij, _ := json.MarshalIndent(inst, "", "    ")
		d.Printf("Instance: %s", ij)
	}

	if err = <-fwc; err != nil {
		return nil, fmt.Errorf("could not create firewall rules: %v", err)
	}
	return inst, nil
}
1012399
func (s *RebootInstanceInput) SetInstanceId(v string) *RebootInstanceInput {
	s.InstanceId = &v
	return s
}
545034
func (t *KVMsTable) computeChanges(c context.Context, datacenters []*config.Datacenter) error {
	cfgs := make(map[string]*KVM, len(datacenters))
	for _, dc := range datacenters {
		for _, cfg := range dc.Kvm {
			ipv4, err := common.ParseIPv4(cfg.Ipv4)
			if err != nil {
				return errors.Reason("failed to determine IP address for KVM %q: invalid IPv4 address %q", cfg.Name, cfg.Ipv4).Err()
			}
			mac48, err := common.ParseMAC48(cfg.MacAddress)
			if err != nil {
				return errors.Reason("failed to determine MAC address for KVM %q: invalid MAC-48 address %q", cfg.Name, cfg.MacAddress).Err()
			}
			pId, ok := t.platforms[cfg.Platform]
			if !ok {
				return errors.Reason("failed to determine platform ID for KVM %q: platform %q does not exist", cfg.Name, cfg.Platform).Err()
			}
			rId, ok := t.racks[cfg.Rack]
			if !ok {
				return errors.Reason("failed to determine rack ID for KVM %q: rack %q does not exist", cfg.Name, cfg.Rack).Err()
			}
			cfgs[cfg.Name] = &KVM{
				KVM: config.KVM{
					Name:        cfg.Name,
					Description: cfg.Description,
					State:       cfg.State,
				},
				IPv4:       ipv4,
				MacAddress: mac48,
				PlatformId: pId,
				RackId:     rId,
			}
		}
	}

	for _, kvm := range t.current {
		if cfg, ok := cfgs[kvm.Name]; ok {
			// KVM found in the config.
			if t.needsUpdate(kvm, cfg) {
				// KVM doesn't match the config.
				cfg.Id = kvm.Id
				t.updates = append(t.updates, cfg)
			}
			// Record that the KVM config has been seen.
			delete(cfgs, cfg.Name)
		} else {
			// KVM not found in the config.
			t.removals = append(t.removals, kvm)
		}
	}

	// KVMs remaining in the map are present in the config but not the database.
	// Iterate deterministically over the slices to determine which KVMs need to be added.
	for _, dc := range datacenters {
		for _, cfg := range dc.Kvm {
			if kvm, ok := cfgs[cfg.Name]; ok {
				t.additions = append(t.additions, kvm)
			}
		}
	}
	return nil
}
888293
func (m *Machine) InstanceId() (instance.Id, error) {
	instId, _, err := m.InstanceNames()
	return instId, err
}
1001471
func (cg *Consumergroup) Instance(id string) *ConsumergroupInstance {
	return &ConsumergroupInstance{cg: cg, ID: id}
}
418062
func (t *DatacentersTable) computeChanges(c context.Context, datacenters []*config.Datacenter) {
	cfgs := make(map[string]*Datacenter, len(datacenters))
	for _, cfg := range datacenters {
		cfgs[cfg.Name] = &Datacenter{
			Datacenter: config.Datacenter{
				Name:        cfg.Name,
				Description: cfg.Description,
				State:       cfg.State,
			},
		}
	}

	for _, dc := range t.current {
		if cfg, ok := cfgs[dc.Name]; ok {
			// Datacenter found in the config.
			if t.needsUpdate(dc, cfg) {
				// Datacenter doesn't match the config.
				cfg.Id = dc.Id
				t.updates = append(t.updates, cfg)
			}
			// Record that the datacenter config has been seen.
			delete(cfgs, cfg.Name)
		} else {
			// Datacenter not found in the config.
			t.removals = append(t.removals, dc)
		}
	}

	// Datacenters remaining in the map are present in the config but not the database.
	// Iterate deterministically over the slice to determine which datacenters need to be added.
	for _, cfg := range datacenters {
		if dc, ok := cfgs[cfg.Name]; ok {
			t.additions = append(t.additions, dc)
		}
	}
}
636299
func (s *DeregisterInstanceInput) SetInstanceId(v string) *DeregisterInstanceInput {
	s.InstanceId = &v
	return s
}
151005
func (s *BuildConfiguration) SetComputeType(v string) *BuildConfiguration {
	s.ComputeType = &v
	return s
}
717557
func (t *IPsTable) computeChanges(c context.Context, vlans []*config.VLAN) error {
	cfgs := make(map[common.IPv4]*IP, len(vlans))
	for _, vlan := range vlans {
		ipv4, length, err := common.IPv4Range(vlan.CidrBlock)
		if err != nil {
			return errors.Annotate(err, "failed to determine start address and range for CIDR block %q", vlan.CidrBlock).Err()
		}
		// TODO(smut): Mark the first address as the network address and the last address as the broadcast address.
		for i := int64(0); i < length; i++ {
			cfgs[ipv4] = &IP{
				IPv4:   ipv4,
				VLANId: vlan.Id,
			}
			ipv4 += 1
		}
	}

	for _, ip := range t.current {
		if cfg, ok := cfgs[ip.IPv4]; ok {
			// IP address found in the config.
			if t.needsUpdate(ip, cfg) {
				// IP address doesn't match the config.
				cfg.Id = ip.Id
				t.updates = append(t.updates, cfg)
			}
			// Record that the IP address config has been seen.
			delete(cfgs, cfg.IPv4)
		} else {
			// IP address not found in the config.
			t.removals = append(t.removals, ip)
		}
	}

	// IP addresses remaining in the map are present in the config but not the database.
	// Iterate deterministically over the slices to determine which IP addresses need to be added.
	for _, vlan := range vlans {
		ipv4, length, err := common.IPv4Range(vlan.CidrBlock)
		if err != nil {
			return errors.Annotate(err, "failed to determine start address and range for CIDR block %q", vlan.CidrBlock).Err()
		}
		for i := int64(0); i < length; i++ {
			if ip, ok := cfgs[ipv4]; ok {
				t.additions = append(t.additions, ip)
			}
			ipv4 += 1
		}
	}
	return nil
}
1045014
func (c *Client) ChangeApplicationofServer(id string, appID string) error {
	values := url.Values{
		"SUBID": {id},
		"APPID": {appID},
	}

	if err := c.post(`server/app_change`, values, nil); err != nil {
		return err
	}
	return nil
}
51123
func (s *DescribeReservationOutput) SetOfferingId(v string) *DescribeReservationOutput {
	s.OfferingId = &v
	return s
}
579767
func (d *Executor) InstanceID(
	ctx types.Context,
	opts types.Store) (*types.InstanceID, error) {
	return d.instanceID, nil
}
530940
func (f *Fetcher) Offer(source *enode.ID) {
	// First we need to have this select to make sure that we return if context is done
	select {
	case <-f.ctx.Done():
		return
	default:
	}

	// This select alone would not guarantee that we return of context is done, it could potentially
	// push to offerC instead if offerC is available (see number 2 in https://golang.org/ref/spec#Select_statements)
	select {
	case f.offerC <- source:
	case <-f.ctx.Done():
	}
}
305399
func (s *CreateInstanceOutput) SetInstanceId(v string) *CreateInstanceOutput {
	s.InstanceId = &v
	return s
}