LBaas v1 Associate Monitor to Pool Fails

The associate monitor fails to show monitors to choose from
within horizon.  The monitor list code has changed where
you can no longer list monitors with a filter criteria.
This change switches to grab needed monitors one at a time.

Change-Id: Ibc5233028507c66de459e84e91f65c9557940ea5
Closes-bug: #1398754
This commit is contained in:
eric 2015-05-04 13:48:07 -06:00
parent 9543c7232a
commit 0dde489a81
2 changed files with 19 additions and 11 deletions

View File

@ -210,13 +210,18 @@ def _pool_get(request, pool_id, expand_resource=False):
except Exception:
messages.warning(request, _("Unable to get members for pool "
"%(pool)s.") % {"pool": pool_id})
try:
pool['health_monitors'] = pool_health_monitor_list(
request, id=pool['health_monitors'])
except Exception:
messages.warning(request,
_("Unable to get health monitors "
"for pool %(pool)s.") % {"pool": pool_id})
monitors = []
for monitor_id in pool['health_monitors']:
try:
monitors.append(_pool_health_monitor_get(request, monitor_id,
False))
except Exception:
messages.warning(request,
_("Unable to get health monitor "
"%(monitor_id)s for pool %(pool)s.")
% {"pool": pool_id,
"monitor_id": monitor_id})
pool['health_monitors'] = monitors
return Pool(pool)

View File

@ -185,7 +185,7 @@ class LbaasApiTests(test.APITestCase):
@test.create_stubs({neutronclient: ('show_pool', 'show_vip',
'list_members',
'list_health_monitors',),
'show_health_monitor',),
api.neutron: ('subnet_get',)})
def test_pool_get(self):
pool = self.pools.first()
@ -198,8 +198,10 @@ class LbaasApiTests(test.APITestCase):
neutronclient.show_vip(pool.vip_id).AndReturn(vip_dict)
neutronclient.list_members(pool_id=pool.id).AndReturn(
{'members': self.api_members.list()})
neutronclient.list_health_monitors(id=pool.health_monitors).AndReturn(
{'health_monitors': [self.api_monitors.first()]})
monitor = self.api_monitors.first()
for pool_mon in pool.health_monitors:
neutronclient.show_health_monitor(pool_mon).AndReturn(
{'health_monitors': [monitor]})
self.mox.ReplayAll()
ret_val = api.lbaas.pool_get(self.request, pool.id)
@ -210,7 +212,8 @@ class LbaasApiTests(test.APITestCase):
self.assertEqual(ret_val.subnet.id, subnet.id)
self.assertEqual(2, len(ret_val.members))
self.assertIsInstance(ret_val.members[0], api.lbaas.Member)
self.assertEqual(1, len(ret_val.health_monitors))
self.assertEqual(len(pool.health_monitors),
len(ret_val.health_monitors))
self.assertIsInstance(ret_val.health_monitors[0],
api.lbaas.PoolMonitor)