Author: tomaz
Date: Sun Mar 25 01:14:43 2012
New Revision: 1304973

URL: http://svn.apache.org/viewvc?rev=1304973&view=rev
Log:
Add an example for creating node on trystack.org.

Added:
    libcloud/site/trunk/content/docs/compute-examples.mdtext

Added: libcloud/site/trunk/content/docs/compute-examples.mdtext
URL: 
http://svn.apache.org/viewvc/libcloud/site/trunk/content/docs/compute-examples.mdtext?rev=1304973&view=auto
==============================================================================
--- libcloud/site/trunk/content/docs/compute-examples.mdtext (added)
+++ libcloud/site/trunk/content/docs/compute-examples.mdtext Sun Mar 25 
01:14:43 2012
@@ -0,0 +1,42 @@
+title: Compute -> Examples
+
+## Examples
+
+* [Create an OpenStack node using trystack.org 
provider](#example-1-openstack-node-using-trystack)
+
+<h3 id="example-1-openstack-node-using-trystack">Create an OpenStack node 
using trystack.org provider</h3>
+
+<p><a href="https://trystack.org/";>trystack.org</a> allows users to try out 
OpenStack for free.
+This example demonstrates how to launch an OpenStack node on the trystack.org 
provider using a generic
+OpenStack driver.</p>
+
+<p>Note: This example works with Libcloud 0.9.0 and above.</p>
+
+    ::python
+    from libcloud.compute.types import Provider
+    from libcloud.compute.providers import get_driver
+
+    import libcloud.security
+
+    # At the time this example was written, https://nova-api.trystack.org:5443
+    # was using a certificate issued by a Certificate Authority (CA)
+    # which is not included in the default Ubuntu certificates bundle 
(ca-certificates).
+    # 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
+
+    OpenStack = get_driver(Provider.OPENSTACK)
+
+    driver = OpenStack('your username', 'your password',
+                       
ex_force_auth_url='https://nova-api.trystack.org:5443/v2.0',
+                       ex_force_auth_version='2.0_password')
+
+    nodes = driver.list_nodes()
+
+    images = driver.list_images()
+    sizes = driver.list_sizes()
+    size = [s for s in sizes if s.ram == 512][0]
+    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)


Reply via email to