0

Background:

In a project, I need use reconfigVM_task to delete all the virtualDisks of one virtualMachine, and then, I need continue to run the second reconfigVM_task which using other configuration file to add multiple virtualDisks to this virtual machine.

Problem:

The firstTask(delete vm's all virtualDisk) works fine, but after that the secondTask(add multiple virtualDisks failed). VCENTER keep showing "Cannot complete operation, becuase the file or folder [xxxdatastore] vmName/virtualDiskName.vmdk is already exists".

I have checked, vcenterURL/folder showing the virtualDisk has been deleted already. If I manually refresh vsphere web client, then redo the add virtualDisk, it works.

Question:

  1. Anyone know how to solve the problem "Add virtualDisks but has error 'Cannot complete operation because xxx.vmdk already exist"?

  2. OR anyone know how to use vijava api to refresh datastore make the delete is able been recognize?

4

3 回答 3

0

通过集中每个动作解决了这个问题。例如,我需要检查当前VM1VM2VM1需要删除 2 个设备并添加 1 个新设备,VM2需要删除 1 个设备然后添加 1 个设备。

在我收集VM1VM2首先删除所有操作之前,然后收集 VM1VM2并将操作添加到 reconfigVM_Task 中VirtualDeviceCOnfigSpec[]。我仔细检查了所有virtualDeviceCOnfigSpec设置是否正确,并且waitForTask在 vmware 论坛上提到了类似问题的其他注释。

VM1 delete-reconfig最后,通过 do then解决这个问题VM2 add-reconfig。然后与VM2相同。这一次,它适用于我的项目。但它失败的真正原因我并不太清楚。

于 2013-12-19T10:43:56.603 回答
0

过去我也遇到过类似的问题,我没有把.waitForTask()函数调用放在最后。

如果你这样做,你不应该得到任何 VMDK 已经存在的错误

于 2013-07-29T16:03:00.963 回答
0

reconfigVM_task顺便说一句,您可以在单个操作中删除所有磁盘并添加新磁盘。只要确保您的VirtualDeviceConfigSpecOperation.remove操作首先在VirtualDeviceConfigSpec[]

于 2013-09-12T04:12:16.803 回答