Fix pool response to fill healthmonitor_id properly

This means both renaming the field to healthmonitor_id and also adding
the code to fill it.
Also rename health_monitor objects to healthmonitor for consistency.

Change-Id: I4c3deb9ad20f5089168030f27fc0929155379585
Closes-Bug: #1693044
This commit is contained in:
Adam Harwell 2017-05-23 15:53:27 -07:00
parent c0a141989a
commit 6fa379c21b
5 changed files with 25 additions and 13 deletions

View File

@ -13,7 +13,7 @@
"name": "rr_pool",
"protocol": "HTTP",
"lb_algorithm": "ROUND_ROBIN",
"health_monitor": {
"healthmonitor": {
"type": "HTTP",
"delay": "3",
"expected_codes": "200,201,202",
@ -61,7 +61,7 @@
"name": "https_pool",
"protocol": "HTTPS",
"lb_algorithm": "ROUND_ROBIN",
"health_monitor": {
"healthmonitor": {
"type": "HTTPS",
"delay": "3",
"max_retries": 2,

View File

@ -14,7 +14,7 @@
"healthmonitor": {
"type": "HTTP",
"id": "0b608787-ea2d-48c7-89a1-8b8c24fa3b17",
"name": "HTTP_health_monitor",
"name": "HTTP_healthmonitor",
"provisioning_status": "ACTIVE"
},
"members": [
@ -73,7 +73,7 @@
"healthmonitor": {
"type": "HTTP",
"id": "0b608787-ea2d-48c7-89a1-8b8c24fa3b17",
"name": "HTTP_health_monitor",
"name": "HTTP_healthmonitor",
"provisioning_status": "ACTIVE"
},
"members": [

View File

@ -40,7 +40,8 @@ class SessionPersistencePUT(types.BaseType):
class BasePoolType(types.BaseType):
_type_to_model_map = {'admin_state_up': 'enabled'}
_type_to_model_map = {'admin_state_up': 'enabled',
'healthmonitor': 'health_monitor'}
class PoolResponse(BasePoolType):
@ -59,7 +60,7 @@ class PoolResponse(BasePoolType):
listeners = wtypes.wsattr([types.IdOnlyType])
created_at = wtypes.wsattr(wtypes.datetime.datetime)
updated_at = wtypes.wsattr(wtypes.datetime.datetime)
health_monitor_id = wtypes.wsattr(wtypes.UuidType())
healthmonitor_id = wtypes.wsattr(wtypes.UuidType())
members = wtypes.wsattr([types.IdOnlyType])
@classmethod
@ -74,8 +75,8 @@ class PoolResponse(BasePoolType):
if cls._full_response():
del pool.loadbalancers
member_model = member.MemberFullResponse
if pool.health_monitor:
pool.health_monitor = (
if pool.healthmonitor:
pool.healthmonitor = (
health_monitor.HealthMonitorFullResponse
.from_data_model(data_model.health_monitor))
else:
@ -85,6 +86,8 @@ class PoolResponse(BasePoolType):
else:
pool.loadbalancers = []
member_model = types.IdOnlyType
if data_model.health_monitor:
pool.healthmonitor_id = data_model.health_monitor.id
pool.listeners = [
types.IdOnlyType.from_data_model(i) for i in data_model.listeners]
@ -100,7 +103,7 @@ class PoolFullResponse(PoolResponse):
return True
members = wtypes.wsattr([member.MemberFullResponse])
health_monitor = wtypes.wsattr(health_monitor.HealthMonitorFullResponse)
healthmonitor = wtypes.wsattr(health_monitor.HealthMonitorFullResponse)
class PoolRootResponse(types.BaseType):
@ -127,7 +130,7 @@ class PoolPOST(BasePoolType):
session_persistence = wtypes.wsattr(SessionPersistencePOST)
# TODO(johnsom) Remove after deprecation (R series)
project_id = wtypes.wsattr(wtypes.StringType(max_length=36))
health_monitor = wtypes.wsattr(health_monitor.HealthMonitorSingleCreate)
healthmonitor = wtypes.wsattr(health_monitor.HealthMonitorSingleCreate)
members = wtypes.wsattr([member.MemberSingleCreate])
@ -158,5 +161,5 @@ class PoolSingleCreate(BasePoolType):
lb_algorithm = wtypes.wsattr(
wtypes.Enum(str, *constants.SUPPORTED_LB_ALGORITHMS))
session_persistence = wtypes.wsattr(SessionPersistencePOST)
health_monitor = wtypes.wsattr(health_monitor.HealthMonitorSingleCreate)
healthmonitor = wtypes.wsattr(health_monitor.HealthMonitorSingleCreate)
members = wtypes.wsattr([member.MemberSingleCreate])

View File

@ -385,6 +385,15 @@ class TestHealthMonitor(base.BaseAPITest):
self.assertEqual('/', api_hm.get('url_path'))
self.assertEqual('200', api_hm.get('expected_codes'))
def test_pool_returns_hm_id(self):
api_hm = self.create_health_monitor(
self.pool_id, constants.HEALTH_MONITOR_HTTP,
1, 1, 1, 1).get(self.root_tag)
self.set_lb_status(self.lb_id)
pool = self.get(self.POOL_PATH.format(
pool_id=self.pool_id)).json.get("pool")
self.assertEqual(pool.get('healthmonitor_id'), api_hm.get('id'))
# TODO(rm_work) Remove after deprecation of project_id in POST (R series)
def test_create_with_project_id_is_ignored(self):
pid = uuidutils.generate_uuid()

View File

@ -834,7 +834,7 @@ class TestLoadBalancerGraph(base.BaseAPITest):
if create_members:
create_pool['members'] = create_members
if create_hm:
create_pool['health_monitor'] = create_hm
create_pool['healthmonitor'] = create_hm
expected_pool = {
'description': None,
'session_persistence': None,
@ -848,7 +848,7 @@ class TestLoadBalancerGraph(base.BaseAPITest):
if expected_members:
expected_pool['members'] = expected_members
if expected_hm:
expected_pool['health_monitor'] = expected_hm
expected_pool['healthmonitor'] = expected_hm
return create_pool, expected_pool
def _get_member_bodies(self, protocol_port=80):