// AttachDriveToAddress attaches a new drive to this SCSI controller, on the specified slot
AttachDriveToAddress attaches a new drive to this SCSI controller, on the specified slot
// AttachDriveToAddress attaches a new drive to this SCSI controller on the specified slot
func (s *SCSIController) AttachDriveToAddress(path string, driveType DriveType, address int) (string, error) {
	resData, err := utils.GetResourceAllocSettings(s.mgr.con, string(driveType), ResourceAllocSettingDataClass)
	if err != nil {
		return "", errors.Wrap(err, "getResourceOfType driveType")
	}
	if err := resData.Set("Parent", s.path); err != nil {
		return "", errors.Wrap(err, "set Parent")
	}
	if err := resData.Set("Address", strconv.Itoa(address)); err != nil {
		return "", errors.Wrap(err, "set Parent")
	}
	if err := resData.Set("AddressOnParent", strconv.Itoa(address)); err != nil {
		return "", errors.Wrap(err, "set Parent")
	}
	dataText, err := resData.GetText(1)
	if err != nil {
		return "", errors.Wrap(err, "GetText")
	}
	resCtrl, err := utils.AddResourceSetting(s.mgr.svc, []string{dataText}, s.vmPath)
	if err != nil {
		return "", errors.Wrap(err, "utils.AddResourceSetting")
	}
	drivePath := resCtrl[0]
	var diskType string
	switch driveType {
	case DiskDrive:
		diskType = IDEDiskResSubType
	case DVDDrive:
		diskType = IDEDVDResSubType
	default:
		return "", fmt.Errorf("invalid drive type")
	}
	storageRes, err := utils.GetResourceAllocSettings(s.mgr.con, diskType, StorageAllocSettingDataClass)
	if err != nil {
		return "", errors.Wrap(err, "utils.GetResourceAllocSettings")
	}
	if err := storageRes.Set("Parent", drivePath); err != nil {
		return "", errors.Wrap(err, "Parent")
	}
	if err := storageRes.Set("HostResource", []string{path}); err != nil {
		return "", errors.Wrap(err, "HostResource")
	}
	storageResText, err := storageRes.GetText(1)
	if err != nil {
		return "", errors.Wrap(err, "GetText")
	}
	resCtrl, err = utils.AddResourceSetting(s.mgr.svc, []string{storageResText}, s.vmPath)
	if err != nil {
		return "", errors.Wrap(err, "utils.AddResourceSetting storageRes")
	}
	return resCtrl[0], nil
}
func ( s * SCSIController ) AttachDriveToAddress ( path string , driveType DriveType , address int ) ( string , error ) { resData , err := utils . GetResourceAllocSettings ( s . mgr . con , string ( driveType ) , ResourceAllocSettingDataClass ) if err != nil { return " " , errors . Wrap ( err , " " ) } if err := resData . Set ( " " , s . path ) ; err != nil { return " " , errors . Wrap ( err , " " ) } if err := resData . Set ( " " , strconv . Itoa ( address ) ) ; err != nil { return " " , errors . Wrap ( err , " " ) } if err := resData . Set ( " " , strconv . Itoa ( address ) ) ; err != nil { return " " , errors . Wrap ( err , " " ) } dataText , err := resData . GetText ( 1 ) if err != nil { return " " , errors . Wrap ( err , " " ) } resCtrl , err := utils . AddResourceSetting ( s . mgr . svc , [ ] string { dataText } , s . vmPath ) if err != nil { return " " , errors . Wrap ( err , " " ) } drivePath := resCtrl [ 0 ] var diskType string switch driveType { case DiskDrive : diskType = IDEDiskResSubType case DVDDrive : diskType = IDEDVDResSubType default : return " " , fmt . Errorf ( " " ) } storageRes , err := utils . GetResourceAllocSettings ( s . mgr . con , diskType , StorageAllocSettingDataClass ) if err != nil { return " " , errors . Wrap ( err , " " ) } if err := storageRes . Set ( " " , drivePath ) ; err != nil { return " " , errors . Wrap ( err , " " ) } if err := storageRes . Set ( " " , [ ] string { path } ) ; err != nil { return " " , errors . Wrap ( err , " " ) } storageResText , err := storageRes . GetText ( 1 ) if err != nil { return " " , errors . Wrap ( err , " " ) } resCtrl , err = utils . AddResourceSetting ( s . mgr . svc , [ ] string { storageResText } , s . vmPath ) if err != nil { return " " , errors . Wrap ( err , " " ) } return resCtrl [ 0 ] , nil }
AttachDriveToAddress attaches a new drive to this SCSI controller, on the specified slot
AttachDriveToAddress attaches a new drive to this SCSI controller on the specified slot