Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error change iops limit on clone image disk. #396

Closed
cinemaster opened this issue Dec 7, 2015 · 16 comments
Closed

Return error change iops limit on clone image disk. #396

cinemaster opened this issue Dec 7, 2015 · 16 comments
Assignees

Comments

@cinemaster
Copy link

Hi

I'm trying change iops limit on created virtual machine which is cloned by image.
But it returns Invalid operation for device '0'.
Any idea to solve this problem?

Here is my code;

newVM, err := finder.VirtualMachine(context.TODO(), vm.name)
devices, err := newVM.Device(context.TODO())
for _, device := range devices {
  if disk, ok := device.(*types.VirtualDisk); ok {
    disk.StorageIOAllocation = &types.StorageIOAllocationInfo{
      Limit: vm.iops,
    }

    err = newVM.EditDevice(context.TODO(), disk)
    if err != nil {
      * this err is "Invalid operation for device '0'."
    }
  }
}
@dougm
Copy link
Member

dougm commented Dec 7, 2015

There should be more detail in your hostd.log (see also: 'govc logs' command). Does the vmdk reside on a host local datastore? Are you able to make this change via the GUI client?

@cinemaster
Copy link
Author

Thank you for reply @dougm!

Actually, I'm using this library from terraform provider. I want to deploy from virtual machine template is located external network storage and change its hard disk iops.

Also, there is nothing problem to add another hard disk to deployed(= cloned) virtual machine with iops configuration.

@cinemaster
Copy link
Author

Attach some logs while provisioning vm from terraform.

Here is my code;

newVM, err := finder.VirtualMachine(context.TODO(), vm.name)
devices, err := newVM.Device(context.TODO())

// set iops on first hard disk if its set
log.Printf("[DEBUG] vm.iops : %v", vm.iops)
if vm.iops != 0 {
    for _, device := range devices {
        if disk, ok := device.(*types.VirtualDisk); ok {
            log.Printf("[DEBUG] found disk : %#v", disk)
            log.Printf("[DEBUG] before disk : %v", disk.StorageIOAllocation)
            disk.StorageIOAllocation = &types.StorageIOAllocationInfo{
                Limit: vm.iops,
                Shares: disk.StorageIOAllocation.Shares,
            }
            log.Printf("[DEBUG] after disk : %v", disk.StorageIOAllocation)

            err = newVM.EditDevice(context.TODO(), disk)
            if err != nil {
                log.Printf("[DEBUG] error : %v", err)
            }
        }
    }
}

And then get these logs on each log.Printf.

[DEBUG] vm.iops : -1
[DEBUG] found disk : &types.VirtualDisk{VirtualDevice:types.VirtualDevice{DynamicData:types.DynamicData{}, Key:2000, DeviceInfo:(*types.Description)(0xc20d62eb40), Backing:(*types.VirtualDiskFlatVer2BackingInfo)(0xc209af24e0), Connectable:(*types.VirtualDeviceConnectInfo)(nil), SlotInfo:types.BaseVirtualDeviceBusSlotInfo(nil), ControllerKey:1000, UnitNumber:0}, CapacityInKB:31457280, CapacityInBytes:32212254720, Shares:(*types.SharesInfo)(0xc20d62f7c0), StorageIOAllocation:(*types.StorageIOAllocationInfo)(0xc20d62f9c0), DiskObjectId:"139-2000", VFlashCacheConfigInfo:(*types.VirtualDiskVFlashCacheConfigInfo)(nil), Iofilter:[]string(nil)}
[DEBUG] before disk : &{{} 500 0xc20d62fa60 0}
[DEBUG] after disk : &{{} -1 0xc20d62fa60 0}
[DEBUG] error : Invalid operation for device '0'.

As you can see in this log, we clone vm from template, which has 500 iops. It is our default setting but sometime we want to change this iops to unlimited(-1). Then newVM.EditDevice(context.TODO(), disk) returns such error.

@dougm
Copy link
Member

dougm commented Dec 9, 2015

What about the hostd logs? As I mentioned: There should be more detail in your hostd.log (see also: 'govc logs' command).

@cinemaster
Copy link
Author

govc logs returns such error;

% govc logs
Error: ServerFaultCode: A specified parameter was not correct.
key

but I can find logs by govc logs.download.

2015-12-10T11:07:28.998+09:00 [06348 error 'VmProv' opID=73c10728 opName=create vmName=terraform-test] _configInfo: (vim.vm.ConfigInfo) {
-->    dynamicType = <unset>, 
-->    changeVersion = "2015-12-10T02:07:30.315745Z", 
-->    modified = "1970-01-01T00:00:00Z", 
-->    name = "terraform-test", 
-->    guestFullName = "CentOS 4/5/6/7 (64-bit)", 
-->    version = "vmx-10", 
-->    uuid = "42199cd3-53fc-f4fa-25df-8639efef150f", 
-->    instanceUuid = "5019344e-a6cd-6245-53cd-e02c1bb06979", 
-->    npivWorldWideNameType = <unset>, 
-->    npivDesiredNodeWwns = <unset>, 
-->    npivDesiredPortWwns = <unset>, 
-->    npivTemporaryDisabled = true, 
-->    npivOnNonRdmDisks = <unset>, 
-->    locationId = "", 
-->    template = false, 
-->    guestId = "centos64Guest", 
-->    alternateGuestName = "", 
-->    annotation = "", 
-->    files = (vim.vm.FileInfo) {
-->       dynamicType = <unset>, 
-->       vmPathName = "ds:///vmfs/volumes/56396417-785d9981-1d79-3863bb2f2718/terraform-test/terraform-test.vmx", 
-->       snapshotDirectory = "ds:///vmfs/volumes/56396417-785d9981-1d79-3863bb2f2718/terraform-test/", 
-->       suspendDirectory = "ds:///vmfs/volumes/56396417-785d9981-1d79-3863bb2f2718/terraform-test/", 
-->       logDirectory = "ds:///vmfs/volumes/56396417-785d9981-1d79-3863bb2f2718/terraform-test/", 
-->    }, 
-->    tools = (vim.vm.ToolsConfigInfo) {
-->       dynamicType = <unset>, 
-->       toolsVersion = 9354, 
-->       afterPowerOn = true, 
-->       afterResume = true, 
-->       beforeGuestStandby = true, 
-->       beforeGuestShutdown = true, 
-->       beforeGuestReboot = <unset>, 
-->       toolsUpgradePolicy = "manual", 
-->       pendingCustomization = <unset>, 
-->       syncTimeWithHost = false, 
-->       lastInstallInfo = (vim.vm.ToolsConfigInfo.ToolsLastInstallInfo) {
-->          dynamicType = <unset>, 
-->          counter = 0, 
-->          fault = (vmodl.MethodFault) null, 
-->       }, 
-->    }, 
-->    flags = (vim.vm.FlagInfo) {
-->       dynamicType = <unset>, 
-->       disableAcceleration = false, 
-->       enableLogging = true, 
-->       useToe = false, 
-->       runWithDebugInfo = false, 
-->       monitorType = "release", 
-->       htSharing = "any", 
-->       snapshotDisabled = false, 
-->       snapshotLocked = false, 
-->       diskUuidEnabled = false, 
-->       virtualMmuUsage = "automatic", 
-->       virtualExecUsage = "hvAuto", 
-->       snapshotPowerOffBehavior = "powerOff", 
-->       recordReplayEnabled = false, 
-->    }, 
-->    consolePreferences = (vim.vm.ConsolePreferences) null, 
-->    defaultPowerOps = (vim.vm.DefaultPowerOpInfo) {
-->       dynamicType = <unset>, 
-->       powerOffType = "soft", 
-->       suspendType = "hard", 
-->       resetType = "soft", 
-->       defaultPowerOffType = "soft", 
-->       defaultSuspendType = "hard", 
-->       defaultResetType = "soft", 
-->       standbyAction = "checkpoint", 
-->    }, 
-->    hardware = (vim.vm.VirtualHardware) {
-->       dynamicType = <unset>, 
-->       numCPU = 2, 
-->       numCoresPerSocket = 1, 
-->       memoryMB = 4096, 
-->       virtualICH7MPresent = false, 
-->       virtualSMCPresent = false, 
-->       device = (vim.vm.device.VirtualDevice) [
-->          (vim.vm.device.VirtualIDEController) {
-->             dynamicType = <unset>, 
-->             key = 200, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "IDE 0", 
-->                summary = "IDE 0", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = <unset>, 
-->             unitNumber = <unset>, 
-->             busNumber = 0, 
-->          }, 
-->          (vim.vm.device.VirtualIDEController) {
-->             dynamicType = <unset>, 
-->             key = 201, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "IDE 1", 
-->                summary = "IDE 1", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = <unset>, 
-->             unitNumber = <unset>, 
-->             busNumber = 1, 
-->             device = (int) [
-->                3002
-->             ], 
-->          }, 
-->          (vim.vm.device.VirtualPS2Controller) {
-->             dynamicType = <unset>, 
-->             key = 300, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "PS2 controller 0", 
-->                summary = "PS2 controller 0", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = <unset>, 
-->             unitNumber = <unset>, 
-->             busNumber = 0, 
-->             device = (int) [
-->                600, 
-->                700
-->             ], 
-->          }, 
-->          (vim.vm.device.VirtualPCIController) {
-->             dynamicType = <unset>, 
-->             key = 100, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "PCI controller 0", 
-->                summary = "PCI controller 0", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = <unset>, 
-->             unitNumber = <unset>, 
-->             busNumber = 0, 
-->             device = (int) [
-->                500, 
-->                12000, 
-->                1000
-->             ], 
-->          }, 
-->          (vim.vm.device.VirtualSIOController) {
-->             dynamicType = <unset>, 
-->             key = 400, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "SIO controller 0", 
-->                summary = "SIO controller 0", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = <unset>, 
-->             unitNumber = <unset>, 
-->             busNumber = 0, 
-->          }, 
-->          (vim.vm.device.VirtualKeyboard) {
-->             dynamicType = <unset>, 
-->             key = 600, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "Keyboard ", 
-->                summary = "Keyboard", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = 300, 
-->             unitNumber = 0, 
-->          }, 
-->          (vim.vm.device.VirtualPointingDevice) {
-->             dynamicType = <unset>, 
-->             key = 700, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "Pointing device", 
-->                summary = "Pointing device; Device", 
-->             }, 
-->             backing = (vim.vm.device.VirtualPointingDevice.DeviceBackingInfo) {
-->                dynamicType = <unset>, 
-->                deviceName = "", 
-->                useAutoDetect = false, 
-->                hostPointingDevice = "autodetect", 
-->             }, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = 300, 
-->             unitNumber = 1, 
-->          }, 
-->          (vim.vm.device.VirtualVideoCard) {
-->             dynamicType = <unset>, 
-->             key = 500, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "Video card ", 
-->                summary = "Video card", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = 100, 
-->             unitNumber = 0, 
-->             videoRamSizeInKB = 4096, 
-->             numDisplays = 1, 
-->             useAutoDetect = false, 
-->             enable3DSupport = false, 
-->             enableMPTSupport = <unset>, 
-->             use3dRenderer = "automatic", 
-->          }, 
-->          (vim.vm.device.VirtualVMCIDevice) {
-->             dynamicType = <unset>, 
-->             key = 12000, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "VMCI device", 
-->                summary = "Device on the virtual machine PCI bus that provides support for the virtual machine communication interface", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = 100, 
-->             unitNumber = 17, 
-->             id = -1, 
-->             allowUnrestrictedCommunication = false, 
-->          }, 
-->          (vim.vm.device.ParaVirtualSCSIController) {
-->             dynamicType = <unset>, 
-->             key = 1000, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "SCSI controller 0", 
-->                summary = "VMware paravirtual SCSI", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDevice.BackingInfo) null, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = 100, 
-->             unitNumber = 3, 
-->             busNumber = 0, 
-->             device = (int) [
-->                2000
-->             ], 
-->             hotAddRemove = true, 
-->             sharedBus = "noSharing", 
-->             scsiCtlrUnitNumber = 7, 
-->          }, 
-->          (vim.vm.device.VirtualCdrom) {
-->             dynamicType = <unset>, 
-->             key = 3002, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "CD/DVD drive 1", 
-->                summary = "Remote device CD/DVD drive 1", 
-->             }, 
-->             backing = (vim.vm.device.VirtualCdrom.RemotePassthroughBackingInfo) {
-->                dynamicType = <unset>, 
-->                deviceName = "CD/DVD drive 1", 
-->                useAutoDetect = false, 
-->                exclusive = false, 
-->             }, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) {
-->                dynamicType = <unset>, 
-->                startConnected = false, 
-->                allowGuestControl = true, 
-->                connected = false, 
-->                status = "untried", 
-->             }, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = 201, 
-->             unitNumber = 0, 
-->          }, 
-->          (vim.vm.device.VirtualDisk) {
-->             dynamicType = <unset>, 
-->             key = 2000, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "Hard disk 1", 
-->                summary = "31,457,280 KB", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDisk.FlatVer2BackingInfo) {
-->                dynamicType = <unset>, 
-->                fileName = "ds:///vmfs/volumes/56396417-785d9981-1d79-3863bb2f2718/terraform-test/terraform-test.vmdk", 
-->                datastore = 'vim.Datastore:datastore-32', 
-->                backingObjectId = "21-2000-0", 
-->                diskMode = "persistent", 
-->                split = false, 
-->                writeThrough = false, 
-->                thinProvisioned = false, 
-->                eagerlyScrub = true, 
-->                uuid = "6000C290-9061-4b07-6883-226fdacbc0bf", 
-->                contentId = "48d6c2598eed84c94d9b7ce59c0506e4", 
-->                changeId = <unset>, 
-->                parent = (vim.vm.device.VirtualDisk.FlatVer2BackingInfo) null, 
-->                deltaDiskFormat = <unset>, 
-->                digestEnabled = false, 
-->                deltaGrainSize = <unset>, 
-->             }, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = 1000, 
-->             unitNumber = 0, 
-->             capacityInKB = 31457280, 
-->             capacityInBytes = 32212254720, 
-->             shares = (vim.SharesInfo) {
-->                dynamicType = <unset>, 
-->                shares = 1000, 
-->                level = "normal", 
-->             }, 
-->             storageIOAllocation = (vim.StorageResourceManager.IOAllocationInfo) {
-->                dynamicType = <unset>, 
-->                limit = 500, 
-->                shares = (vim.SharesInfo) {
-->                   dynamicType = <unset>, 
-->                   shares = 1000, 
-->                   level = "normal", 
-->                }, 
-->                reservation = 0, 
-->             }, 
-->             diskObjectId = "21-2000", 
-->             vFlashCacheConfigInfo = (vim.vm.device.VirtualDisk.VFlashCacheConfigInfo) null, 
-->          }
-->       ], 
-->    }, 
-->    cpuAllocation = (vim.ResourceAllocationInfo) {
-->       dynamicType = <unset>, 
-->       reservation = 0, 
-->       expandableReservation = false, 
-->       limit = -1, 
-->       shares = (vim.SharesInfo) {
-->          dynamicType = <unset>, 
-->          shares = 2000, 
-->          level = "normal", 
-->       }, 
-->       overheadLimit = <unset>, 
-->    }, 
-->    memoryAllocation = (vim.ResourceAllocationInfo) {
-->       dynamicType = <unset>, 
-->       reservation = 4096, 
-->       expandableReservation = false, 
-->       limit = -1, 
-->       shares = (vim.SharesInfo) {
-->          dynamicType = <unset>, 
-->          shares = 20480, 
-->          level = "normal", 
-->       }, 
-->       overheadLimit = <unset>, 
-->    }, 
-->    latencySensitivity = (vim.LatencySensitivity) {
-->       dynamicType = <unset>, 
-->       level = "normal", 
-->       sensitivity = <unset>, 
-->    }, 
-->    memoryHotAddEnabled = false, 
-->    cpuHotAddEnabled = false, 
-->    cpuHotRemoveEnabled = false, 
-->    hotPlugMemoryLimit = <unset>, 
-->    hotPlugMemoryIncrementSize = <unset>, 
-->    cpuAffinity = (vim.vm.AffinityInfo) null, 
-->    memoryAffinity = (vim.vm.AffinityInfo) null, 
-->    networkShaper = (vim.vm.NetworkShaperInfo) null, 
-->    extraConfig = (vim.option.OptionValue) [
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "sched.cpu.latencySensitivity", 
-->          value = "normal", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "tools.guest.desktop.autolock", 
-->          value = "false", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "nvram", 
-->          value = "terraform-test.nvram", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge0.present", 
-->          value = "TRUE", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "svga.present", 
-->          value = "TRUE", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge4.present", 
-->          value = "TRUE", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge4.virtualDev", 
-->          value = "pcieRootPort", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge4.functions", 
-->          value = "8", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge5.present", 
-->          value = "TRUE", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge5.virtualDev", 
-->          value = "pcieRootPort", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge5.functions", 
-->          value = "8", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge6.present", 
-->          value = "TRUE", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge6.virtualDev", 
-->          value = "pcieRootPort", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge6.functions", 
-->          value = "8", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge7.present", 
-->          value = "TRUE", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge7.virtualDev", 
-->          value = "pcieRootPort", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "pciBridge7.functions", 
-->          value = "8", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "hpet0.present", 
-->          value = "true", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "virtualHW.productCompatibility", 
-->          value = "hosted", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "sched.scsi0:0.throughputCap", 
-->          value = "500", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "vmci.filter.enable", 
-->          value = "true", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "vmware.tools.internalversion", 
-->          value = "9354", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "vmware.tools.requiredversion", 
-->          value = "9359", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "migrate.hostLogState", 
-->          value = "none", 
-->       }, 
-->       (vim.option.OptionValue) {
-->          dynamicType = <unset>, 
-->          key = "migrate.migrationId", 
-->          value = "0", 
-->       }
-->    ], 
-->    swapPlacement = "inherit", 
-->    swapDirectory = <unset>, 
-->    preserveSwapOnPowerOff = <unset>, 
-->    bootOptions = (vim.vm.BootOptions) {
-->       dynamicType = <unset>, 
-->       bootDelay = 0, 
-->       enterBIOSSetup = false, 
-->       bootRetryEnabled = false, 
-->       bootRetryDelay = 10000, 
-->    }, 
-->    ftInfo = (vim.vm.FaultToleranceConfigInfo) null, 
-->    vAppConfig = (vim.vApp.VmConfigInfo) null, 
-->    vAssertsEnabled = false, 
-->    changeTrackingEnabled = false, 
-->    firmware = "bios", 
-->    maxMksConnections = 40, 
-->    guestAutoLockEnabled = false, 
-->    managedBy = (vim.ext.ManagedByInfo) null, 
-->    memoryReservationLockedToMax = false, 
-->    initialOverhead = (vim.vm.ConfigInfo.OverheadInfo) {
-->       dynamicType = <unset>, 
-->       initialMemoryReservation = 182976512, 
-->       initialSwapReservation = 265089024, 
-->    }, 
-->    nestedHVEnabled = false, 
-->    vPMCEnabled = false, 
-->    scheduledHardwareUpgradeInfo = (vim.vm.ScheduledHardwareUpgradeInfo) {
-->       dynamicType = <unset>, 
-->       upgradePolicy = "never", 
-->       versionKey = <unset>, 
-->       scheduledHardwareUpgradeStatus = "none", 
-->       fault = (vmodl.MethodFault) null, 
-->    }, 
-->    vFlashCacheReservation = 0, 
--> }

2015-12-10T11:07:28.999+09:00 [06348 error 'VmProv' opID=73c10728 opName=create vmName=terraform-test] _configSpec: (vim.vm.ConfigSpec) {
-->    dynamicType = <unset>, 
-->    changeVersion = <unset>, 
-->    name = <unset>, 
-->    version = <unset>, 
-->    uuid = <unset>, 
-->    instanceUuid = <unset>, 
-->    npivWorldWideNameType = <unset>, 
-->    npivDesiredNodeWwns = <unset>, 
-->    npivDesiredPortWwns = <unset>, 
-->    npivTemporaryDisabled = <unset>, 
-->    npivOnNonRdmDisks = <unset>, 
-->    npivWorldWideNameOp = <unset>, 
-->    locationId = <unset>, 
-->    guestId = <unset>, 
-->    alternateGuestName = <unset>, 
-->    annotation = <unset>, 
-->    files = (vim.vm.FileInfo) {
-->       dynamicType = <unset>, 
-->       vmPathName = "ds:///vmfs/volumes/56396417-785d9981-1d79-3863bb2f2718/terraform-test/terraform-test.vmx", 
-->       snapshotDirectory = <unset>, 
-->       suspendDirectory = <unset>, 
-->       logDirectory = <unset>, 
-->    }, 
-->    tools = (vim.vm.ToolsConfigInfo) null, 
-->    flags = (vim.vm.FlagInfo) null, 
-->    consolePreferences = (vim.vm.ConsolePreferences) null, 
-->    powerOpInfo = (vim.vm.DefaultPowerOpInfo) null, 
-->    numCPUs = <unset>, 
-->    numCoresPerSocket = <unset>, 
-->    memoryMB = <unset>, 
-->    memoryHotAddEnabled = <unset>, 
-->    cpuHotAddEnabled = <unset>, 
-->    cpuHotRemoveEnabled = <unset>, 
-->    virtualICH7MPresent = <unset>, 
-->    virtualSMCPresent = <unset>, 
-->    deviceChange = (vim.vm.device.VirtualDeviceSpec) [
-->       (vim.vm.device.VirtualDeviceSpec) {
-->          dynamicType = <unset>, 
-->          operation = "edit", 
-->          fileOperation = "replace", 
-->          device = (vim.vm.device.VirtualDisk) {
-->             dynamicType = <unset>, 
-->             key = 2000, 
-->             deviceInfo = (vim.Description) {
-->                dynamicType = <unset>, 
-->                label = "Hard disk 1", 
-->                summary = "31,457,280 KB", 
-->             }, 
-->             backing = (vim.vm.device.VirtualDisk.FlatVer2BackingInfo) {
-->                dynamicType = <unset>, 
-->                fileName = "ds:///vmfs/volumes/56396417-785d9981-1d79-3863bb2f2718/terraform-test/terraform-test.vmdk", 
-->                datastore = 'vim.Datastore:datastore-32', 
-->                backingObjectId = "21-2000-0", 
-->                diskMode = "persistent", 
-->                split = false, 
-->                writeThrough = false, 
-->                thinProvisioned = false, 
-->                eagerlyScrub = true, 
-->                uuid = "6000C290-9061-4b07-6883-226fdacbc0bf", 
-->                contentId = "48d6c2598eed84c94d9b7ce59c0506e4", 
-->                changeId = <unset>, 
-->                parent = (vim.vm.device.VirtualDisk.FlatVer2BackingInfo) null, 
-->                deltaDiskFormat = <unset>, 
-->                digestEnabled = false, 
-->                deltaGrainSize = <unset>, 
-->             }, 
-->             connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null, 
-->             slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null, 
-->             controllerKey = 1000, 
-->             unitNumber = <unset>, 
-->             capacityInKB = 31457280, 
-->             capacityInBytes = 32212254720, 
-->             shares = (vim.SharesInfo) {
-->                dynamicType = <unset>, 
-->                shares = 1000, 
-->                level = "normal", 
-->             }, 
-->             storageIOAllocation = (vim.StorageResourceManager.IOAllocationInfo) {
-->                dynamicType = <unset>, 
-->                limit = -1, 
-->                shares = (vim.SharesInfo) {
-->                   dynamicType = <unset>, 
-->                   shares = 1000, 
-->                   level = "normal", 
-->                }, 
-->                reservation = <unset>, 
-->             }, 
-->             diskObjectId = "21-2000", 
-->             vFlashCacheConfigInfo = (vim.vm.device.VirtualDisk.VFlashCacheConfigInfo) null, 
-->          }, 
-->       }
-->    ], 
-->    cpuAllocation = (vim.ResourceAllocationInfo) null, 
-->    memoryAllocation = (vim.ResourceAllocationInfo) null, 
-->    latencySensitivity = (vim.LatencySensitivity) null, 
-->    cpuAffinity = (vim.vm.AffinityInfo) null, 
-->    memoryAffinity = (vim.vm.AffinityInfo) null, 
-->    networkShaper = (vim.vm.NetworkShaperInfo) null, 
-->    swapPlacement = <unset>, 
-->    swapDirectory = <unset>, 
-->    preserveSwapOnPowerOff = <unset>, 
-->    bootOptions = (vim.vm.BootOptions) null, 
-->    vAppConfig = (vim.vApp.VmConfigSpec) null, 
-->    ftInfo = (vim.vm.FaultToleranceConfigInfo) null, 
-->    vAppConfigRemoved = <unset>, 
-->    vAssertsEnabled = <unset>, 
-->    changeTrackingEnabled = <unset>, 
-->    firmware = <unset>, 
-->    maxMksConnections = <unset>, 
-->    guestAutoLockEnabled = <unset>, 
-->    managedBy = (vim.ext.ManagedByInfo) null, 
-->    memoryReservationLockedToMax = <unset>, 
-->    nestedHVEnabled = <unset>, 
-->    vPMCEnabled = <unset>, 
-->    scheduledHardwareUpgradeInfo = (vim.vm.ScheduledHardwareUpgradeInfo) null, 
--> }

2015-12-10T11:07:29.001+09:00 [06348 warning 'Default' opID=73c10728] [JrnlFilePersistenceProvider] Got EOF while reading file

2015-12-10T11:07:29.006+09:00 [06348 info 'vmprovvpxdVmprovXaction' opID=73c10728] [VpxdVmprovXaction] Starting journal rollback

2015-12-10T11:07:29.006+09:00 [06348 info 'vmprovvpxdVmprovXaction' opID=73c10728] [VpxdVmprovXaction] Vm provision transaction rollback done

2015-12-10T11:07:29.006+09:00 [06348 error 'vmprovvpxdVmprov' opID=73c10728] [VpxdVmprov::Reconfigure] Unexpected exception during reconfig

2015-12-10T11:07:29.006+09:00 [06348 info 'commonvpxLro' opID=73c10728] [VpxLRO] -- FINISH task-471 -- vm-95 -- vim.VirtualMachine.reconfigure -- 

2015-12-10T11:07:29.006+09:00 [06348 info 'Default' opID=73c10728] [VpxLRO] -- ERROR task-471 -- vm-95 -- vim.VirtualMachine.reconfigure: vim.fault.InvalidDeviceOperation:
--> Result:
--> (vim.fault.InvalidDeviceOperation) {
-->    dynamicType = <unset>, 
-->    faultCause = (vmodl.MethodFault) null, 
-->    property = "virtualDevice.backing", 
-->    deviceIndex = 0, 
-->    badOp = <unset>, 
-->    badFileOp = "replace", 
-->    msg = "Invalid operation for device '0'.", 
--> }
--> Args:
--> 

@eloycoto
Copy link
Contributor

Hey @cinemaster @dougm

Did you found the fix for this issue? I'm trying to do the same with disk size and iop and I'm having the same issue. Any idea?

Regards

@cinemaster
Copy link
Author

Hi @eloycoto, I'm still facing this issue....

@eloycoto
Copy link
Contributor

hey @dougm

Any hint on this?

Regards

@dougm
Copy link
Member

dougm commented Jan 20, 2016

Not yet, I'll try to have a look in the next day or two.

@dougm dougm self-assigned this Jan 20, 2016
@eloycoto
Copy link
Contributor

Hey @dougm

About this, I'm trying to expand disk and make it bigger, I'm doing the following. Disk got resized but I'm getting error device 0.

This is my code:

spec := new(configSpec)
size := int64(180 * 1024 * 1024)
sizeBytes := size * 1024


for _, device := range devices {
    if disk, ok := device.(*types.VirtualDisk); ok {
        backing := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
        data := backing.GetVirtualDeviceFileBackingInfo()

        diskAddOp := &types.VirtualDeviceConfigSpec{
            Operation: types.VirtualDeviceConfigSpecOperationEdit,
            Device: &types.VirtualDisk{
                VirtualDevice: types.VirtualDevice{
                    Backing:       data,
                    ControllerKey: disk.ControllerKey,
                    UnitNumber:    disk.UnitNumber,
                    Key:           disk.Key,
                },
                CapacityInKB:    size,
                CapacityInBytes: sizeBytes,
            },
        }
        spec.AddChange(diskAddOp)
    }
}

task, err := newVM.Reconfigure(context.TODO(), spec.ToSpec())
if err != nil {
    fmt.Printf("ERROOR %s", err)
}

err = task.Wait(context.TODO())
fmt.Printf("TASK ERROR '%+v'", err)

Thanks

@eloycoto
Copy link
Contributor

Hey @dougm,

Any update on this? I tried today, but I can't find the problem :S

Regards

@dougm
Copy link
Member

dougm commented Jan 26, 2016

@eloycoto expanding a disk, likely a separate issue. I haven't had a chance to look at either yet.

@dougm dougm added this to the 0.4.0 milestone Jan 26, 2016
@dougm dougm removed this from the 0.4.0 milestone Mar 28, 2016
@cinemaster
Copy link
Author

Hi @dougm ,
I'm still working on this issue but output error has changed from Invalid operation for device '0' to Invalid configuration for device '0'.

  • device config spec create by
newVM, err := finder.VirtualMachine(context.TODO(), vm.name)
devices, err := newVM.Device(context.TODO())

// select disk
devices = devices.SelectByType((*types.VirtualDisk)(nil))

// create device config spec
var res []types.BaseVirtualDeviceConfigSpec
for _, device := range devices {
    disk := device.(*types.VirtualDisk)
    disk.StorageIOAllocation.Limit = -1
    config := &types.VirtualDeviceConfigSpec{
        Device:    device,
        Operation: types.VirtualDeviceConfigSpecOperationEdit,
    }
    res = append(res, config)
    cnt++
}
  • create vm config spec and reconfigure vm
// config spec
configSpec := types.VirtualMachineConfigSpec{
    DeviceChange: res,
}

task, err := newVM.Reconfigure(context.TODO(), configSpec)
return task.Wait(context.TODO())

but still catch error (from host log)

[05840 info 'Default' opID=6289557a] [VpxLRO] -- ERROR task-1650 -- vm-248 -- vim.VirtualMachine.reconfigure: vim.fault.InvalidDeviceSpec:
--> Result:
--> (vim.fault.InvalidDeviceSpec) {
-->    dynamicType = <unset>, 
-->    faultCause = (vmodl.MethodFault) null, 
-->    property = "unitNumber", 
-->    deviceIndex = 0, 
-->    msg = "Invalid configuration for device '0'.", 
--> }
--> Args:
-->

And also I compare with vSphere client (from GUI) case.
Host log in this case as following;

[05676 info 'vmcheckclusterChecker'] [CheckChangePropertiesInt] Property Modified config.hardware.device[2000].storageIOAllocation.limit
[05676 info 'vpxdoverheadMemory'] [OverheadCache::Invalidate] VM vim.VirtualMachine:vm-243: config changed, invalidating cache...
[05676 info 'vpxdvpxdInvtHostDb'] [VpxdInvtHost::SaveFieldsToDb] IPMI info of host test-host is not set
[05676 info 'vpxdvpxdInvtHostCnx'] [VpxdHostSync] Completed host synchronization for host-28
[05676 info 'commonvpxLro'] [VpxLRO] -- FINISH task-internal-421444 -- host-28 -- VpxdInvtHostSyncHostLRO.Synchronize -- 
[06640 info 'pbmvpxd' opID=60d3fd66] PBMCallback: PbmCallBack::CreateAssociationOps: Given NULL/zero-length list of profile specs
[06640 info 'pbmvpxd' opID=60d3fd66] PBMCallback: PbmCallBack::GetDeviceKeyForVM: origControllerKey=1000 and origUnitNumber=0
[06640 info 'pbmvpxd' opID=60d3fd66] PBMCallback: PbmCallBack::GetDeviceKeyForVM: new device Key 2000
[06640 info 'pbmvpxd' opID=60d3fd66] PBMCallback: PbmCallBack::CreateAssociationOps: Given NULL/zero-length list of profile specs
[06640 info 'commonvpxLro' opID=60d3fd66] [VpxLRO] -- FINISH task-1643 -- vm-243 -- vim.VirtualMachine.reconfigure -- 

It seem the hardware property, config.hardware.device[2000].storageIOAllocation.limit, is directly modified, validated and reconfigured.
So, is there any operation to edit VM storage w/o Config Spec?
Or, I want to know the BaseVirtualDeviceConfigSpec property above vSphere (GUI) operation case.

@dougm
Copy link
Member

dougm commented Apr 5, 2016

Looks like this might be fixed by e077bcf - without that change, Go's omitempty json tag would cause the UnitNumber with value 0 to not be sent over the wire.

@cinemaster
Copy link
Author

Hi @dougm,

Thank you for reply!
It works fine with above patch to virtual_device_list.go!

Thank you very match!

@dougm
Copy link
Member

dougm commented Apr 6, 2016

Great news @cinemaster 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants