Browse Source

List l7poclies by listener

Sample CLI:
openstack loadbalancer l7policy list --listener <Name or ID>

Story: 2006617
Task: 36820

Change-Id: Ie02b5a4bbec7243806a0a9523897dd82e6737482
changes/24/684924/3
Lingxian Kong 2 years ago
parent
commit
92a0d4b8ae
3 changed files with 30 additions and 1 deletions
  1. +10
    -1
      octaviaclient/osc/v2/l7policy.py
  2. +17
    -0
      octaviaclient/tests/unit/osc/v2/test_l7policy.py
  3. +3
    -0
      releasenotes/notes/list-l7policies-by-listener-a11322c8e03a11e9.yaml

+ 10
- 1
octaviaclient/osc/v2/l7policy.py View File

@ -153,12 +153,21 @@ class ListL7Policy(lister.Lister):
def get_parser(self, prog_name):
parser = super(ListL7Policy, self).get_parser(prog_name)
parser.add_argument(
'--listener',
help="List l7policies that applied to the given listener "
"(name or ID)."
)
return parser
def take_action(self, parsed_args):
columns = const.L7POLICY_COLUMNS
data = self.app.client_manager.load_balancer.l7policy_list()
attrs = v2_utils.get_l7policy_attrs(self.app.client_manager,
parsed_args)
data = self.app.client_manager.load_balancer.l7policy_list(**attrs)
formatters = {'rules': v2_utils.format_list}
return (columns,


+ 17
- 0
octaviaclient/tests/unit/osc/v2/test_l7policy.py View File

@ -60,6 +60,23 @@ class TestL7PolicyList(TestL7Policy):
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist, tuple(data))
@mock.patch('octaviaclient.osc.v2.utils.get_l7policy_attrs')
def test_l7policy_list_by_listener(self, mock_l7policy_attrs):
mock_l7policy_attrs.return_value = {
'listener_id': self._l7po.listener_id,
}
arglist = ['--listener', 'mock_li_id']
verifylist = [('listener', 'mock_li_id')]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.api_mock.l7policy_list.assert_called_with(
listener_id=self._l7po.listener_id
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist, tuple(data))
class TestL7PolicyDelete(TestL7Policy):


+ 3
- 0
releasenotes/notes/list-l7policies-by-listener-a11322c8e03a11e9.yaml View File

@ -0,0 +1,3 @@
---
features:
- Added support to query l7policies by a given listener using ``--listener``.

Loading…
Cancel
Save