Merge "Fix fields translation on filtering"
commit
a52d7c6ef9
|
@ -31,7 +31,8 @@ class BaseLoadBalancerType(types.BaseType):
|
|||
'ip_address': 'vip_address',
|
||||
'subnet_id': 'vip_subnet_id',
|
||||
'port_id': 'vip_port_id',
|
||||
'network_id': 'vip_network_id'}}
|
||||
'network_id': 'vip_network_id',
|
||||
'qos_policy_id': 'vip_qos_policy_id'}}
|
||||
|
||||
|
||||
class LoadBalancerResponse(BaseLoadBalancerType):
|
||||
|
|
|
@ -43,8 +43,10 @@ class SessionPersistencePUT(types.BaseType):
|
|||
|
||||
class BasePoolType(types.BaseType):
|
||||
_type_to_model_map = {'admin_state_up': 'enabled',
|
||||
'healthmonitor': 'health_monitor'}
|
||||
_child_map = {}
|
||||
'healthmonitor': 'health_monitor',
|
||||
'healthmonitor_id': 'health_monitor.id'}
|
||||
|
||||
_child_map = {'health_monitor': {'id': 'healthmonitor_id'}}
|
||||
|
||||
|
||||
class PoolResponse(BasePoolType):
|
||||
|
|
|
@ -113,8 +113,11 @@ class OctaviaBase(models.ModelBase):
|
|||
filters['enabled'])
|
||||
for attr, name_map in model.__v2_wsme__._child_map.items():
|
||||
for k, v in name_map.items():
|
||||
if v in filters:
|
||||
child_map[attr] = {k: filters.pop(v)}
|
||||
if attr in filters and k in filters[attr]:
|
||||
child_map.setdefault(attr, {}).update(
|
||||
{k: filters[attr].pop(k)})
|
||||
filters.pop(attr, None)
|
||||
|
||||
for k, v in model.__v2_wsme__._type_to_model_map.items():
|
||||
if k in filters:
|
||||
translated_filters[v] = filters.pop(k)
|
||||
|
|
|
@ -1096,7 +1096,8 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||
lb1 = self.create_load_balancer(
|
||||
uuidutils.generate_uuid(),
|
||||
name='lb1',
|
||||
project_id=self.project_id).get(self.root_tag)
|
||||
project_id=self.project_id,
|
||||
vip_address='10.0.0.1').get(self.root_tag)
|
||||
self.create_load_balancer(
|
||||
uuidutils.generate_uuid(),
|
||||
name='lb2',
|
||||
|
@ -1106,7 +1107,7 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||
name='lb3',
|
||||
project_id=self.project_id).get(self.root_tag)
|
||||
lbs = self.get(self.LBS_PATH, params={
|
||||
'id': lb1['id']}).json
|
||||
'id': lb1['id'], 'vip_address': lb1['vip_address']}).json
|
||||
self.assertEqual(1, len(lbs['loadbalancers']))
|
||||
self.assertEqual(lb1['id'],
|
||||
lbs['loadbalancers'][0]['id'])
|
||||
|
|
|
@ -510,6 +510,10 @@ class TestPool(base.BaseAPITest):
|
|||
constants.LB_ALGORITHM_ROUND_ROBIN,
|
||||
name='pool1').get(self.root_tag)
|
||||
self.set_lb_status(lb_id=self.lb_id)
|
||||
hm = self.create_health_monitor(po1['id'],
|
||||
constants.HEALTH_MONITOR_HTTP,
|
||||
1, 1, 1, 1).get('healthmonitor')
|
||||
self.set_lb_status(lb_id=self.lb_id)
|
||||
self.create_pool(
|
||||
self.lb_id,
|
||||
constants.PROTOCOL_HTTP,
|
||||
|
@ -524,7 +528,7 @@ class TestPool(base.BaseAPITest):
|
|||
self.set_lb_status(lb_id=self.lb_id)
|
||||
|
||||
pools = self.get(self.POOLS_PATH, params={
|
||||
'id': po1['id']}).json
|
||||
'id': po1['id'], 'healthmonitor_id': hm['id']}).json
|
||||
self.assertEqual(1, len(pools['pools']))
|
||||
self.assertEqual(po1['id'],
|
||||
pools['pools'][0]['id'])
|
||||
|
|
Loading…
Reference in New Issue