Merge "Add list of pool ids to HealthMonitor dict"
This commit is contained in:
commit
c96d32281f
@ -145,9 +145,8 @@ class HealthMonitor(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
|
||||
|
||||
pools = orm.relationship(
|
||||
"PoolMonitorAssociation",
|
||||
backref="healthmonitor",
|
||||
cascade="all"
|
||||
"PoolMonitorAssociation", backref="healthmonitor",
|
||||
cascade="all", lazy="joined"
|
||||
)
|
||||
|
||||
|
||||
@ -679,7 +678,10 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase,
|
||||
if res['type'] in ['HTTP', 'HTTPS']:
|
||||
for attr in ['url_path', 'http_method', 'expected_codes']:
|
||||
res[attr] = health_monitor[attr]
|
||||
|
||||
res['pools'] = [{'pool_id': p['pool_id'],
|
||||
'status': p['status'],
|
||||
'status_description': p['status_description']}
|
||||
for p in health_monitor.pools]
|
||||
return self._fields(res, fields)
|
||||
|
||||
def create_health_monitor(self, context, health_monitor):
|
||||
|
@ -258,7 +258,9 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'status': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
'status_description': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True}
|
||||
'is_visible': True},
|
||||
'pools': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1200,16 +1200,55 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
|
||||
self.pool(),
|
||||
self.health_monitor()
|
||||
) as (pool, hm):
|
||||
data = {"health_monitor": {
|
||||
"id": hm['health_monitor']['id'],
|
||||
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']
|
||||
)
|
||||
hm['health_monitor']['pools'] = [
|
||||
{'pool_id': pool['pool']['id'],
|
||||
'status': 'PENDING_CREATE',
|
||||
'status_description': None}]
|
||||
driver_call.assert_called_once_with(
|
||||
mock.ANY, hm['health_monitor'], pool['pool']['id'])
|
||||
|
||||
def test_pool_monitor_list_of_pools(self):
|
||||
with contextlib.nested(
|
||||
self.pool(),
|
||||
self.pool(),
|
||||
self.health_monitor()
|
||||
) as (p1, p2, hm):
|
||||
ctx = context.get_admin_context()
|
||||
data = {'health_monitor': {
|
||||
'id': hm['health_monitor']['id'],
|
||||
'tenant_id': self._tenant_id}}
|
||||
self.plugin.create_pool_health_monitor(
|
||||
ctx, data, p1['pool']['id'])
|
||||
self.plugin.create_pool_health_monitor(
|
||||
ctx, data, p2['pool']['id'])
|
||||
healthmon = self.plugin.get_health_monitor(
|
||||
ctx, hm['health_monitor']['id'])
|
||||
pool_data = [{'pool_id': p1['pool']['id'],
|
||||
'status': 'PENDING_CREATE',
|
||||
'status_description': None},
|
||||
{'pool_id': p2['pool']['id'],
|
||||
'status': 'PENDING_CREATE',
|
||||
'status_description': None}]
|
||||
self.assertEqual(sorted(healthmon['pools']),
|
||||
sorted(pool_data))
|
||||
req = self.new_show_request(
|
||||
'health_monitors',
|
||||
hm['health_monitor']['id'],
|
||||
fmt=self.fmt)
|
||||
hm = self.deserialize(
|
||||
self.fmt,
|
||||
req.get_response(self.ext_api)
|
||||
)
|
||||
self.assertEqual(sorted(hm['health_monitor']['pools']),
|
||||
sorted(pool_data))
|
||||
|
||||
def test_create_pool_health_monitor_already_associated(self):
|
||||
with contextlib.nested(
|
||||
self.pool(name="pool"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user