libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pque...@apache.org
Subject svn commit: r1102988 - in /incubator/libcloud/trunk: libcloud/loadbalancer/base.py libcloud/loadbalancer/drivers/gogrid.py libcloud/loadbalancer/drivers/rackspace.py test/loadbalancer/test_gogrid.py test/loadbalancer/test_rackspace.py
Date Sat, 14 May 2011 09:46:05 GMT
Author: pquerna
Date: Sat May 14 09:46:05 2011
New Revision: 1102988

URL: http://svn.apache.org/viewvc?rev=1102988&view=rev
Log:
Rename 'node{,s}' in the load balancer API to be 'member{,s}', as this is less confusing terminology

Modified:
    incubator/libcloud/trunk/libcloud/loadbalancer/base.py
    incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py
    incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
    incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py
    incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py

Modified: incubator/libcloud/trunk/libcloud/loadbalancer/base.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/loadbalancer/base.py?rev=1102988&r1=1102987&r2=1102988&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/loadbalancer/base.py (original)
+++ incubator/libcloud/trunk/libcloud/loadbalancer/base.py Sat May 14 09:46:05 2011
@@ -16,13 +16,13 @@
 from libcloud.common.base import ConnectionKey
 
 __all__ = [
-        "LBNode",
+        "LBMember",
         "LB",
         "LBDriver",
         "LBAlgorithm"
         ]
 
-class LBNode(object):
+class LBMember(object):
 
     def __init__(self, id, ip, port):
         self.id = str(id) if id else None
@@ -30,7 +30,7 @@ class LBNode(object):
         self.port = port
 
     def __repr__(self):
-        return ('<LBNode: id=%s, address=%s:%s>' % (self.id,
+        return ('<LBMember: id=%s, address=%s:%s>' % (self.id,
             self.ip, self.port))
 
 class LBAlgorithm(object):
@@ -53,14 +53,14 @@ class LB(object):
         self.port = port
         self.driver = driver
 
-    def attach_node(self, **kwargs):
-        return self.driver.balancer_attach_node(self, **kwargs)
+    def attach_member(self, **kwargs):
+        return self.driver.balancer_attach_member(self, **kwargs)
 
-    def detach_node(self, node):
-        return self.driver.balancer_detach_node(self, node)
+    def detach_member(self, member):
+        return self.driver.balancer_detach_member(self, member)
 
-    def list_nodes(self):
-        return self.driver.balancer_list_nodes(self)
+    def list_members(self):
+        return self.driver.balancer_list_members(self)
 
     def __repr__(self):
         return ('<LB: id=%s, name=%s, state=%s>' % (self.id,
@@ -110,7 +110,7 @@ class LBDriver(object):
         @type name: C{str}
         @keyword port: Port the load balancer should listen on (required)
         @type port: C{str}
-        @keyword nodes: C{list} of L{LBNode}s to attach to balancer
+        @keyword members: C{list} of L{LBNode}s to attach to balancer
         @type: C{list} of L{LBNode}s
 
         """
@@ -145,38 +145,38 @@ class LBDriver(object):
         raise NotImplementedError, \
                 'balancer_detail not implemented for this driver'
 
-    def balancer_attach_node(self, balancer, **kwargs):
+    def balancer_attach_member(self, balancer, **kwargs):
         """
-        Attach a node to balancer
+        Attach a member to balancer
 
-        @keyword ip: IP address of a node
+        @keyword ip: IP address of a member
         @type ip: C{str}
-        @keyword port: port that services we're balancing listens on on the node
+        @keyword port: port that services we're balancing listens on on the member
         @keyword port: C{str}
 
         """
 
         raise NotImplementedError, \
-                'balancer_attach_node not implemented for this driver'
+                'balancer_attach_member not implemented for this driver'
 
-    def balancer_detach_node(self, balancer, node):
+    def balancer_detach_member(self, balancer, member):
         """
-        Detach node from balancer
+        Detach member from balancer
 
-        @return: C{bool} True if node detach was successful, otherwise False
+        @return: C{bool} True if member detach was successful, otherwise False
 
         """
 
         raise NotImplementedError, \
-                'balancer_detach_node not implemented for this driver'
+                'balancer_detach_member not implemented for this driver'
 
-    def balancer_list_nodes(self, balancer):
+    def balancer_list_members(self, balancer):
         """
-        Return list of nodes attached to balancer
+        Return list of members attached to balancer
 
         @return: C{list} of L{LBNode}s
 
         """
 
         raise NotImplementedError, \
-                'balancer_list_nodes not implemented for this driver'
+                'balancer_list_members not implemented for this driver'

Modified: incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py?rev=1102988&r1=1102987&r2=1102988&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py (original)
+++ incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py Sat May 14 09:46:05 2011
@@ -23,7 +23,7 @@ except ImportError:
 
 from libcloud.common.types import LibcloudError
 from libcloud.common.gogrid import GoGridConnection, BaseGoGridDriver
-from libcloud.loadbalancer.base import LB, LBNode, LBDriver
+from libcloud.loadbalancer.base import LB, LBMember, LBDriver
 from libcloud.loadbalancer.types import Provider, LBState, LibcloudLBImmutableError
 
 
@@ -43,12 +43,12 @@ class GoGridLBDriver(BaseGoGridDriver, L
     def ex_create_balancer_nowait(self, **kwargs):
         name = kwargs['name']
         port = kwargs['port']
-        nodes = kwargs['nodes']
+        members = kwargs['members']
 
         params = {'name': name,
                 'virtualip.ip': self._get_first_ip(),
                 'virtualip.port': port}
-        params.update(self._nodes_to_params(nodes))
+        params.update(self._members_to_params(members))
 
         resp = self.connection.request('/api/grid/loadbalancer/add',
                 method='GET',
@@ -108,41 +108,41 @@ class GoGridLBDriver(BaseGoGridDriver, L
 
         return self._to_balancers(resp.object)[0]
 
-    def balancer_attach_node(self, balancer, **kwargs):
+    def balancer_attach_member(self, balancer, **kwargs):
         ip = kwargs['ip']
         port = kwargs['port']
 
-        nodes = self.balancer_list_nodes(balancer)
-        nodes.append(LBNode(None, ip, port))
+        members = self.balancer_list_members(balancer)
+        members.append(LBMember(None, ip, port))
 
         params = {"id": balancer.id}
 
-        params.update(self._nodes_to_params(nodes))
+        params.update(self._members_to_params(members))
 
-        resp = self._update_node(params)
+        resp = self._update_balancer(params)
 
-        return [ node for node in
-                self._to_nodes(resp.object["list"][0]["realiplist"])
-                if node.ip == ip ][0]
+        return [ member for member in
+                self._to_members(resp.object["list"][0]["realiplist"])
+                if member.ip == ip ][0]
 
-    def balancer_detach_node(self, balancer, node):
-        nodes = self.balancer_list_nodes(balancer)
+    def balancer_detach_member(self, balancer, member):
+        members = self.balancer_list_members(balancer)
 
-        remaining_nodes = [n for n in nodes if n.id != node.id]
+        remaining_members = [n for n in members if n.id != member.id]
 
         params = {"id": balancer.id}
-        params.update(self._nodes_to_params(remaining_nodes))
+        params.update(self._members_to_params(remaining_members))
 
-        resp = self._update_node(params)
+        resp = self._update_balancer(params)
 
         return resp.status == 200
 
-    def balancer_list_nodes(self, balancer):
+    def balancer_list_members(self, balancer):
         resp = self.connection.request('/api/grid/loadbalancer/get',
                 params={'id': balancer.id})
-        return self._to_nodes(resp.object["list"][0]["realiplist"])
+        return self._to_members(resp.object["list"][0]["realiplist"])
 
-    def _update_node(self, params):
+    def _update_balancer(self, params):
         try:
             return self.connection.request('/api/grid/loadbalancer/edit',
                     method='POST',
@@ -153,9 +153,9 @@ class GoGridLBDriver(BaseGoGridDriver, L
 
         raise LibcloudError(value='Exception: %s' % str(err), driver=self)
 
-    def _nodes_to_params(self, nodes):
+    def _members_to_params(self, members):
         """
-        Helper method to convert list of L{LBNode} objects
+        Helper method to convert list of L{LBMember} objects
         to GET params.
 
         """
@@ -163,9 +163,9 @@ class GoGridLBDriver(BaseGoGridDriver, L
         params = {}
 
         i = 0
-        for node in nodes:
-            params["realiplist.%s.ip" % i] = node.ip
-            params["realiplist.%s.port" % i] = node.port
+        for member in members:
+            params["realiplist.%s.ip" % i] = member.ip
+            params["realiplist.%s.port" % i] = member.port
             i += 1
 
         return params
@@ -183,11 +183,11 @@ class GoGridLBDriver(BaseGoGridDriver, L
                 driver=self.connection.driver)
         return lb
 
-    def _to_nodes(self, object):
-        return [ self._to_node(el) for el in object ]
+    def _to_members(self, object):
+        return [ self._to_member(el) for el in object ]
 
-    def _to_node(self, el):
-        lbnode = LBNode(id=el["ip"]["id"],
+    def _to_member(self, el):
+        member = LBMember(id=el["ip"]["id"],
                 ip=el["ip"]["ip"],
                 port=el["port"])
-        return lbnode
+        return member

Modified: incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py?rev=1102988&r1=1102987&r2=1102988&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py (original)
+++ incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py Sat May 14 09:46:05
2011
@@ -21,7 +21,7 @@ except ImportError:
     import simplejson
 
 from libcloud.common.base import Response
-from libcloud.loadbalancer.base import LB, LBNode, LBDriver
+from libcloud.loadbalancer.base import LB, LBMember, LBDriver
 from libcloud.loadbalancer.types import Provider, LBState
 from libcloud.common.rackspace import (AUTH_HOST_US,
         RackspaceBaseConnection)
@@ -79,16 +79,16 @@ class RackspaceLBDriver(LBDriver):
     def create_balancer(self, **kwargs):
         name = kwargs['name']
         port = kwargs['port']
-        nodes = kwargs['nodes']
+        members = kwargs['members']
 
         balancer_object = {"loadBalancer":
                 {"name": name,
                     "port": port,
                     "protocol": "HTTP",
                     "virtualIps": [{"type": "PUBLIC"}],
-                    "nodes": [{"address": node.ip,
-                        "port": node.port,
-                        "condition": "ENABLED"} for node in nodes],
+                    "nodes": [{"address": member.ip,
+                        "port": member.port,
+                        "condition": "ENABLED"} for member in members],
                     }
                 }
 
@@ -114,11 +114,11 @@ class RackspaceLBDriver(LBDriver):
 
         return self._to_balancer(resp.object["loadBalancer"])
 
-    def balancer_attach_node(self, balancer, **kwargs):
+    def balancer_attach_member(self, balancer, **kwargs):
         ip = kwargs['ip']
         port = kwargs['port']
 
-        node_object = {"nodes":
+        member_object = {"nodes":
                 [{"port": port,
                     "address": ip,
                     "condition": "ENABLED"}]
@@ -126,18 +126,18 @@ class RackspaceLBDriver(LBDriver):
 
         uri = '/loadbalancers/%s/nodes' % (balancer.id)
         resp = self.connection.request(uri, method='POST',
-                data=json.dumps(node_object))
-        return self._to_nodes(resp.object)[0]
+                data=json.dumps(member_object))
+        return self._to_members(resp.object)[0]
 
-    def balancer_detach_node(self, balancer, node):
-        uri = '/loadbalancers/%s/nodes/%s' % (balancer.id, node.id)
+    def balancer_detach_member(self, balancer, member):
+        uri = '/loadbalancers/%s/nodes/%s' % (balancer.id, member.id)
         resp = self.connection.request(uri, method='DELETE')
 
         return resp.status == 202
 
-    def balancer_list_nodes(self, balancer):
+    def balancer_list_members(self, balancer):
         uri = '/loadbalancers/%s/nodes' % (balancer.id)
-        return self._to_nodes(
+        return self._to_members(
                 self.connection.request(uri).object)
 
     def _to_balancers(self, object):
@@ -153,11 +153,11 @@ class RackspaceLBDriver(LBDriver):
                 driver=self.connection.driver)
         return lb
 
-    def _to_nodes(self, object):
-        return [ self._to_node(el) for el in object["nodes"] ]
+    def _to_members(self, object):
+        return [ self._to_member(el) for el in object["nodes"] ]
 
-    def _to_node(self, el):
-        lbnode = LBNode(id=el["id"],
+    def _to_member(self, el):
+        lbmember = LBMember(id=el["id"],
                 ip=el["address"],
                 port=el["port"])
-        return lbnode
+        return lbmember

Modified: incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py?rev=1102988&r1=1102987&r2=1102988&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py (original)
+++ incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py Sat May 14 09:46:05 2011
@@ -3,7 +3,7 @@ import os.path
 import sys
 import unittest
 
-from libcloud.loadbalancer.base import LB, LBNode
+from libcloud.loadbalancer.base import LB, LBMember
 from libcloud.loadbalancer.drivers.gogrid import GoGridLBDriver
 
 from test import MockHttp, MockRawResponse
@@ -29,8 +29,8 @@ class GoGridTests(unittest.TestCase):
     def test_create_balancer(self):
         balancer = self.driver.create_balancer(name='test2',
                 port=80,
-                nodes=(LBNode(None, '10.1.0.10', 80),
-                    LBNode(None, '10.1.0.11', 80))
+                members=(LBMember(None, '10.1.0.10', 80),
+                    LBMember(None, '10.1.0.11', 80))
                 )
 
         self.assertEquals(balancer.name, 'test2')
@@ -48,30 +48,30 @@ class GoGridTests(unittest.TestCase):
         self.assertEquals(balancer.name, 'test2')
         self.assertEquals(balancer.id, '23530')
 
-    def test_balancer_list_nodes(self):
+    def test_balancer_list_members(self):
         balancer = self.driver.balancer_detail(balancer_id='23530')
-        nodes = balancer.list_nodes()
+        members = balancer.list_members()
 
-        expected_nodes = set([u'10.0.0.78:80', u'10.0.0.77:80',
+        expected_members = set([u'10.0.0.78:80', u'10.0.0.77:80',
             u'10.0.0.76:80'])
 
-        self.assertEquals(len(nodes), 3)
-        self.assertEquals(expected_nodes,
-                set(["%s:%s" % (node.ip, node.port) for node in nodes]))
+        self.assertEquals(len(members), 3)
+        self.assertEquals(expected_members,
+                set(["%s:%s" % (member.ip, member.port) for member in members]))
 
-    def test_balancer_attach_node(self):
+    def test_balancer_attach_member(self):
         balancer = LB(23530, None, None, None, None, None)
-        node = self.driver.balancer_attach_node(balancer,
+        member = self.driver.balancer_attach_member(balancer,
                 ip='10.0.0.75', port='80')
 
-        self.assertEquals(node.ip, '10.0.0.75')
-        self.assertEquals(node.port, 80)
+        self.assertEquals(member.ip, '10.0.0.75')
+        self.assertEquals(member.port, 80)
 
-    def test_balancer_detach_node(self):
+    def test_balancer_detach_member(self):
         balancer = LB(23530, None, None, None, None, None)
-        node = self.driver.balancer_list_nodes(balancer)[0]
+        member = self.driver.balancer_list_members(balancer)[0]
 
-        ret = self.driver.balancer_detach_node(balancer, node)
+        ret = self.driver.balancer_detach_member(balancer, member)
 
         self.assertTrue(ret)
 

Modified: incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py?rev=1102988&r1=1102987&r2=1102988&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py (original)
+++ incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py Sat May 14 09:46:05 2011
@@ -3,7 +3,7 @@ import os.path
 import sys
 import unittest
 
-from libcloud.loadbalancer.base import LB, LBNode
+from libcloud.loadbalancer.base import LB, LBMember
 from libcloud.loadbalancer.drivers.rackspace import RackspaceLBDriver
 
 from test import MockHttp, MockRawResponse
@@ -29,8 +29,8 @@ class RackspaceLBTests(unittest.TestCase
     def test_create_balancer(self):
         balancer = self.driver.create_balancer(name='test2',
                 port=80,
-                nodes=(LBNode(None, '10.1.0.10', 80),
-                    LBNode(None, '10.1.0.11', 80))
+                members=(LBMember(None, '10.1.0.10', 80),
+                    LBMember(None, '10.1.0.11', 80))
                 )
 
         self.assertEquals(balancer.name, 'test2')
@@ -48,26 +48,26 @@ class RackspaceLBTests(unittest.TestCase
         self.assertEquals(balancer.name, 'test2')
         self.assertEquals(balancer.id, '8290')
 
-    def test_balancer_list_nodes(self):
+    def test_balancer_list_members(self):
         balancer = self.driver.balancer_detail(balancer_id='8290')
-        nodes = balancer.list_nodes()
+        members = balancer.list_members()
 
-        self.assertEquals(len(nodes), 2)
+        self.assertEquals(len(members), 2)
         self.assertEquals(set(['10.1.0.10:80', '10.1.0.11:80']),
-                set(["%s:%s" % (node.ip, node.port) for node in nodes]))
+                set(["%s:%s" % (member.ip, member.port) for member in members]))
 
-    def test_balancer_attach_node(self):
+    def test_balancer_attach_member(self):
         balancer = self.driver.balancer_detail(balancer_id='8290')
-        node = balancer.attach_node(ip='10.1.0.12', port='80')
+        member = balancer.attach_member(ip='10.1.0.12', port='80')
 
-        self.assertEquals(node.ip, '10.1.0.12')
-        self.assertEquals(node.port, 80)
+        self.assertEquals(member.ip, '10.1.0.12')
+        self.assertEquals(member.port, 80)
 
-    def test_balancer_detach_node(self):
+    def test_balancer_detach_member(self):
         balancer = self.driver.balancer_detail(balancer_id='8290')
-        node = balancer.list_nodes()[0]
+        member = balancer.list_members()[0]
 
-        ret = balancer.detach_node(node)
+        ret = balancer.detach_member(member)
 
         self.assertTrue(ret)
 



Mime
View raw message