Exception When Cloning A Template VM

2,820 views
Skip to first unread message

craig

unread,
Jan 26, 2012, 4:56:20 AM1/26/12
to pysphere
Hi Seba,

I've got the following exception when attempting to clone a Template
VM:

In [47]: vm.clone('cas_new_tmp')
---------------------------------------------------------------------------
VIException Traceback (most recent call
last)
/Users/craastil/<ipython-input-47-a7f6cf31a7d5> in <module>()
----> 1 vm.clone('cas_new_tmp')

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/pysphere-0.1.5-py2.7.egg/pysphere/
vi_virtual_machine.pyc in clone(self, name, sync_run, folder,
resourcepool, power_on)
466 if status == vi_task.STATE_ERROR:
467 raise
VIException(vi_task.get_error_message(),
--> 468 FaultTypes.TASK_ERROR)
469 return VIVirtualMachine(self._server,
vi_task.get_result())
470

VIException: [Task Error]: A specified parameter was not correct.
spec.location.pool

Note: This works fine when cloning a VM that has not been converted to
a Template.

Seba

unread,
Jan 27, 2012, 3:30:56 PM1/27/12
to pysp...@googlegroups.com, craig
Hi Craig,

    This is is the vmware documentation for the spec.location.pool parameter:
"""
The resource pool to which this virtual machine should be attached. For a relocate or clone operation to a virtual machine, if the argument is not supplied, the current resource pool of virtual machine is used. For a clone operation to a template, this argument is ignored. For a clone operation from a template to a virtual machine, this argument is required.
"""
So, if you are cloning from template, you must provide a resource pool:

>> rps = server.get_resource_pools()

pick any mor (the returned dictionary keys in trunk r54)

>> rp = rps.keys()[0]
>> vm.clone('cas_new_tmp', resourcepool=rp)


What I'm hardcoding in this method is the 'template' parameter. So you can not clone (a vm or template) to a template.
I've just changed this (r56), so you can now do this:
>> vm.clone('can_new_tmp', template=True) #defaults to False

Summarizing, when cloning from:
VM to VM: resource pool is optional (if not set uses the same from the original vm)
VM to Template: resource pool is ignored
Template to Template: resource pool is ignored
Template to VM: resource pool is mandatory


Regards,

Sebastian.

2012/1/26 craig

Melvin Moses

unread,
Aug 4, 2016, 8:01:49 AM8/4/16
to pysphere
Hi Seba,

         I have installed VMWare VCenter server and dowload VSphere SDK 6.0. I have tried to create a clone from template using VMClone(java class) provided in SDK. I ended up with an exception

        ERROR
: A specified parameter was not correct: spec.location.pool

java.lang.RuntimeException: A specified parameter was not correct: spec.location
.pool

             By reading this blog I found that I have to set the resource pool for creating the new clone from the template. Since I'm new in this area I can't set the resource pool in clone specification. Can you give me a sample code (java) with VSphere SDK 6.0. Any help would be grateful.

Thanks,
Melvin Moses
Reply all
Reply to author
Forward
0 new messages