Author: tomaz
Date: Mon May 14 01:53:41 2012
New Revision: 1338023
URL: http://svn.apache.org/viewvc?rev=1338023&view=rev
Log:
Add vCloud 1.5 example to the docs, contributed by Sengor Kusturica part of
LIBCLOUD-194.
Modified:
libcloud/site/trunk/content/docs/compute-examples.mdtext
Modified: libcloud/site/trunk/content/docs/compute-examples.mdtext
URL:
http://svn.apache.org/viewvc/libcloud/site/trunk/content/docs/compute-examples.mdtext?rev=1338023&r1=1338022&r2=1338023&view=diff
==============================================================================
--- libcloud/site/trunk/content/docs/compute-examples.mdtext (original)
+++ libcloud/site/trunk/content/docs/compute-examples.mdtext Mon May 14
01:53:41 2012
@@ -3,6 +3,7 @@ title: Compute -> Examples
## Examples
* [Create an OpenStack node using trystack.org
provider](#example-1-openstack-node-using-trystack)
+* [Create a VMware vCloud v1.5 node using generic
provider](#example-2-vcloud-generic-provider)
<h3 id="example-1-openstack-node-using-trystack">Create an OpenStack node
using trystack.org provider</h3>
@@ -40,3 +41,61 @@ OpenStack driver.</p>
image = [i for i in images if i.name == 'natty-server-cloudimg-amd64'][0]
node = driver.create_node(name='test node', image=image, size=size)
+
+
+<h3 id="example-2-vcloud-generic-provider">Create a VMware vCloud v1.5 node
using generic provider</h3>
+
+<p>This example demonstrates how to launch a VMware vCloud v1.5 node on a
generic provider such as a test lab.</p>
+
+<p>Note: This example works with Libcloud trunk rev 1333307 and above.</p>
+
+ ::python
+ from libcloud.compute.types import Provider
+ from libcloud.compute.providers import get_driver
+
+ import libcloud.security
+
+ # Skip this step if you are launching nodes on an official vCloud
+ # provider. It is intended only for self signed SSL certs in
+ # vanilla vCloud Director v1.5 test deployments.
+ # Note: Code like this poses a security risk (MITM attack) and
+ # that's the reason why you should never use it for anything else
+ # besides testing. You have been warned.
+ libcloud.security.VERIFY_SSL_CERT = False
+
+ vcloud = get_driver(Provider.VCLOUD)
+
+ driver = vcloud('you username@organisation', 'your password',
+ host='vcloud.local', api_version='1.5')
+
+ # List all instantiated vApps
+ nodes = driver.list_nodes()
+ # List all VMs within the first vApp instance
+ print nodes[0].extra['vms']
+
+ # List all available vApp Templates
+ images = driver.list_images()
+ image = [i for i in images if i.name == 'natty-server-cloudimg-amd64'][0]
+
+ # Create node with minimum set of parameters
+ node = driver.create_node(name='test node 1', image=image)
+ # Destroy the node
+ driver.destroy_node(node)
+
+ # Create node without deploying and powering it on
+ node = driver.create_node(name='test node 2', image=image, ex_deploy=False)
+
+ # Create node with custom CPU & Memory values
+ node = driver.create_node(name='test node 3', image=image, ex_vm_cpu=3,
ex_vm_memory=1024)
+
+ # Create node with customised networking parameters (eg. for OVF imported
images)
+ node = driver.create_node(name='test node 4', image=image,
+ ex_vm_network='your vm net name',
ex_network='your org net name',
+ ex_vm_fence='bridged', ex_vm_ipmode='DHCP')
+
+ # Create node in a custom virtual data center
+ node = driver.create_node(name='test node 4', image=image, ex_vdc='your
vdc name')
+
+ # Create node with guest OS customisation script to be run at first boot
+ node = driver.create_node(name='test node 5', image=image,
+ ex_vm_script='filesystem path to your script')
\ No newline at end of file