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,
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.