You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/08/01 20:30:25 UTC

[13/22] git commit: Really added the examples

Really added the examples

Signed-off-by: Tomaz Muraus <to...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8a868d97
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8a868d97
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8a868d97

Branch: refs/heads/0.13.x
Commit: 8a868d974e53bccdf10070042487561586b44dcf
Parents: 9d4e3ff
Author: Alex Gaynor <al...@gmail.com>
Authored: Wed Jul 31 15:06:33 2013 -0700
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Aug 1 20:28:49 2013 +0200

----------------------------------------------------------------------
 docs/compute/examples.rst | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8a868d97/docs/compute/examples.rst
----------------------------------------------------------------------
diff --git a/docs/compute/examples.rst b/docs/compute/examples.rst
new file mode 100644
index 0000000..1a7e2bd
--- /dev/null
+++ b/docs/compute/examples.rst
@@ -0,0 +1,42 @@
+Compute Examples
+================
+
+Create an OpenStack node using trystack.org provider
+----------------------------------------------------
+
+`trystack.org`_ 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.
+
+.. sourcecode:: 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)
+
+
+.. _`trystack.org`: http://trystack.org/