I did a dump like you said and it was very helpful. I needed to add the code below to make it work
Turns out that I need a unique key for every disk that I am adding. Thank you for your help
my $disk = VirtualDisk->new(
controllerKey => $devSpec->device->controllerKey,
unitNumber => $devSpec->device->unitNumber,
key => -1 *($i + 1),
backing => $devSpec->device->backing,
capacityInKB => $devSpec->device->capacityInKB,
);
$devSpec = VirtualDeviceConfigSpec->new(
operation => $devSpec->operation,
fileOperation => $devSpec->fileOperation,
device => $disk,
);
Is there a better way to do it than this