libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1229432 - in /libcloud/trunk: CHANGES libcloud/loadbalancer/drivers/rackspace.py test/loadbalancer/test_rackspace.py
Date Tue, 10 Jan 2012 01:10:46 GMT
Author: tomaz
Date: Tue Jan 10 01:10:45 2012
New Revision: 1229432

URL: http://svn.apache.org/viewvc?rev=1229432&view=rev
Log:
Add ex_list_protocols_with_default_ports method to the Rackspace loadbalancer
driver. This patch has been contributed by Dave King 
<dave dot king at mailtrust dot com> and it's part of LIBCLOUD-142.

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

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1229432&r1=1229431&r2=1229432&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Tue Jan 10 01:10:45 2012
@@ -59,6 +59,7 @@ Changes with Apache Libcloud in developm
       - Populate LoadBalancer extra dictionary with more attributes
       - Add support for health monitors and connection throttling
       - Add more balancer states
+      - ex_list_protocols_with_default_ports
       [Dave King]
 
     - Propagate extra keyword arguments passed to the Rackspace driver

Modified: libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py?rev=1229432&r1=1229431&r2=1229432&view=diff
==============================================================================
--- libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py (original)
+++ libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py Tue Jan 10 01:10:45 2012
@@ -304,6 +304,15 @@ class RackspaceLBDriver(Driver):
         return self._to_protocols(
                    self.connection.request('/loadbalancers/protocols').object)
 
+    def ex_list_protocols_with_default_ports(self):
+        """
+        @rtype: C{list} of tuples of protocols (C{str}) with default ports
+        (C{int}).
+        @return: A list of protocols with default ports included.
+        """
+        return self._to_protocols_with_default_ports(
+                   self.connection.request('/loadbalancers/protocols').object)
+
     def list_balancers(self, ex_member_address=None):
         """
         @param ex_member_address: Optional IP address of the attachment member.
@@ -1103,6 +1112,15 @@ class RackspaceLBDriver(Driver):
             protocols.append(item['name'].lower())
         return protocols
 
+    def _to_protocols_with_default_ports(self, object):
+        protocols = []
+        for item in object["protocols"]:
+            name = item['name'].lower()
+            port = int(item['port'])
+            protocols.append((name, port))
+
+        return protocols
+
     def _to_balancers(self, object):
         return [self._to_balancer(el) for el in object["loadBalancers"]]
 

Modified: libcloud/trunk/test/loadbalancer/test_rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/loadbalancer/test_rackspace.py?rev=1229432&r1=1229431&r2=1229432&view=diff
==============================================================================
--- libcloud/trunk/test/loadbalancer/test_rackspace.py (original)
+++ libcloud/trunk/test/loadbalancer/test_rackspace.py Tue Jan 10 01:10:45 2012
@@ -52,6 +52,12 @@ class RackspaceLBTests(unittest.TestCase
         self.assertEqual(len(protocols), 10)
         self.assertTrue('http' in protocols)
 
+    def test_ex_list_protocols_with_default_ports(self):
+        protocols = self.driver.ex_list_protocols_with_default_ports()
+
+        self.assertEqual(len(protocols), 10)
+        self.assertTrue(('http', 80) in protocols)
+
     def test_list_supported_algorithms(self):
         algorithms = self.driver.list_supported_algorithms()
 



Mime
View raw message