libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [1/3] git commit: docs: Add examples of how to retrieve balance and use ex_avoid.
Date Thu, 30 Jan 2014 14:19:51 GMT
Updated Branches:
  refs/heads/trunk 37abf99c5 -> feba5a3be


docs: Add examples of how to retrieve balance and use ex_avoid.


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

Branch: refs/heads/trunk
Commit: 626c881a5b3dfe7a3ea35afb32933de13a191c44
Parents: 37abf99
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Thu Jan 30 13:16:36 2014 +0100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Thu Jan 30 13:16:36 2014 +0100

----------------------------------------------------------------------
 docs/compute/drivers/cloudsigma.rst             | 31 ++++++++++++++++++++
 .../compute/cloudsigma/create_node_ex_avoid.py  | 17 +++++++++++
 .../compute/cloudsigma/get_account_balance.py   | 10 +++++++
 3 files changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/626c881a/docs/compute/drivers/cloudsigma.rst
----------------------------------------------------------------------
diff --git a/docs/compute/drivers/cloudsigma.rst b/docs/compute/drivers/cloudsigma.rst
index 8823355..0ea35a2 100644
--- a/docs/compute/drivers/cloudsigma.rst
+++ b/docs/compute/drivers/cloudsigma.rst
@@ -125,6 +125,37 @@ servers tagged with ``database-server``.
 .. literalinclude:: /examples/compute/cloudsigma/attach_firewall_policy.py
    :language: python
 
+7. Starting a server in a different availability group using avoid functionality
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+CloudSigma allows you to specify a list of server UUIDs which to avoid when
+starting a server.
+
+This helps make your infrastructure more highly available and is useful when
+you want to create a server in a different availability zone than the existing
+server.
+
+The example bellow shows how to create a new server in a different availability
+zone from all the existing servers.
+
+Keep in mind that `as noted in the CloudSigma documentation
+<https://zrh.cloudsigma.com/docs/availability_groups.html#general-notes-on-avoid-functionality>`_,
+this functionality uses the best effort mode. This means that the request might
+succeed even if the avoid can not be satisfied and the requested resource ends
+in the same availability group as an avoid resource.
+
+.. literalinclude:: /examples/compute/cloudsigma/create_node_ex_avoid.py
+   :language: python
+
+8. Retrieving the account balance
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This example shows how to retrieve the account balance. The method returns a
+dictionary with two keys - ``balance`` and ``currency``.
+
+.. literalinclude:: /examples/compute/cloudsigma/get_account_balance.py
+   :language: python
+
 API Docs
 --------
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/626c881a/docs/examples/compute/cloudsigma/create_node_ex_avoid.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/cloudsigma/create_node_ex_avoid.py b/docs/examples/compute/cloudsigma/create_node_ex_avoid.py
new file mode 100644
index 0000000..9126d67
--- /dev/null
+++ b/docs/examples/compute/cloudsigma/create_node_ex_avoid.py
@@ -0,0 +1,17 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+
+cls = get_driver(Provider.CLOUDSIGMA)
+driver = cls('username', 'password', region='zrh', api_version='2.0')
+
+name = 'test node avoid mode'
+size = driver.list_sizes()[0]
+image = driver.list_images()[0]
+
+existing_nodes = driver.list_nodes()
+existing_node_uuids = [node.id for node in existing_nodes]
+
+
+node = driver.create_node(name=name, size=size, image=image,
+                          ex_avoid=existing_node_uuids)
+print(node)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/626c881a/docs/examples/compute/cloudsigma/get_account_balance.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/cloudsigma/get_account_balance.py b/docs/examples/compute/cloudsigma/get_account_balance.py
new file mode 100644
index 0000000..29d55e2
--- /dev/null
+++ b/docs/examples/compute/cloudsigma/get_account_balance.py
@@ -0,0 +1,10 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+
+cls = get_driver(Provider.CLOUDSIGMA)
+driver = cls('username', 'password', region='zrh', api_version='2.0')
+
+balance = driver.ex_get_balance()
+
+values = {'balance': balance['balance'], 'currency': balance['currency']}
+print('Account balance: %(balance)s %(currency)s' % values)


Mime
View raw message