0

我可以线性添加磁盘,如下所示:

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

有没有人知道发生了什么?

编辑:在我运行代码之前或之后,该文件肯定不存在。

4

1 回答 1

1

我找到了解决方案。显然,您需要为每个虚拟机配置规范提供自己的密钥,即使它是否定的。为子孙集

$disk->key = UNIQUE NEGATIVE NUMBER

然后设置你的配置规范

$devSpec = VirtualDeviceConfigSpec->new(
      operation     => $devSpec->operation,
      fileOperation => $devSpec->fileOperation,
      device        => $disk,
);
于 2013-06-13T20:47:56.993 回答