libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1471179 - in /libcloud/trunk: CHANGES libcloud/loadbalancer/drivers/rackspace.py libcloud/test/loadbalancer/fixtures/rackspace/v1_0_slug_loadbalancers_8290_usage_current.json libcloud/test/loadbalancer/test_rackspace.py
Date Tue, 23 Apr 2013 22:07:38 GMT
Author: tomaz
Date: Tue Apr 23 22:07:38 2013
New Revision: 1471179

URL: http://svn.apache.org/r1471179
Log:
Add ex_list_current_usage method to the Rackspace load balancer driver.

Added:
    libcloud/trunk/libcloud/test/loadbalancer/fixtures/rackspace/v1_0_slug_loadbalancers_8290_usage_current.json
Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
    libcloud/trunk/libcloud/test/loadbalancer/test_rackspace.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1471179&r1=1471178&r2=1471179&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Tue Apr 23 22:07:38 2013
@@ -10,6 +10,10 @@ Changes with Apache Libcloud in deveplom
     - Add ex_start_node method to the Joyent driver. (LIBCLOUD-319)
       [rszabo50]
 
+ *) Load Balancer
+
+    - Add ex_list_current_usage method to the Rackspace driver.
+
 Changes with Apache Libcloud 0.12.4:
 
  *) Compute

Modified: libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py?rev=1471179&r1=1471178&r2=1471179&view=diff
==============================================================================
--- libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py (original)
+++ libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py Tue Apr 23 22:07:38 2013
@@ -1298,6 +1298,21 @@ class RackspaceLBDriver(Driver, OpenStac
 
         return resp.status == httplib.ACCEPTED
 
+    def ex_list_current_usage(self, balancer):
+        """
+        Return current load balancer usage report.
+
+        @param balancer: Balancer to remove the access rules from.
+        @type  balancer: L{LoadBalancer}
+
+        @return: Raw load balancer usage object.
+        @rtype: C{dict}
+        """
+        uri = '/loadbalancers/%s/usage/current' % (balancer.id)
+        resp = self.connection.request(uri, method='GET')
+
+        return resp.object
+
     def _to_protocols(self, object):
         protocols = []
         for item in object["protocols"]:

Added: libcloud/trunk/libcloud/test/loadbalancer/fixtures/rackspace/v1_0_slug_loadbalancers_8290_usage_current.json
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/loadbalancer/fixtures/rackspace/v1_0_slug_loadbalancers_8290_usage_current.json?rev=1471179&view=auto
==============================================================================
--- libcloud/trunk/libcloud/test/loadbalancer/fixtures/rackspace/v1_0_slug_loadbalancers_8290_usage_current.json
(added)
+++ libcloud/trunk/libcloud/test/loadbalancer/fixtures/rackspace/v1_0_slug_loadbalancers_8290_usage_current.json
Tue Apr 23 22:07:38 2013
@@ -0,0 +1,35 @@
+{
+    "links": [],
+    "loadBalancerUsageRecords": [
+        {
+            "id": 1234,
+            "startTime": "2013-04-22T22:00:00Z",
+            "endTime": "2013-04-22T23:00:00Z",
+            "numVips": 1,
+            "incomingTransfer": 0,
+            "outgoingTransfer": 0,
+            "incomingTransferSsl": 6182163,
+            "outgoingTransferSsl": 9702071,
+            "vipType": "PUBLIC",
+            "averageNumConnections": 0,
+            "averageNumConnectionsSsl": 14.9166666666666,
+            "numPolls": 12,
+            "sslMode": "ON"
+        },
+        {
+            "id": 12345,
+            "startTime": "2013-04-22T23:00:00Z",
+            "endTime": "2013-04-23T00:00:00Z",
+            "numVips": 1,
+            "incomingTransfer": 0,
+            "outgoingTransfer": 0,
+            "incomingTransferSsl": 6815503,
+            "outgoingTransferSsl": 10474092,
+            "vipType": "PUBLIC",
+            "averageNumConnections": 0,
+            "averageNumConnectionsSsl": 19.9166666666667,
+            "numPolls": 12,
+            "sslMode": "ON"
+        }
+    ]
+}

Modified: libcloud/trunk/libcloud/test/loadbalancer/test_rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/loadbalancer/test_rackspace.py?rev=1471179&r1=1471178&r2=1471179&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/loadbalancer/test_rackspace.py (original)
+++ libcloud/trunk/libcloud/test/loadbalancer/test_rackspace.py Tue Apr 23 22:07:38 2013
@@ -884,6 +884,12 @@ class RackspaceLBTests(unittest.TestCase
             condition=MemberCondition.ENABLED, weight=12)
         self.assertTrue(resp)
 
+    def test_ex_list_current_usage(self):
+        balancer = self.driver.get_balancer(balancer_id='8290')
+        usage = self.driver.ex_list_current_usage(balancer=balancer)
+        self.assertEqual(usage['loadBalancerUsageRecords'][0]['incomingTransferSsl'],
+                         6182163)
+
 
 class RackspaceUKLBTests(RackspaceLBTests):
 
@@ -1413,6 +1419,13 @@ class RackspaceLBMockHttp(MockHttpTestCa
             return (httplib.OK, json.dumps(response_body), {}, httplib.responses[httplib.OK])
         raise NotImplementedError
 
+    def _v1_0_slug_loadbalancers_8290_usage_current(self, method, url, body,
+                                                    headers):
+        if method == 'GET':
+            body = self.fixtures.load('v1_0_slug_loadbalancers_8290_usage_current.json')
+            return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+        raise NotImplementedError
+
     def _v1_1_auth(self, method, url, body, headers):
         headers = {'content-type': 'application/json; charset=UTF-8'}
         body = self.auth_fixtures.load('_v1_1__auth.json')



Mime
View raw message