2

I’m new to python and pyvmomi I have task to deploy a VM machine from a template, I looked at examples under github but couldn’t find a script that do that,

https://github.com/vmware/pyvmomi
https://github.com/vmware/pyvmomi-community-samples

Can someone share example or reference to a guide ?

user9051377
  • 21
  • 1
  • 2

1 Answers1

1

The link you provided to the community samples has the sample you are looking for. You need to look at the clone_vm.py file. There is an argument in there to allow you to set the template you are cloning from.

Michael Rice
  • 7,974
  • 1
  • 15
  • 18
  • Thanks but doesn’t this script clone a template ( create identical template ) rather than deploy a VM from a template ? Also looking at line 219 task = template.Clone(folder=destfolder, name=vm_name, spec=clonespec) I couldn’t find info about .Clone ( method ? ) in documentation. – user9051377 Dec 05 '17 at 13:50
  • It should deploy a VM from template. As part of the clonespec, there's a property for 'template'. If you wanted a template as the end result of the clone, that template property would have to be set to true. https://code.vmware.com/apis/196/vsphere#/doc/vim.vm.CloneSpec.html – Kyle Ruddy Dec 05 '17 at 15:16
  • Yes I see, I must admit I’m still confused about commands I see in examples as I can’t find them in documentation. I already checked vSphere API reference but for example can’t find .Clone which I mentioned before. are there docs specific for pyVmomi ? I simply don’t know where to start. – user9051377 Dec 06 '17 at 14:22