]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
LBaaS: pass the complete healthmonitor object to driver
authorOleg Bondarev <obondarev@mirantis.com>
Mon, 5 Aug 2013 08:39:22 +0000 (12:39 +0400)
committerOleg Bondarev <obondarev@mirantis.com>
Tue, 6 Aug 2013 14:36:42 +0000 (18:36 +0400)
Fixes bug: #1208372

Change-Id: I72198446f4de3907d92fc9c2bbdb403cf2e87341

neutron/services/loadbalancer/plugin.py
neutron/tests/unit/db/loadbalancer/test_db_loadbalancer.py

index 2f6e2de8439b77e889b92c836e5c830aca54e9f6..d3903b67b40aedd9c008ed4fed0d80687d14e971 100644 (file)
@@ -206,8 +206,10 @@ class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb,
             health_monitor,
             pool_id
         )
+        monitor_id = health_monitor['health_monitor']['id']
+        hm = self.get_health_monitor(context, monitor_id)
         self.driver.create_pool_health_monitor(
-            context, health_monitor, pool_id)
+            context, hm, pool_id)
         return retval
 
     def delete_pool_health_monitor(self, context, id, pool_id):
index 9ccab978dba9ce43c875d61e0235800cfdd768d4..697b1cd464d33bbf57f1d652e034d1a242ecf0aa 100644 (file)
@@ -1193,6 +1193,23 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
                                    health_mon2['health_monitor']['id']]},
                                  res)
 
+    def test_driver_call_create_pool_health_monitor(self):
+        with mock.patch.object(self.plugin.driver,
+                               'create_pool_health_monitor') as driver_call:
+            with contextlib.nested(
+                self.pool(),
+                self.health_monitor()
+            ) as (pool, hm):
+                data = {"health_monitor": {
+                        "id": hm['health_monitor']['id'],
+                        'tenant_id': self._tenant_id}}
+                self.plugin.create_pool_health_monitor(
+                    context.get_admin_context(),
+                    data, pool['pool']['id']
+                )
+                driver_call.assert_called_once_with(
+                    mock.ANY, hm['health_monitor'], pool['pool']['id'])
+
     def test_create_pool_healthmon_invalid_pool_id(self):
         with self.health_monitor() as healthmon:
             self.assertRaises(loadbalancer.PoolNotFound,