I am able to add the disks linearly like below:

my $vmSpec = VirtualMachineConfigSpec->new(deviceChange => [$devSpecs[0]]);
$vmView->ReconfigVM(spec => $vmSpec);
my $vmSpec = VirtualMachineConfigSpec->new(deviceChange => [$devSpecs[1]]);
$vmView->ReconfigVM(spec => $vmSpec);
my $vmSpec = VirtualMachineConfigSpec->new(deviceChange => [$devSpecs[2]]);
$vmView->ReconfigVM(spec => $vmSpec);

However, when I attempt to add all the disks at once I get a SOAP fault

my $vmSpec = VirtualMachineConfigSpec->new(deviceChange => \@devSpecs);
$vmView->ReconfigVM(spec => $vmSpec);

The Error:

SOAP Fault:
-----------
Fault string: Cannot complete the operation because the file or folder
/vmfs/volumes/ba5e81fe-201a6c4e/paul-vm1/paul-vm1_0_3.vmdk already exists
Fault detail: FileAlreadyExists

Is there anyone out there wise in the way of VSphere/VMware that knows what is going on?

EDIT : The file definitely does not exist before or after I run the code.

有帮助吗?

解决方案

I found the solution. Apparently you need to give each virtual machine config spec its own key, even if it is negative. For posterity set

$disk->key = UNIQUE NEGATIVE NUMBER

and then set your config spec

$devSpec = VirtualDeviceConfigSpec->new(
      operation     => $devSpec->operation,
      fileOperation => $devSpec->fileOperation,
      device        => $disk,
);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top