libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1103136 - in /incubator/libcloud/trunk: libcloud/loadbalancer/drivers/rackspace.py test/loadbalancer/test_rackspace.py
Date Sat, 14 May 2011 15:26:51 GMT
Author: tomaz
Date: Sat May 14 15:26:51 2011
New Revision: 1103136

URL: http://svn.apache.org/viewvc?rev=1103136&view=rev
Log:
Add list_protocols method to the Rackspace LB driver.

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

Modified: incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py?rev=1103136&r1=1103135&r2=1103136&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py (original)
+++ incubator/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py Sat May 14 15:26:51
2011
@@ -80,6 +80,10 @@ class RackspaceLBDriver(Driver):
     }
     _ALGORITHM_TO_VALUE_MAP = reverse_dict(_VALUE_TO_ALGORITHM_MAP)
 
+    def list_protocols(self):
+        return self._to_protocols(
+                   self.connection.request('/loadbalancers/protocols').object)
+
     def list_balancers(self):
         return self._to_balancers(
                 self.connection.request('/loadbalancers').object)
@@ -141,6 +145,12 @@ class RackspaceLBDriver(Driver):
         return self._to_members(
                 self.connection.request(uri).object)
 
+    def _to_protocols(self, object):
+        protocols = []
+        for item in object["protocols"]:
+            protocols.append(item['name'].lower())
+        return protocols
+
     def _to_balancers(self, object):
         return [ self._to_balancer(el) for el in object["loadBalancers"] ]
 

Modified: incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py?rev=1103136&r1=1103135&r2=1103136&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py (original)
+++ incubator/libcloud/trunk/test/loadbalancer/test_rackspace.py Sat May 14 15:26:51 2011
@@ -17,6 +17,12 @@ class RackspaceLBTests(unittest.TestCase
         RackspaceLBMockHttp.type = None
         self.driver = RackspaceLBDriver('user', 'key')
 
+    def test_list_protocols(self):
+        protocols = self.driver.list_protocols()
+
+        self.assertEqual(len(protocols), 10)
+        self.assertTrue('http' in protocols)
+
     def test_list_balancers(self):
         balancers = self.driver.list_balancers()
 
@@ -83,6 +89,11 @@ class RackspaceLBMockHttp(MockHttp):
                    'x-storage-url': 'https://storage4.clouddrive.com/v1/MossoCloudFS_FE011C19-CF86-4F87-BE5D-9229145D7A06'}
         return (httplib.NO_CONTENT, "", headers, httplib.responses[httplib.NO_CONTENT])
 
+    def _v1_0_slug_loadbalancers_protocols(self, method, url, body, headers):
+        body = self.fixtures.load('v1_slug_loadbalancers_protocols.json')
+        return (httplib.ACCEPTED, body, {},
+                httplib.responses[httplib.ACCEPTED])
+
     def _v1_0_slug_loadbalancers(self, method, url, body, headers):
         if method == "GET":
             body = self.fixtures.load('v1_slug_loadbalancers.json')



Mime
View raw message