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/09/04 12:28:13 UTC

[06/14] git commit: Add returning the public ip address of opsrouce nodes when listing nodes

Add returning the public ip address of opsrouce nodes when listing nodes

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

Branch: refs/heads/0.13.1
Commit: 05b810c5e1772daeb45498b247a3797724a0cf68
Parents: fe47412
Author: Michael <mi...@securitycompass.com>
Authored: Sun Aug 25 16:10:20 2013 -0400
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Sep 4 12:02:45 2013 +0200

----------------------------------------------------------------------
 libcloud/compute/drivers/opsource.py                        | 4 +++-
 ...8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_deployed.xml | 1 +
 libcloud/test/compute/test_opsource.py                      | 9 +++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/05b810c5/libcloud/compute/drivers/opsource.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/opsource.py b/libcloud/compute/drivers/opsource.py
index 8b89ea8..d45ba3c 100644
--- a/libcloud/compute/drivers/opsource.py
+++ b/libcloud/compute/drivers/opsource.py
@@ -578,10 +578,12 @@ class OpsourceNodeDriver(NodeDriver):
             'status': status,
         }
 
+	public_ip = findtext(element, 'publicIpAddress', SERVER_NS)
+
         n = Node(id=findtext(element, 'id', SERVER_NS),
                  name=findtext(element, 'name', SERVER_NS),
                  state=state,
-                 public_ips=[],
+                 public_ips=[public_ip] if public_ip is not None else [],
                  private_ips=findtext(element, 'privateIpAddress', SERVER_NS),
                  driver=self.connection.driver,
                  extra=extra)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/05b810c5/libcloud/test/compute/fixtures/opsource/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_deployed.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/opsource/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_deployed.xml b/libcloud/test/compute/fixtures/opsource/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_deployed.xml
index ae48208..a11d6c2 100644
--- a/libcloud/test/compute/fixtures/opsource/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_deployed.xml
+++ b/libcloud/test/compute/fixtures/opsource/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_deployed.xml
@@ -17,6 +17,7 @@
         <sourceImageId>44ed8b72-ebea-11df-bdc1-001517c46384</sourceImageId>
         <networkId>53b4c05b-341e-4ac3-b688-bdd78e43ca9e</networkId>
         <privateIpAddress>10.162.1.1</privateIpAddress>
+        <publicIpAddress>200.16.132.7</publicIpAddress>
         <machineName>10-162-1-1</machineName>
         <isStarted>true</isStarted>
         <deployedTime>2011-03-02T17:16:09.882Z</deployedTime>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/05b810c5/libcloud/test/compute/test_opsource.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_opsource.py b/libcloud/test/compute/test_opsource.py
index c94dba7..f0518c4 100644
--- a/libcloud/test/compute/test_opsource.py
+++ b/libcloud/test/compute/test_opsource.py
@@ -144,6 +144,15 @@ class OpsourceTests(unittest.TestCase, TestCaseMixin):
         self.assertEqual(nets[0].name, 'test-net1')
         self.assertTrue(isinstance(nets[0].location, NodeLocation))
 
+    def test_node_public_ip(self):
+        nodes = self.driver.list_nodes()
+        for node in nodes:
+            if node.id == "abadbc7e-9e10-46ca-9d4a-194bcc6b6c16":
+                self.assertEqual(node.public_ips[0], '200.16.132.7')
+            else:
+                self.assertEqual(len(node.public_ips), 0)
+
+
 class OpsourceMockHttp(MockHttp):
 
     fixtures = ComputeFileFixtures('opsource')