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 newVapp.zip".
For input parameters it uses an XML document like this:
<config>
<server>vcd.vmware.com</server>
<organization>calls</organization>
<user>calladmin</user>
<password>vmware</password>
<orgvdc>CallsOrgVDC1</orgvdc>
<catalog>Master Images</catalog>
<vAppTemplate>apitest</vAppTemplate>
<vAppName>api_vApp</vAppName>
<vAppDesc>example vApp created by vCloud API</vAppDesc>
<vAppNetwork>calls internal</vAppNetwork>
</config>
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.
Bill
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 newVApp.py
base_url:https://10.10.51.8/api/v1.0
Traceback (most recent call last):
File "newVApp.py", line 37, in <module>
resp = urllib2.urlopen(base_url + '/login')
File "/usr/local/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/local/lib/python2.7/urllib2.py", line 397, in open
response = meth(req, response)
File "/usr/local/lib/python2.7/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python2.7/urllib2.py", line 435, in error
return self._call_chain(*args)
File "/usr/local/lib/python2.7/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.7/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 406: Not Acceptable