I have been playing with the vmcreate.pl script, but it seems to only allow me to create a VM with a disk that is created during the process.
If I have an existing vmdk file and want to create a new VM using the existing disk, is there a way to do that?
Thanks,
Dave
Hi Dave,
You can indeed create a new VM with an existing vmdk file. This can be done by setting the "deviceChange" property of the VirtualMachineConfigSpec. Below is the code snippet to illustrate the same. While creating the disk backing info, you can provide the path to VMDK file and assign it to the "fileName" property.
my $disk_backing_info =
VirtualDiskFlatVer2BackingInfo->new(diskMode => 'persistent',
fileName => $vmdk_path);
my $disk = VirtualDisk->new(backing => $disk_backing_info,
controllerKey => 0,
key => 0,
unitNumber => 0,
capacityInKB => $disksize);
my $disk_vm_dev_conf_spec =
VirtualDeviceConfigSpec->new(device => $disk);
Hope the above information resolves your query.
Regards,
Neha
Hi Dave,
You can indeed create a new VM with an existing vmdk file. This can be done by setting the "deviceChange" property of the VirtualMachineConfigSpec. Below is the code snippet to illustrate the same. While creating the disk backing info, you can provide the path to VMDK file and assign it to the "fileName" property.
my $disk_backing_info =
VirtualDiskFlatVer2BackingInfo->new(diskMode => 'persistent',
fileName => $vmdk_path);
my $disk = VirtualDisk->new(backing => $disk_backing_info,
controllerKey => 0,
key => 0,
unitNumber => 0,
capacityInKB => $disksize);
my $disk_vm_dev_conf_spec =
VirtualDeviceConfigSpec->new(device => $disk);
Hope the above information resolves your query.
Regards,
Neha
So,
Let me get this straight. In the vmcreate.pl script where it does:
my $disk_vm_dev_cnf_scpe = create_virtual_disk(ds_path => $ds_path, disksize => $args);
I can instead set it as you show and then when the VirtualmachineConfigSpec->new(----
) is called it will use the existing disk specified.
I think I understand, thanks for your help.
Dave