Merge "LBaaS: add status of pool-monitor association to the pool return dict"

This commit is contained in:
Jenkins 2013-09-04 16:52:03 +00:00 committed by Gerrit Code Review
commit b0475db9dd
3 changed files with 32 additions and 0 deletions

View File

@ -479,6 +479,11 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase,
# Get the associated health_monitors
res['health_monitors'] = [
monitor['monitor_id'] for monitor in pool['monitors']]
res['health_monitors_status'] = [
{'monitor_id': monitor['monitor_id'],
'status': monitor['status'],
'status_description': monitor['status_description']}
for monitor in pool['monitors']]
return self._fields(res, fields)
def update_pool_stats(self, context, pool_id, data=None):

View File

@ -175,6 +175,8 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid_list': None},
'convert_to': attr.convert_to_list,
'is_visible': True},
'health_monitors_status': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'admin_state_up': {'allow_post': True, 'allow_put': True,
'default': True,
'convert_to': attr.convert_to_boolean,
@ -308,6 +310,7 @@ class Loadbalancer(extensions.ExtensionDescriptor):
@classmethod
def get_resources(cls):
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
my_plurals.append(('health_monitors_status', 'health_monitor_status'))
attr.PLURALS.update(dict(my_plurals))
resources = []
plugin = manager.NeutronManager.get_service_plugins()[

View File

@ -1109,6 +1109,16 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
res['pool']['health_monitors'])
self.assertIn(monitor2['health_monitor']['id'],
res['pool']['health_monitors'])
expected = [
{'monitor_id': monitor1['health_monitor']['id'],
'status': 'PENDING_CREATE',
'status_description': None},
{'monitor_id': monitor2['health_monitor']['id'],
'status': 'PENDING_CREATE',
'status_description': None}]
self.assertEqual(
sorted(expected),
sorted(res['pool']['health_monitors_status']))
def test_delete_healthmonitor_of_pool(self):
with self.health_monitor(type="TCP") as monitor1:
@ -1161,6 +1171,13 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
res['pool']['health_monitors'])
self.assertIn(monitor2['health_monitor']['id'],
res['pool']['health_monitors'])
expected = [
{'monitor_id': monitor2['health_monitor']['id'],
'status': 'PENDING_CREATE',
'status_description': None}
]
self.assertEqual(expected,
res['pool']['health_monitors_status'])
def test_create_loadbalancer(self):
vip_name = "vip3"
@ -1221,6 +1238,13 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
pool_updated['pool']['members'])
self.assertIn(health_monitor['health_monitor']['id'],
pool_updated['pool']['health_monitors'])
expected = [
{'monitor_id': health_monitor['health_monitor']['id'],
'status': 'PENDING_CREATE',
'status_description': None}
]
self.assertEqual(
expected, pool_updated['pool']['health_monitors_status'])
req = self.new_show_request('vips',
vip_id,