// Get the VM field of the given VBD.
488036
func (_class VBDClass) GetVM(sessionID SessionRef, self VBDRef) (_retval VMRef, _err error) {
	_method := "VBD.get_VM"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVBDRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertVMRefToGo(_method + " -> ", _result.Value)
	return
}
979301
func (c *Client) GetVirtualMachineUserData(p *GetVirtualMachineUserDataParameter) (*VirtualMachineUserData, error) {
	obj, err := c.Request("getVirtualMachineUserData", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*VirtualMachineUserData), err
}
932628
func (_class VIFClass) GetVM(sessionID SessionRef, self VIFRef) (_retval VMRef, _err error) {
	_method := "VIF.get_VM"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVIFRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertVMRefToGo(_method + " -> ", _result.Value)
	return
}
1263454
func (_class VMMetricsClass) GetCurrentDomainType(sessionID SessionRef, self VMMetricsRef) (_retval DomainType, _err error) {
	_method := "VM_metrics.get_current_domain_type"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVMMetricsRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertEnumDomainTypeToGo(_method + " -> ", _result.Value)
	return
}
333039
func (d *DeviceMapperDriver) getVolume(volumeName string, create bool) (*DeviceMapperVolume, error) {
	tenant := getTenant(volumeName)
	metadata, err := NewMetadata(d.MetadataPath(tenant), create)
	if err != nil {
		return nil, err
	}
	vol := &DeviceMapperVolume{
		name:     volumeName,
		path:     d.volumeDir(volumeName),
		tenant:   tenant,
		driver:   d,
		Metadata: metadata,
	}

	// if create is false, check to make sure the metadata info isn't empty or equal to base
	if !create {
		deviceHash := vol.deviceHash()
		if deviceHash == "" || deviceHash == "base" {
			return nil, ErrBaseDeviceHash
		}
	}

	return vol, nil
}
1240277
func (d *driver) getVolumeMapping(ctx types.Context) ([]*types.Volume, error) {

	var (
		err         error
		mapDiskByID map[string]string
		mas         []*vboxw.IMediumAttachment
		m           *vboxc.Machine
		iid         = context.MustInstanceID(ctx)
	)

	m, err = d.findMachineByInstanceID(ctx, iid)
	if err != nil {
		return nil, err
	}

	if err = m.Refresh(); err != nil {
		return nil, err
	}
	defer m.Release()

	ld, ok := context.LocalDevices(ctx)
	if !ok {
		return nil, goof.New("missing local devices")
	}
	mapDiskByID = ld.DeviceMap

	mas, err = m.GetMediumAttachments()
	if err != nil {
		return nil, err
	}

	var blockDevices []*types.Volume
	for _, ma := range mas {
		medium := d.vbox.NewMedium(ma.Medium)
		defer medium.Release()

		mid, err := medium.GetID()
		if err != nil {
			return nil, err
		}
		smid := strings.Split(mid, "-")
		if len(smid) == 0 {
			continue
		}

		location, err := medium.GetLocation()
		if err != nil {
			return nil, err
		}

		var bdn string
		var ok bool
		if bdn, ok = mapDiskByID[smid[0]]; !ok {
			continue
		}
		sdBlockDevice := &types.Volume{
			Name:   bdn,
			ID:     mid,
			Status: location,
		}
		blockDevices = append(blockDevices, sdBlockDevice)

	}
	return blockDevices, nil
}
163374
func (az *Cloud) getVirtualMachine(nodeName types.NodeName) (vm compute.VirtualMachine, err error) {
	vmName := string(nodeName)
	cachedVM, err := az.vmCache.Get(vmName)
	if err != nil {
		return vm, err
	}

	if cachedVM == nil {
		return vm, cloudprovider.InstanceNotFound
	}

	return *(cachedVM.(*compute.VirtualMachine)), nil
}
732381
func (c *VSphereCloud) FindVMUUID(vm *string) (string, error) {
	f := find.NewFinder(c.Client.Client, true)
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	dc, err := f.Datacenter(ctx, c.Datacenter)
	if err != nil {
		return "", err
	}
	f.SetDatacenter(dc)

	vmRef, err := f.VirtualMachine(ctx, *vm)
	if err != nil {
		return "", err
	}

	var vmResult mo.VirtualMachine

	pc := property.DefaultCollector(c.Client.Client)
	err = pc.RetrieveOne(ctx, vmRef.Reference(), []string{"config.uuid"}, &vmResult)
	if err != nil {
		return "", err
	}
	glog.V(4).Infof("vm property collector result :%+v\n", vmResult)
	glog.V(3).Infof("retrieved vm uuid as %q for vm %q", vmResult.Config.Uuid, *vm)
	return vmResult.Config.Uuid, nil
}
1233467
func (dc *Datacenter) GetHostByVMUUID(ctx context.Context, vmUUID string) (*types.ManagedObjectReference, error) {
	virtualMachine, err := dc.GetVMByUUID(ctx, vmUUID)
	if err != nil {
		return nil, err
	}
	var vmMo mo.VirtualMachine
	pc := property.DefaultCollector(virtualMachine.Client())
	err = pc.RetrieveOne(ctx, virtualMachine.Reference(), []string{"summary.runtime.host"}, &vmMo)
	if err != nil {
		klog.Errorf("Failed to retrieve VM runtime host, err: %v", err)
		return nil, err
	}
	host := vmMo.Summary.Runtime.Host
	klog.Infof("%s host is %s", virtualMachine.Reference(), host)
	return host, nil
}
728695
func (vm *VM) getMetadata() *compute.Metadata {
	if len(vm.Attributes.GetMetadata()) == 0 {
		return nil
	}
	meta := &compute.Metadata{
		Items: make([]*compute.MetadataItems, len(vm.Attributes.Metadata)),
	}
	for i, data := range vm.Attributes.Metadata {
		// Implicitly rejects FromFile, which is only supported in configs.
		spl := strings.SplitN(data.GetFromText(), ":", 2)
		// Per strings.SplitN semantics, len(spl) > 0 when splitting on a non-empty separator.
		// Therefore we can be sure the spl[0] exists (even if it's an empty string).
		key := spl[0]
		var val *string
		if len(spl) > 1 {
			val = &spl[1]
		}
		meta.Items[i] = &compute.MetadataItems{
			Key:   key,
			Value: val,
		}
	}
	return meta
}
926918
func (i ImportBinding) GetVirtualAddress(instanceID int) (string, error) {
	t := template.Must(template.New(i.Application).Funcs(funcs).Parse(i.VirtualAddress))

	var buffer bytes.Buffer
	if err := t.Execute(&buffer, struct{ InstanceID int }{instanceID}); err != nil {
		return "", &TemplateError{
			Application: i.Application,
			Field:       i.VirtualAddress,
			Message:     "could not interpret value",
		}
	}

	return buffer.String(), nil
}
319880
func (r Hardware_SecurityModule750) GetVirtualLicenses() (resp []datatypes.Software_VirtualLicense, err error) {
	err = r.Session.DoRequest("SoftLayer_Hardware_SecurityModule750", "getVirtualLicenses", nil, &r.Options, &resp)
	return
}
720688
func GetVM(structPtr interface{}) *ViewModel {
	vm, ok := vMap[structPtr]
	if !ok {
		panic("GetVM: Vue not registerd yet")
	}
	return vm
}
957975
func (_class VBDClass) GetMode(sessionID SessionRef, self VBDRef) (_retval VbdMode, _err error) {
	_method := "VBD.get_mode"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVBDRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertEnumVbdModeToGo(_method + " -> ", _result.Value)
	return
}
67563
func (d *driver) getVolume(
	ctx types.Context,
	volumeID string, volumeName string,
	attachments types.VolumeAttachmentsTypes) ([]*types.Volume, error) {

	if err := d.refreshSession(ctx); err != nil {
		return nil, err
	}

	volumes, err := d.vbox.GetMedium(volumeID, volumeName)
	if err != nil {
		return nil, err
	}

	if len(volumes) == 0 {
		return nil, nil
	}

	var mapDN map[string]string
	if attachments.Devices() {
		volumeMapping, err := d.getVolumeMapping(ctx)
		if err != nil {
			return nil, err
		}

		mapDN = make(map[string]string)
		for _, vm := range volumeMapping {
			mapDN[vm.ID] = vm.Name
		}
	}

	var volumesSD []*types.Volume

	for _, v := range volumes {
		volumeSD := &types.Volume{
			Name:   v.Name,
			ID:     v.ID,
			Size:   int64(v.LogicalSize / 1024 / 1024 / 1024),
			Status: v.Location,
			Type:   string(v.DeviceType),
		}

		if attachments.Requested() {
			var attachmentsSD []*types.VolumeAttachment
			for _, mid := range v.MachineIDs {
				attachmentSD := &types.VolumeAttachment{
					VolumeID: v.ID,
					InstanceID: &types.InstanceID{
						ID:     mid,
						Driver: vbox.Name,
					},
				}
				if attachments.Devices() && mapDN != nil {
					dn, _ := mapDN[v.ID]
					attachmentSD.DeviceName = dn
				}
				attachmentsSD = append(attachmentsSD, attachmentSD)
			}
			volumeSD.Attachments = attachmentsSD
		}

		volumesSD = append(volumesSD, volumeSD)
	}

	return volumesSD, nil
}
1176709
func (ts *Server) GetSrvVSchema(ctx context.Context, cell string) (*vschemapb.SrvVSchema, error) {
	conn, err := ts.ConnForCell(ctx, cell)
	if err != nil {
		return nil, err
	}

	nodePath := SrvVSchemaFile
	data, _, err := conn.Get(ctx, nodePath)
	if err != nil {
		return nil, err
	}
	srvVSchema := &vschemapb.SrvVSchema{}
	if err := proto.Unmarshal(data, srvVSchema); err != nil {
		return nil, vterrors.Wrapf(err, "SrvVSchema unmarshal failed: %v", data)
	}
	return srvVSchema, nil
}
496878
func (client *RenderingControl2) GetVolumeDB(InstanceID uint32, Channel string) (CurrentVolume int16, err error) {
	// Request structure.
	request := &struct {
		InstanceID string
		Channel    string
	}{}
	// BEGIN Marshal arguments into request.

	if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
		return
	}
	if request.Channel, err = soap.MarshalString(Channel); err != nil {
		return
	}
	// END Marshal arguments into request.

	// Response structure.
	response := &struct {
		CurrentVolume string
	}{}

	// Perform the SOAP call.
	if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetVolumeDB", request, response); err != nil {
		return
	}

	// BEGIN Unmarshal arguments from response.

	if CurrentVolume, err = soap.UnmarshalI2(response.CurrentVolume); err != nil {
		return
	}
	// END Unmarshal arguments from response.
	return
}