vmware / pyvmomi-community-samples

A place for community contributed samples for the pyVmomi library.
Apache License 2.0
1.02k stars 925 forks source link

how to create a linked clone vm out of a template? #555

Open plrnr opened 5 years ago

plrnr commented 5 years ago

According to this: https://github.com/vmware/pyvmomi/issues/362 you have to have a snapshot which is not possible on a template.

So, is it even possible to do a linked clone out of a template? If not, is there another method to create a VM fastly from template?

prziborowski commented 5 years ago

You would have to take a snapshot while it is still a VM, then mark it as a template and then link clone from that. Note that some versions of vSphere don't handle this properly, so try it on a test vm before hooking that up to your main automation.

arizvisa commented 4 years ago

The govc client from the govmomi project lets you create a clone with the following.

$ govc ls -json /mydc/vm/user/template/eval-win81x86-enterprise | jq .elements[].Object.Config | grep -i Template
  "Template": true,
$ govc vm.clone -ds=mydc -vm=user/template/eval-win81x86-enterprise -link=true removethis
[05-08-20 17:24:22] Cloning /mydc/vm/user/template/eval-win81x86-enterprise to removethis...(42%)^C
$

So it's definitely possible...