Clone a new vApp using Python

Clone a new vApp using Python

Since I didn't find a simple Python vCloud API example and there is no Python binding at this time, I wrote an example that instantiates a vApp from a vApp Template in the Catalog.  Please see the attached "Python".

For input parameters it uses an XML document like this:

  <catalog>Master Images</catalog>
  <vAppDesc>example vApp created by vCloud API</vAppDesc>
  <vAppNetwork>calls internal</vAppNetwork>

Ideally, your source vApp Template should be fully configured for network and making identical copies because this simple example powers on the new vApp behind a network fence (that is - natRouted instead of bridged). And this example does not address the numerous options around new network connections or guest customization in each VM.

Hopefully you will find this simple example somewhat helpful.


Tags (3)

where did you find the Python vCloud API ??

There is no Python binding for the vCloud API as this time.  So in this Python example I am using the Python methods directly for accessing a REST API in general and the vCloud REST API in particular.

But Bill, hasn't VMware announced almost 2 years ago the Open-Source Python SDK for vCloud API ?

Yes, but it never materialized, I'm afraid.  I have not heard if/when a Python binding will be available.  You might try asking the question over on the vCloud API community forum.

Just to do a little thread Necromancy:

There is a python library that support vcloud

could some one please help me on the issue below, i am using the vcloud director 5.5

[xxxxxx@localhost newVapp]$ python


Traceback (most recent call last):

  File "", line 37, in <module>

    resp = urllib2.urlopen(base_url + '/login')

  File "/usr/local/lib/python2.7/", line 126, in urlopen

    return, data, timeout)

  File "/usr/local/lib/python2.7/", line 397, in open

    response = meth(req, response)

  File "/usr/local/lib/python2.7/", line 510, in http_response

    'http', request, response, code, msg, hdrs)

  File "/usr/local/lib/python2.7/", line 435, in error

    return self._call_chain(*args)

  File "/usr/local/lib/python2.7/", line 369, in _call_chain

    result = func(*args)

  File "/usr/local/lib/python2.7/", line 518, in http_error_default

    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)

urllib2.HTTPError: HTTP Error 406: Not Acceptable

Version history
Revision #:
1 of 1
Last update:
‎01-03-2011 02:58 PM
Updated by: