Author: tomaz
Date: Thu Apr 19 22:57:32 2012
New Revision: 1328146
URL: http://svn.apache.org/viewvc?rev=1328146&view=rev
Log:
Don't include 'body_regex' attribute in the Rackspace driver body if
body_regex is None or empty string. This patch has been contributed by Bill
Woodward and is part of LIBCLOUD-186.
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=1328146&r1=1328145&r2=1328146&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Thu Apr 19 22:57:32 2012
@@ -30,6 +30,7 @@ Changes with Apache Libcloud in developm
- Add new driver for VCL cloud
(http://www.educause.edu/blog/hes8/CloudComputingandtheVirtualCom/167931)
+ ; LIBCLOUD-180
[Jason Gionta, Tomaz Muraus]
- Improve and add new features to Brightbox driver ; LIBCLOUD-184
@@ -44,12 +45,11 @@ Changes with Apache Libcloud in developm
- Allow reverse dns updates for cloud ip extensions
[Neil Wilson, Tomaz Muraus]
- - Add ex_userdata argument to the OpenStack 1.1 driver.
+ - Add ex_userdata argument to the OpenStack 1.1 driver. ; LIBCLOUD-185
[Jay Doane]
-
- Modify Vmware vCloud driver and implement new features
- for the vCloud version 1.5.
+ for the vCloud version 1.5. LIBCLOUD-183
[Michal Galet, Sengor Kusturica]
*) Storage
@@ -58,6 +58,12 @@ Changes with Apache Libcloud in developm
- Add CLOUDFILES_SWIFT driver to connect to OpenStack Swift
[Dmitry Russkikh, Roman Bogorodskiy]
+ *) Load-balancer
+
+ - Don't include 'body_regex' attribute in the Rackspace driver body if
+ body_regex is None or empty string. ; LIBCLOUD-186
+ [Bill Woodward]
+
Changes with Apache Libcloud 0.9.1:
*) General:
Modified: libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py?rev=1328146&r1=1328145&r2=1328146&view=diff
==============================================================================
--- libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py (original)
+++ libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py Thu Apr 19
22:57:32 2012
@@ -125,7 +125,9 @@ class RackspaceHTTPHealthMonitor(Rackspa
super_dict = super(RackspaceHTTPHealthMonitor, self)._to_dict()
super_dict['path'] = self.path
super_dict['statusRegex'] = self.status_regex
- super_dict['bodyRegex'] = self.body_regex
+
+ if self.body_regex:
+ super_dict['bodyRegex'] = self.body_regex
return super_dict
@@ -1455,7 +1457,7 @@ class RackspaceLBDriver(Driver, OpenStac
attempts_before_deactivation=attempts_before_deactivation,
path=health_monitor_data.get("path"),
status_regex=health_monitor_data.get("statusRegex"),
- body_regex=health_monitor_data.get("bodyRegex"))
+ body_regex=health_monitor_data.get("bodyRegex", ''))
return None
Modified: libcloud/trunk/test/loadbalancer/test_rackspace.py
URL:
http://svn.apache.org/viewvc/libcloud/trunk/test/loadbalancer/test_rackspace.py?rev=1328146&r1=1328145&r2=1328146&view=diff
==============================================================================
--- libcloud/trunk/test/loadbalancer/test_rackspace.py (original)
+++ libcloud/trunk/test/loadbalancer/test_rackspace.py Thu Apr 19 22:57:32 2012
@@ -500,6 +500,25 @@ class RackspaceLBTests(unittest.TestCase
self.assertTrue(resp)
+ def
test_ex_update_balancer_http_health_monitor_with_no_option_body_regex(self):
+ balancer = self.driver.get_balancer(balancer_id='94700')
+ monitor = RackspaceHTTPHealthMonitor(type='HTTP', delay=10, timeout=5,
+ attempts_before_deactivation=2,
+ path='/',
+ status_regex='^[234][0-9][0-9]$',
+ body_regex='')
+
+ balancer = self.driver.ex_update_balancer_health_monitor(balancer,
monitor)
+ updated_monitor = balancer.extra['healthMonitor']
+
+ self.assertEquals('HTTP', updated_monitor.type)
+ self.assertEquals(10, updated_monitor.delay)
+ self.assertEquals(5, updated_monitor.timeout)
+ self.assertEquals(2, updated_monitor.attempts_before_deactivation)
+ self.assertEquals('/', updated_monitor.path)
+ self.assertEquals('^[234][0-9][0-9]$', updated_monitor.status_regex)
+ self.assertEquals('', updated_monitor.body_regex)
+
def test_ex_disable_balancer_health_monitor(self):
balancer = self.driver.get_balancer(balancer_id='8290')
balancer = self.driver.ex_disable_balancer_health_monitor(balancer)
@@ -1286,6 +1305,29 @@ class RackspaceLBMockHttp(MockHttpTestCa
raise NotImplementedError
+ def _v1_0_slug_loadbalancers_94700(self, method, url, body, headers):
+ if method == "GET":
+ body =
self.fixtures.load("v1_slug_loadbalancers_94700_http_health_monitor_no_body_regex.json")
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+ raise NotImplementedError
+
+ def _v1_0_slug_loadbalancers_94700_healthmonitor(self, method, url, body,
headers):
+ if method == 'PUT':
+ json_body = json.loads(body)
+
+ self.assertEquals('HTTP', json_body['type'])
+ self.assertEquals(10, json_body['delay'])
+ self.assertEquals(5, json_body['timeout'])
+ self.assertEquals(2, json_body['attemptsBeforeDeactivation'])
+ self.assertEquals('/', json_body['path'])
+ self.assertEquals('^[234][0-9][0-9]$', json_body['statusRegex'])
+ self.assertFalse('bodyRegex' in json_body)
+
+ return (httplib.ACCEPTED, '', {},
httplib.responses[httplib.ACCEPTED])
+
+ raise NotImplementedError
+
def _v1_0_slug_loadbalancers_3130(self, method, url, body, headers):
""" update_balancer(b, protocol='HTTPS'), then get_balancer('3130') """
if method == "PUT":