From ab59666a18c219ca7dc48eb950d36abc32f39d4c Mon Sep 17 00:00:00 2001 From: Evgeny Fedoruk Date: Mon, 6 Jun 2016 06:05:29 -0700 Subject: [PATCH] Add missing "listener_id" attribute to L7 policy Adding missing "listener_id" attribute to the L7 policy resource. Updating unit tests. Change-Id: I1e7a173642f87851c35dd8b644d1f06653d7776a Closes-Bug: 1587901 --- neutron_lbaas/services/loadbalancer/data_models.py | 2 +- .../tests/unit/db/loadbalancer/test_db_loadbalancerv2.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/neutron_lbaas/services/loadbalancer/data_models.py b/neutron_lbaas/services/loadbalancer/data_models.py index e760f81f1..963dfc4ca 100644 --- a/neutron_lbaas/services/loadbalancer/data_models.py +++ b/neutron_lbaas/services/loadbalancer/data_models.py @@ -603,7 +603,7 @@ class L7Policy(BaseDataModel): def to_api_dict(self): ret_dict = super(L7Policy, self).to_dict( - listener=False, listener_id=False, + listener=False, listener_id=True, provisioning_status=False, redirect_pool=False) ret_dict['listeners'] = [] if self.listener: diff --git a/neutron_lbaas/tests/unit/db/loadbalancer/test_db_loadbalancerv2.py b/neutron_lbaas/tests/unit/db/loadbalancer/test_db_loadbalancerv2.py index 50350702c..6a6bbcb10 100755 --- a/neutron_lbaas/tests/unit/db/loadbalancer/test_db_loadbalancerv2.py +++ b/neutron_lbaas/tests/unit/db/loadbalancer/test_db_loadbalancerv2.py @@ -1051,7 +1051,7 @@ class TestLoadBalancerGraphCreation(LbaasPluginDbTestCase): self.assertEqual(expected_graph, actual) for observed_listener in observed_listeners: self.assertTrue(observed_listener.get('id')) - observed_listener.pop('id') + listener_id = observed_listener.pop('id') default_pool = observed_listener.get('default_pool') l7_policies = observed_listener.get('l7policies') if default_pool: @@ -1067,7 +1067,10 @@ class TestLoadBalancerGraphCreation(LbaasPluginDbTestCase): if l7_policies: for policy in l7_policies: self.assertTrue(policy.get('id')) + self.assertTrue(policy.get('listener_id')) + self.assertEqual(listener_id, policy.get('listener_id')) policy.pop('id') + policy.pop('listener_id') r_pool = policy.get('redirect_pool') rules = policy.get('rules') if r_pool: @@ -2353,6 +2356,7 @@ class LbaasL7Tests(ListenerTestBase): with self.listener(loadbalancer_id=self.lb_id) as listener: listener_id = listener['listener']['id'] + expected['listener_id'] = listener_id with self.l7policy(listener_id, name="0") as p: req = self.new_show_request('l7policies', p['l7policy']['id'],