libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From all...@apache.org
Subject [1/2] libcloud git commit: [LIBCLOUD-879] Add support of node without public IP in LB
Date Fri, 23 Dec 2016 14:25:22 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 64e52938b -> 4c67398d3


[LIBCLOUD-879] Add support of node without public IP in LB

closes #879

Signed-off-by: Allard Hoeve <allardhoeve@gmail.com>


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

Branch: refs/heads/trunk
Commit: 1666a8da34068db0557cc9b186736f571e73df58
Parents: 64e5293
Author: Charles Walker <charles.walker.37@gmail.com>
Authored: Wed Nov 23 01:34:05 2016 +0000
Committer: Allard Hoeve <allardhoeve@gmail.com>
Committed: Fri Dec 23 15:14:48 2016 +0100

----------------------------------------------------------------------
 libcloud/loadbalancer/drivers/gce.py            |  5 +-
 ...al1-b_instances_libcloud-lb-nopubip-001.json | 49 ++++++++++++++++++++
 libcloud/test/compute/test_gce.py               |  6 +++
 libcloud/test/loadbalancer/test_gce.py          |  7 +++
 4 files changed, 66 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1666a8da/libcloud/loadbalancer/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/loadbalancer/drivers/gce.py b/libcloud/loadbalancer/drivers/gce.py
index c754221..df95b1a 100644
--- a/libcloud/loadbalancer/drivers/gce.py
+++ b/libcloud/loadbalancer/drivers/gce.py
@@ -338,9 +338,12 @@ class GCELBDriver(Driver):
         # would be found if it was there.
         if hasattr(node, 'name'):
             member_id = node.name
-            member_ip = node.public_ips[0]
         else:
             member_id = node
+
+        if hasattr(node, 'public_ips') and len(node.public_ips) > 0:
+            member_ip = node.public_ips[0]
+        else:
             member_ip = None
 
         extra = {'node': node}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1666a8da/libcloud/test/compute/fixtures/gce/zones_us-central1-b_instances_libcloud-lb-nopubip-001.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/zones_us-central1-b_instances_libcloud-lb-nopubip-001.json
b/libcloud/test/compute/fixtures/gce/zones_us-central1-b_instances_libcloud-lb-nopubip-001.json
new file mode 100644
index 0000000..0ec1709
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/zones_us-central1-b_instances_libcloud-lb-nopubip-001.json
@@ -0,0 +1,49 @@
+{
+  "canIpForward": false,
+  "creationTimestamp": "2013-12-13T10:51:25.165-08:00",
+  "disks": [
+    {
+      "boot": true,
+      "deviceName": "libcloud-lb-demo-www-001",
+      "index": 0,
+      "kind": "compute#attachedDisk",
+      "mode": "READ_WRITE",
+      "source": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-b/disks/libcloud-lb-demo-www-001",
+      "type": "PERSISTENT"
+    }
+  ],
+  "id": "11523404878663997348",
+  "kind": "compute#instance",
+  "machineType": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-b/machineTypes/n1-standard-1",
+  "metadata": {
+    "fingerprint": "09vSzO6KXcw=",
+    "items": [
+      {
+        "key": "startup-script",
+        "value": "apt-get -y update && apt-get -y install apache2 && hostname
> /var/www/index.html"
+      }
+    ],
+    "kind": "compute#metadata"
+  },
+  "name": "libcloud-lb-nopubip-001",
+  "networkInterfaces": [
+    {
+      "name": "nic0",
+      "network": "https://www.googleapis.com/compute/v1/projects/project_name/global/networks/default",
+      "networkIP": "10.240.94.66"
+    }
+  ],
+  "scheduling": {
+    "automaticRestart": true,
+    "onHostMaintenance": "MIGRATE"
+  },
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-b/instances/libcloud-lb-nopubip-001",
+  "status": "RUNNING",
+  "tags": {
+    "fingerprint": "XI0he92M8l8=",
+    "items": [
+      "libcloud-lb-demo-www"
+    ]
+  },
+  "zone": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-b"
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1666a8da/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index 9ec97e0..630ecd1 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -3160,6 +3160,12 @@ class GCEMockHttp(MockHttpTestCase):
                 'zones_us-central1-a_instances_lcnode-001.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
 
+    def _zones_us_central1_b_instances_libcloud_lb_nopubip_001(
+            self, method, url, body, headers):
+        body = self.fixtures.load(
+            'zones_us-central1-b_instances_libcloud-lb-nopubip-001.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
     def _zones_us_central1_b_instances_libcloud_lb_demo_www_000(
             self, method, url, body, headers):
         body = self.fixtures.load(

http://git-wip-us.apache.org/repos/asf/libcloud/blob/1666a8da/libcloud/test/loadbalancer/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/loadbalancer/test_gce.py b/libcloud/test/loadbalancer/test_gce.py
index 41d0594..bd5d5ea 100644
--- a/libcloud/test/loadbalancer/test_gce.py
+++ b/libcloud/test/loadbalancer/test_gce.py
@@ -189,6 +189,13 @@ class GCELoadBalancerTest(GoogleTestCase):
         self.assertEqual(member.id, node.name)
         self.assertEqual(member.port, balancer.port)
 
+    def test_node_to_member_no_pub_ip(self):
+        node = self.driver.gce.ex_get_node('libcloud-lb-nopubip-001',
+                                           'us-central1-b')
+        balancer = self.driver.get_balancer('lcforwardingrule')
+        member = self.driver._node_to_member(node, balancer)
+        self.assertIsNone(member.ip)
+
     def test_forwarding_rule_to_loadbalancer(self):
         fwr = self.driver.gce.ex_get_forwarding_rule('lcforwardingrule')
         balancer = self.driver._forwarding_rule_to_loadbalancer(fwr)


Mime
View raw message