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/23 17:37:09 UTC

[1/3] git commit: Add example for OpenStack's floating IPs

Updated Branches:
  refs/heads/trunk b7304a71b -> d26c9a61e


Add example for OpenStack's floating IPs

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/cf3e7bb9
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/cf3e7bb9
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/cf3e7bb9

Branch: refs/heads/trunk
Commit: cf3e7bb92a500cce3c2d522745b56ec68d111eaa
Parents: b7304a7
Author: Ivan Kusalic <iv...@ikusalic.com>
Authored: Fri Aug 23 16:58:11 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Aug 23 17:34:29 2013 +0200

----------------------------------------------------------------------
 docs/compute/examples.rst                       |  8 +++++
 docs/examples/compute/openstack_floating_ips.py | 33 ++++++++++++++++++++
 2 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/cf3e7bb9/docs/compute/examples.rst
----------------------------------------------------------------------
diff --git a/docs/compute/examples.rst b/docs/compute/examples.rst
index 681c041..a9418aa 100644
--- a/docs/compute/examples.rst
+++ b/docs/compute/examples.rst
@@ -111,3 +111,11 @@ Created node also gets added to the provided security groups.
 As noted in the example, you use `extra_args` argument to provide a dictionary that
 contains the keypair and list of securitygroups. Note that the list of securitygroups
 is passed as a string not as a python list.
+
+Create flaoting IP and attach it to a node using a local OpenStack provider
+---------------------------------------------------------------------------
+
+This example demonstrates how to use OpenStack's floating IPs.
+
+.. literalinclude:: /examples/compute/openstack_floating_ips.py
+   :language: python

http://git-wip-us.apache.org/repos/asf/libcloud/blob/cf3e7bb9/docs/examples/compute/openstack_floating_ips.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/openstack_floating_ips.py b/docs/examples/compute/openstack_floating_ips.py
new file mode 100644
index 0000000..620326e
--- /dev/null
+++ b/docs/examples/compute/openstack_floating_ips.py
@@ -0,0 +1,33 @@
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+
+import libcloud.security
+
+# This assumes you don't have SSL set up.
+# 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_auth_username', 'your_auth_password',
+    ex_force_auth_url='http://10.0.4.1:5000/v2.0',
+    ex_force_auth_version='2.0_password', ex_tenant_name='your_tenant')
+
+# get the first pool - public by default
+pool, = driver.ex_list_floating_ip_pools()
+
+# create an ip in the pool
+floating_ip = pool.create_floating_ip()
+
+# get the node, note: change the node id to the some id you have
+node = driver.ex_get_node_details('922a4381-a18c-487f-b816-cc31c9060853')
+
+# attach the ip to the node
+driver.ex_attach_floating_ip_to_node(node, floating_ip)
+
+# remove it from the node
+driver.ex_detach_floating_ip_from_node(node, floating_ip)
+
+# delete the ip
+floating_ip.delete()


[2/3] git commit: Pep8.

Posted by to...@apache.org.
Pep8.


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

Branch: refs/heads/trunk
Commit: 6ab58f2e035db15aa2eb10bd97527499bb42defa
Parents: cf3e7bb
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Aug 23 17:35:14 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Aug 23 17:35:14 2013 +0200

----------------------------------------------------------------------
 docs/examples/compute/openstack_floating_ips.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/6ab58f2e/docs/examples/compute/openstack_floating_ips.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/openstack_floating_ips.py b/docs/examples/compute/openstack_floating_ips.py
index 620326e..d7afe3f 100644
--- a/docs/examples/compute/openstack_floating_ips.py
+++ b/docs/examples/compute/openstack_floating_ips.py
@@ -11,8 +11,9 @@ libcloud.security.VERIFY_SSL_CERT = False
 
 OpenStack = get_driver(Provider.OPENSTACK)
 driver = OpenStack('your_auth_username', 'your_auth_password',
-    ex_force_auth_url='http://10.0.4.1:5000/v2.0',
-    ex_force_auth_version='2.0_password', ex_tenant_name='your_tenant')
+                   ex_force_auth_url='http://10.0.4.1:5000/v2.0',
+                   ex_force_auth_version='2.0_password',
+                   ex_tenant_name='your_tenant')
 
 # get the first pool - public by default
 pool, = driver.ex_list_floating_ip_pools()


[3/3] git commit: Fix the syntax.

Posted by to...@apache.org.
Fix the syntax.


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

Branch: refs/heads/trunk
Commit: d26c9a61e964ae066209a8ab73baedbfb1842d96
Parents: 6ab58f2
Author: Tomaz Muraus <to...@apache.org>
Authored: Fri Aug 23 17:36:45 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Fri Aug 23 17:36:45 2013 +0200

----------------------------------------------------------------------
 docs/examples/compute/openstack_floating_ips.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/d26c9a61/docs/examples/compute/openstack_floating_ips.py
----------------------------------------------------------------------
diff --git a/docs/examples/compute/openstack_floating_ips.py b/docs/examples/compute/openstack_floating_ips.py
index d7afe3f..203e3ea 100644
--- a/docs/examples/compute/openstack_floating_ips.py
+++ b/docs/examples/compute/openstack_floating_ips.py
@@ -16,7 +16,7 @@ driver = OpenStack('your_auth_username', 'your_auth_password',
                    ex_tenant_name='your_tenant')
 
 # get the first pool - public by default
-pool, = driver.ex_list_floating_ip_pools()
+pool = driver.ex_list_floating_ip_pools()[0]
 
 # create an ip in the pool
 floating_ip = pool.create_floating_ip()