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 14:04:32 UTC
[5/6] 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/bd12f37a
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/bd12f37a
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/bd12f37a
Branch: refs/heads/trunk
Commit: bd12f37a96dd8411e576092de0573d34f9b57757
Parents: a940716
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 14:03:15 2013 +0200
----------------------------------------------------------------------
docs/compute/examples.rst | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bd12f37a/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/