admin_state_up = sa.Column(sa.Boolean(), nullable=False)
pools = orm.relationship(
- "PoolMonitorAssociation",
- backref="healthmonitor",
- cascade="all"
+ "PoolMonitorAssociation", backref="healthmonitor",
+ cascade="all", lazy="joined"
)
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):
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"),