libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1197169 - in /libcloud/trunk: libcloud/loadbalancer/base.py test/loadbalancer/test_gogrid.py
Date Thu, 03 Nov 2011 14:54:24 GMT
Author: tomaz
Date: Thu Nov  3 14:54:23 2011
New Revision: 1197169

URL: http://svn.apache.org/viewvc?rev=1197169&view=rev
Log:
Add a missing argument to the method call inside
LoadBalancer.attach_compute_node and Driver.balancer_attach_compute_node. This
patch has been contributed by Tim Fletcher <mail at tfletcher dot com> and is
part of LIBCLOUD-126

Modified:
    libcloud/trunk/libcloud/loadbalancer/base.py
    libcloud/trunk/test/loadbalancer/test_gogrid.py

Modified: libcloud/trunk/libcloud/loadbalancer/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/loadbalancer/base.py?rev=1197169&r1=1197168&r2=1197169&view=diff
==============================================================================
--- libcloud/trunk/libcloud/loadbalancer/base.py (original)
+++ libcloud/trunk/libcloud/loadbalancer/base.py Thu Nov  3 14:54:23 2011
@@ -55,7 +55,7 @@ class LoadBalancer(object):
         self.driver = driver
 
     def attach_compute_node(self, node):
-        return self.driver.balancer_attach_compute_node(node)
+        return self.driver.balancer_attach_compute_node(self, node)
 
     def attach_member(self, member):
         return self.driver.balancer_attach_member(self, member)
@@ -151,15 +151,16 @@ class Driver(BaseDriver):
                 'get_balancer not implemented for this driver'
 
     def balancer_attach_compute_node(self, balancer, node):
-      """
-      Attach a compute node as a member to the load balancer.
+        """
+        Attach a compute node as a member to the load balancer.
 
-      @keyword node: Member to join to the balancer
-      @type member: C{libcloud.compute.base.Node}
-      @return {Member} Member after joining the balancer.
-      """
+        @keyword node: Member to join to the balancer
+        @type member: C{libcloud.compute.base.Node}
+        @return {Member} Member after joining the balancer.
+        """
 
-      return self.attach_member(Member(None, node.public_ip[0], balancer.port))
+        return self.balancer_attach_member(balancer, Member(None, node.public_ip[0],
+                                           balancer.port))
 
     def balancer_attach_member(self, balancer, member):
         """

Modified: libcloud/trunk/test/loadbalancer/test_gogrid.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/loadbalancer/test_gogrid.py?rev=1197169&r1=1197168&r2=1197169&view=diff
==============================================================================
--- libcloud/trunk/test/loadbalancer/test_gogrid.py (original)
+++ libcloud/trunk/test/loadbalancer/test_gogrid.py Thu Nov  3 14:54:23 2011
@@ -19,6 +19,8 @@ import unittest
 from urlparse import urlparse
 
 from libcloud.common.types import LibcloudError
+from libcloud.compute.base import Node
+from libcloud.compute.drivers.dummy import DummyNodeDriver
 from libcloud.loadbalancer.base import LoadBalancer, Member, Algorithm
 from libcloud.loadbalancer.drivers.gogrid import GoGridLBDriver
 
@@ -101,6 +103,18 @@ class GoGridTests(unittest.TestCase):
         self.assertEquals(expected_members,
                 set(["%s:%s" % (member.ip, member.port) for member in members]))
 
+    def test_balancer_attach_compute_node(self):
+        balancer = LoadBalancer(23530, None, None, None, None, self.driver)
+        node = Node(id='1', name='test', state=None, public_ip=['10.0.0.75'], 
+                    private_ip=[], driver=DummyNodeDriver)
+        member1 = self.driver.balancer_attach_compute_node(balancer, node)
+        member2 = balancer.attach_compute_node(node)
+
+        self.assertEquals(member1.ip, '10.0.0.75')
+        self.assertEquals(member1.port, 80)
+        self.assertEquals(member2.ip, '10.0.0.75')
+        self.assertEquals(member2.port, 80)
+
     def test_balancer_attach_member(self):
         balancer = LoadBalancer(23530, None, None, None, None, None)
         member = self.driver.balancer_attach_member(balancer,



Mime
View raw message