我可以像下面一样线性添加磁盘:
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);
但是,当我尝试一次添加所有磁盘时,我收到了SOAP错误
my $vmSpec = VirtualMachineConfigSpec->new(deviceChange => \@devSpecs);
$vmView->ReconfigVM(spec => $vmSpec);
错误:
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
有没有人知道VSphere / VMware的方式知道发生了什么?
编辑:在我运行代码之前或之后,文件肯定不存在。
答案 0 :(得分:1)
我找到了解决方案。显然,您需要为每个虚拟机配置规范提供自己的密钥,即使它是负数。为后代集
$disk->key = UNIQUE NEGATIVE NUMBER
然后设置配置规范
$devSpec = VirtualDeviceConfigSpec->new(
operation => $devSpec->operation,
fileOperation => $devSpec->fileOperation,
device => $disk,
);