Updated Branches: refs/heads/trunk 93db5c094 -> 01e12d3e5
Put example in a file. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/2648b37c Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/2648b37c Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/2648b37c Branch: refs/heads/trunk Commit: 2648b37c1455c94625d3422de35892d5b3dfb9f6 Parents: 93db5c0 Author: Tomaz Muraus <[email protected]> Authored: Sat Aug 3 14:27:29 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Sat Aug 3 14:27:29 2013 +0200 ---------------------------------------------------------------------- docs/compute/examples.rst | 32 ++------------------------------ docs/examples/compute/trystack.py | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/2648b37c/docs/compute/examples.rst ---------------------------------------------------------------------- diff --git a/docs/compute/examples.rst b/docs/compute/examples.rst index 1a7e2bd..22b1724 100644 --- a/docs/compute/examples.rst +++ b/docs/compute/examples.rst @@ -8,35 +8,7 @@ Create an OpenStack node using trystack.org provider 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) - +.. literalinclude:: /examples/compute/trystack.py + :language: python .. _`trystack.org`: http://trystack.org/ http://git-wip-us.apache.org/repos/asf/libcloud/blob/2648b37c/docs/examples/compute/trystack.py ---------------------------------------------------------------------- diff --git a/docs/examples/compute/trystack.py b/docs/examples/compute/trystack.py new file mode 100644 index 0000000..6ba3950 --- /dev/null +++ b/docs/examples/compute/trystack.py @@ -0,0 +1,27 @@ +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)
