libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pque...@apache.org
Subject svn commit: r1103098 - in /incubator/libcloud/trunk: ./ libcloud/loadbalancer/ libcloud/loadbalancer/drivers/ test/loadbalancer/
Date Sat, 14 May 2011 13:22:25 GMT
Author: pquerna
Date: Sat May 14 13:22:24 2011
New Revision: 1103098

URL: http://svn.apache.org/viewvc?rev=1103098&view=rev
Log:
Remove the LB prefix to most libcloud.loadbalancer.* types

Modified:
    incubator/libcloud/trunk/example_loadbalancer.py
    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/libcloud/loadbalancer/types.py
    incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py
    incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py

Modified: incubator/libcloud/trunk/example_loadbalancer.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/example_loadbalancer.py?rev=1103098&r1=1103097&r2=1103098&view=diff
==============================================================================
--- incubator/libcloud/trunk/example_loadbalancer.py (original)
+++ incubator/libcloud/trunk/example_loadbalancer.py Sat May 14 13:22:24 2011
@@ -3,8 +3,8 @@
 import os
 import time
 
-from libcloud.loadbalancer.base import LB, LBMember
-from libcloud.loadbalancer.types import Provider, LBState
+from libcloud.loadbalancer.base import LoadBalancer, Member
+from libcloud.loadbalancer.types import Provider, State
 from libcloud.loadbalancer.providers import get_driver
 
 def main():
@@ -20,8 +20,8 @@ def main():
     new_balancer_name = 'testlb' + os.urandom(4).encode('hex')
     new_balancer = driver.create_balancer(name=new_balancer_name,
             port=80,
-            nodes=(LBMember(None, '192.168.86.1', 80),
-                LBMember(None, '192.168.86.2', 8080))
+            nodes=(Member(None, '192.168.86.1', 80),
+                Member(None, '192.168.86.2', 8080))
             )
 
     print new_balancer
@@ -32,7 +32,7 @@ def main():
     while True:
         balancer = driver.balancer_detail(balancer=new_balancer)
 
-        if balancer.state == LBState.RUNNING:
+        if balancer.state == State.RUNNING:
             break
 
         time.sleep(30)
@@ -45,7 +45,7 @@ def main():
     balancer.detach_node(nodes[0])
 
     # and add another one: 10.0.0.10:1000
-    print balancer.attach_node(ip='10.0.0.10', port='1000')
+    print balancer.attach_node(Member(None, ip='10.0.0.10', port='1000'))
 
     # remove the balancer
     driver.destroy_balancer(new_balancer)

Modified: incubator/libcloud/trunk/libcloud/loadbalancer/base.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/loadbalancer/base.py?rev=1103098&r1=1103097&r2=1103098&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/loadbalancer/base.py (original)
+++ incubator/libcloud/trunk/libcloud/loadbalancer/base.py Sat May 14 13:22:24 2011
@@ -17,14 +17,14 @@ from libcloud.common.base import Connect
 from libcloud.common.types import LibcloudError
 
 __all__ = [
-        "LBMember",
+        "Member",
         "LB",
         "LBDriver",
         "LBAlgorithm",
         "LBProtocol"
         ]
 
-class LBMember(object):
+class Member(object):
 
     def __init__(self, id, ip, port):
         self.id = str(id) if id else None
@@ -35,14 +35,14 @@ class LBMember(object):
         return ('<LBMember: id=%s, address=%s:%s>' % (self.id,
             self.ip, self.port))
 
-class LBAlgorithm(object):
+class Algorithm(object):
     RANDOM = 0
     ROUND_ROBIN = 1
     LEAST_CONNECTIONS = 2
 
-DEFAULT_ALGORITHM = LBAlgorithm.ROUND_ROBIN
+DEFAULT_ALGORITHM = Algorithm.ROUND_ROBIN
 
-class LB(object):
+class LoadBalancer(object):
     """
     Provide a common interface for handling Load Balancers.
     """
@@ -72,7 +72,7 @@ class LB(object):
                 self.name, self.state))
 
 
-class LBDriver(object):
+class Driver(object):
     """
     A base LBDriver class to derive from
 

Modified: incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py?rev=1103098&r1=1103097&r2=1103098&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py (original)
+++ incubator/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py Sat May 14 13:22:24 2011
@@ -18,22 +18,22 @@ import time
 from libcloud.common.types import LibcloudError
 from libcloud.utils import reverse_dict
 from libcloud.common.gogrid import GoGridConnection, BaseGoGridDriver
-from libcloud.loadbalancer.base import LB, LBMember, LBDriver, LBAlgorithm
+from libcloud.loadbalancer.base import LoadBalancer, Member, Driver, Algorithm
 from libcloud.loadbalancer.base import DEFAULT_ALGORITHM 
-from libcloud.loadbalancer.types import Provider, LBState, LibcloudLBImmutableError
+from libcloud.loadbalancer.types import Provider, State, LibcloudLBImmutableError
 
 
-class GoGridLBDriver(BaseGoGridDriver, LBDriver):
+class GoGridLBDriver(BaseGoGridDriver, Driver):
     connectionCls = GoGridConnection
     type = Provider.RACKSPACE
     api_name = 'gogrid_lb'
     name = 'GoGrid LB'
 
-    LB_STATE_MAP = { 'On': LBState.RUNNING,
-                     'Unknown': LBState.UNKNOWN }
+    LB_STATE_MAP = { 'On': State.RUNNING,
+                     'Unknown': State.UNKNOWN }
     _VALUE_TO_ALGORITHM_MAP = {
-        'round balancer': LBAlgorithm.ROUND_ROBIN,
-        'least connection': LBAlgorithm.LEAST_CONNECTIONS
+        'round balancer': Algorithm.ROUND_ROBIN,
+        'least connection': Algorithm.LEAST_CONNECTIONS
     }
     _ALGORITHM_TO_VALUE_MAP = reverse_dict(_VALUE_TO_ALGORITHM_MAP)
 
@@ -151,7 +151,7 @@ class GoGridLBDriver(BaseGoGridDriver, L
 
     def _members_to_params(self, members):
         """
-        Helper method to convert list of L{LBMember} objects
+        Helper method to convert list of L{Member} objects
         to GET params.
 
         """
@@ -170,10 +170,10 @@ class GoGridLBDriver(BaseGoGridDriver, L
         return [ self._to_balancer(el) for el in object["list"] ]
 
     def _to_balancer(self, el):
-        lb = LB(id=el.get("id"),
+        lb = LoadBalancer(id=el.get("id"),
                 name=el["name"],
                 state=self.LB_STATE_MAP.get(
-                    el["state"]["name"], LBState.UNKNOWN),
+                    el["state"]["name"], State.UNKNOWN),
                 ip=el["virtualip"]["ip"]["ip"],
                 port=el["virtualip"]["port"],
                 driver=self.connection.driver)
@@ -183,7 +183,7 @@ class GoGridLBDriver(BaseGoGridDriver, L
         return [ self._to_member(el) for el in object ]
 
     def _to_member(self, el):
-        member = LBMember(id=el["ip"]["id"],
+        member = Member(id=el["ip"]["id"],
                 ip=el["ip"]["ip"],
                 port=el["port"])
         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=1103098&r1=1103097&r2=1103098&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py (original)
+++ incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py Sat May 14 13:22:24
2011
@@ -21,8 +21,8 @@ except ImportError:
     import simplejson as json
 
 from libcloud.common.base import Response
-from libcloud.loadbalancer.base import LB, LBMember, LBDriver
-from libcloud.loadbalancer.types import Provider, LBState
+from libcloud.loadbalancer.base import LoadBalancer, Member, Driver
+from libcloud.loadbalancer.types import Provider, State
 from libcloud.common.rackspace import (AUTH_HOST_US,
         RackspaceBaseConnection)
 
@@ -63,14 +63,14 @@ class RackspaceConnection(RackspaceBaseC
                 params=params, data=data, method=method, headers=headers)
 
 
-class RackspaceLBDriver(LBDriver):
+class RackspaceLBDriver(Driver):
     connectionCls = RackspaceConnection
     type = Provider.RACKSPACE
     api_name = 'rackspace_lb'
     name = 'Rackspace LB'
 
-    LB_STATE_MAP = { 'ACTIVE': LBState.RUNNING,
-                     'BUILD': LBState.PENDING }
+    LB_STATE_MAP = { 'ACTIVE': State.RUNNING,
+                     'BUILD': State.PENDING }
 
     def list_balancers(self):
         return self._to_balancers(
@@ -139,10 +139,10 @@ class RackspaceLBDriver(LBDriver):
         return [ self._to_balancer(el) for el in object["loadBalancers"] ]
 
     def _to_balancer(self, el):
-        lb = LB(id=el["id"],
+        lb = LoadBalancer(id=el["id"],
                 name=el["name"],
                 state=self.LB_STATE_MAP.get(
-                    el["status"], LBState.UNKNOWN),
+                    el["status"], State.UNKNOWN),
                 ip=el["virtualIps"][0]["address"],
                 port=el["port"],
                 driver=self.connection.driver)
@@ -152,7 +152,7 @@ class RackspaceLBDriver(LBDriver):
         return [ self._to_member(el) for el in object["nodes"] ]
 
     def _to_member(self, el):
-        lbmember = LBMember(id=el["id"],
+        lbmember = Member(id=el["id"],
                 ip=el["address"],
                 port=el["port"])
         return lbmember

Modified: incubator/libcloud/trunk/libcloud/loadbalancer/types.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/loadbalancer/types.py?rev=1103098&r1=1103097&r2=1103098&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/loadbalancer/types.py (original)
+++ incubator/libcloud/trunk/libcloud/loadbalancer/types.py Sat May 14 13:22:24 2011
@@ -15,7 +15,7 @@
 
 __all__ = [
         "Provider",
-        "LBState",
+        "State",
         "LibcloudLBError",
         "LibcloudLBImmutableError",
         ]
@@ -30,7 +30,7 @@ class Provider(object):
     RACKSPACE = 0
     GOGRID = 1
 
-class LBState(object):
+class State(object):
     """
     Standart states for a loadbalancer
 

Modified: incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py?rev=1103098&r1=1103097&r2=1103098&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py (original)
+++ incubator/libcloud/trunk/test/loadbalancer/test_gogrid.py Sat May 14 13:22:24 2011
@@ -3,7 +3,7 @@ import os.path
 import sys
 import unittest
 
-from libcloud.loadbalancer.base import LB, LBMember, LBAlgorithm
+from libcloud.loadbalancer.base import LoadBalancer, Member, Algorithm
 from libcloud.loadbalancer.drivers.gogrid import GoGridLBDriver
 
 from test import MockHttp, MockRawResponse
@@ -29,9 +29,9 @@ class GoGridTests(unittest.TestCase):
     def test_create_balancer(self):
         balancer = self.driver.create_balancer(name='test2',
                 port=80,
-                algorithm=LBAlgorithm.ROUND_ROBIN,
-                members=(LBMember(None, '10.1.0.10', 80),
-                    LBMember(None, '10.1.0.11', 80))
+                algorithm=Algorithm.ROUND_ROBIN,
+                members=(Member(None, '10.1.0.10', 80),
+                         Member(None, '10.1.0.11', 80))
                 )
 
         self.assertEquals(balancer.name, 'test2')
@@ -61,15 +61,15 @@ class GoGridTests(unittest.TestCase):
                 set(["%s:%s" % (member.ip, member.port) for member in members]))
 
     def test_balancer_attach_member(self):
-        balancer = LB(23530, None, None, None, None, None)
+        balancer = LoadBalancer(23530, None, None, None, None, None)
         member = self.driver.balancer_attach_member(balancer,
-                LBMember(None, ip='10.0.0.75', port='80'))
+                    Member(None, ip='10.0.0.75', port='80'))
 
         self.assertEquals(member.ip, '10.0.0.75')
         self.assertEquals(member.port, 80)
 
     def test_balancer_detach_member(self):
-        balancer = LB(23530, None, None, None, None, None)
+        balancer = LoadBalancer(23530, None, None, None, None, None)
         member = self.driver.balancer_list_members(balancer)[0]
 
         ret = self.driver.balancer_detach_member(balancer, member)

Modified: incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py?rev=1103098&r1=1103097&r2=1103098&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py (original)
+++ incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py Sat May 14 13:22:24 2011
@@ -3,7 +3,7 @@ import os.path
 import sys
 import unittest
 
-from libcloud.loadbalancer.base import LB, LBMember
+from libcloud.loadbalancer.base import Member
 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,
-                members=(LBMember(None, '10.1.0.10', 80),
-                    LBMember(None, '10.1.0.11', 80))
+                members=(Member(None, '10.1.0.10', 80),
+                    Member(None, '10.1.0.11', 80))
                 )
 
         self.assertEquals(balancer.name, 'test2')
@@ -58,7 +58,7 @@ class RackspaceLBTests(unittest.TestCase
 
     def test_balancer_attach_member(self):
         balancer = self.driver.get_balancer(balancer_id='8290')
-        member = balancer.attach_member(LBMember(None, ip='10.1.0.12', port='80'))
+        member = balancer.attach_member(Member(None, ip='10.1.0.12', port='80'))
 
         self.assertEquals(member.ip, '10.1.0.12')
         self.assertEquals(member.port, 80)



Mime
View raw message