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

ReconfigVM_Task disk edit #13

Closed
s0j0hn opened this issue Jul 6, 2018 · 4 comments
Closed

ReconfigVM_Task disk edit #13

s0j0hn opened this issue Jul 6, 2018 · 4 comments

Comments

@s0j0hn
Copy link

s0j0hn commented Jul 6, 2018

Hello,

Apparently i am doing something wrong with the reconfigvm task but i can't figure out what the prblem in there.

          'ReconfigVM_Task',
          {
            _this: util.moRef('VirtualMachine', virtualMachine.moref),
            spec: {
              deviceChange: {
                device: {
                  key: disk.key,
                  capacityInKB: disk.capacityInKB,
                  backing: {
                    fileName: disk.backing.fileName,
                    diskMode: disk.backing.diskMode,
                  },
                },
                operation: 'edit',
              },
            },
          },```
{ errorCode: 400,
  message: 'Required property key is missing from data object of type VirtualDevice\n\nwhile parsing serialized DataObject of type vim.vm.device.VirtualDevice\nat line 1, column 388\n\nwhile parsing property "device" of static type VirtualDevice\n\nwhile parsing serialized DataObject of type vim.vm.device.VirtualDeviceSpec\nat line 1, column 347\n\nwhile parsing property "deviceChange" of static type ArrayOfVirtualDeviceConfigSpec\n\nwhile parsing serialized DataObject of type vim.vm.ConfigSpec\nat line 1, column 341\n\nwhile parsing call information for method ReconfigVM_Task\nat line 1, column 281\n\nwhile parsing SOAP body\nat line 1, column 270\n\nwhile parsing SOAP envelope\nat line 1, column 38\n\nwhile parsing HTTP request for method reconfigure\non object of type vim.VirtualMachine\nat line 1, column 0' }
@bhoriuchi
Copy link
Owner

What version of vsphere-connect are you using?

You probably need to define a device type. See this issue #12

@s0j0hn
Copy link
Author

s0j0hn commented Jul 9, 2018

I am using v1 of vsphere-connect. Btw this works:

'ReconfigVM_Task',
            {
              _this: util.moRef('VirtualMachine', virtualMachine.moref),
              spec: {
                deviceChange: {
                  device: {
                    key: dbVirtualDisk.key,
                  },
                  operation: 'remove',
                },
              },
            },```

@s0j0hn
Copy link
Author

s0j0hn commented Jul 10, 2018

If anyone could tell me how such request should look like from object point of view. That's would be great. TRying to do all actions on vm to add/edit/remove a disk

@jfraudeau
Copy link

jfraudeau commented Jul 10, 2018

After some investigation this seems to work

client.method('ReconfigVM_Task',
      {
        _this: moref,
        spec: {
          deviceChange: [{
            device: {
              attributes: { 'xsi:type': 'VirtualDisk' },
              key: device.key,
              capacityInKB: newCapacity,
              unitNumber: device.unitNumber,
              controllerKey: device.controllerKey,
              backing: {
                attributes: { 'xsi:type': 'VirtualDiskFlatVer2BackingInfo' },
                fileName: device.backing.fileName,
                diskMode: device.backing.diskMode,
              },
            },
            operation: 'edit',
          }],
        },
      })

where device is the retrieved disk device.

What remains unsolved is how to automatically retrieve the xsi:type for the original device and its backing since they aren't conveyed in the js representation of the original soap response.

@s0j0hn s0j0hn closed this as completed May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants