From 0d764cdb5a1f9a8b113721634fcc8948ddd82c8d Mon Sep 17 00:00:00 2001 From: Vishakha Agarwal Date: Fri, 19 Oct 2018 12:29:00 +0530 Subject: [PATCH] Add project param in LimitList parser when doing openstack limit list --project xyz_id, CLI raising error unrecognized arguments, whereas in api-ref document [1], user can pass project_id as query param.This addresses the above issue, by adding param --project in parser of LimitList. [1] https://developer.openstack.org/api-ref/identity/v3/index.html Change-Id: If4644cc99a3803f61f4a688b828aeb73977fc0dd Closes-Bug: #1798744 --- doc/source/cli/command-objects/limit.rst | 5 +++++ openstackclient/identity/v3/limit.py | 13 ++++++++++++- .../tests/unit/identity/v3/test_limit.py | 3 ++- .../notes/bug-1798744-5512256baf4dc633.yaml | 4 ++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bug-1798744-5512256baf4dc633.yaml diff --git a/doc/source/cli/command-objects/limit.rst b/doc/source/cli/command-objects/limit.rst index 71cf2a420d..46da6c1b70 100644 --- a/doc/source/cli/command-objects/limit.rst +++ b/doc/source/cli/command-objects/limit.rst @@ -73,6 +73,7 @@ List project-specific limits [--service ] [--resource-name ] [--region ] + [--project ] .. option:: --service @@ -86,6 +87,10 @@ List project-specific limits The region name to filter the response by +.. option:: --project + + List resource limits associated with project + limit show ---------- diff --git a/openstackclient/identity/v3/limit.py b/openstackclient/identity/v3/limit.py index c6f1cb1fb5..57d1dfd641 100644 --- a/openstackclient/identity/v3/limit.py +++ b/openstackclient/identity/v3/limit.py @@ -116,6 +116,11 @@ class ListLimit(command.Lister): metavar='', help=_('Region for the registered limit to affect.'), ) + parser.add_argument( + '--project', + metavar='', + help=_('List resource limits associated with project'), + ) return parser def take_action(self, parsed_args): @@ -131,11 +136,17 @@ class ListLimit(command.Lister): region = utils.find_resource( identity_client.regions, parsed_args.region ) + project = None + if parsed_args.project: + project = utils.find_resource( + identity_client.projects, parsed_args.project + ) limits = identity_client.limits.list( service=service, resource_name=parsed_args.resource_name, - region=region + region=region, + project=project ) columns = ( diff --git a/openstackclient/tests/unit/identity/v3/test_limit.py b/openstackclient/tests/unit/identity/v3/test_limit.py index 44c0358d89..e5cd87b8bd 100644 --- a/openstackclient/tests/unit/identity/v3/test_limit.py +++ b/openstackclient/tests/unit/identity/v3/test_limit.py @@ -362,7 +362,8 @@ class TestLimitList(TestLimit): columns, data = self.cmd.take_action(parsed_args) self.limit_mock.list.assert_called_with( - service=None, resource_name=None, region=None + service=None, resource_name=None, region=None, + project=None ) collist = ( diff --git a/releasenotes/notes/bug-1798744-5512256baf4dc633.yaml b/releasenotes/notes/bug-1798744-5512256baf4dc633.yaml new file mode 100644 index 0000000000..1dd01ba001 --- /dev/null +++ b/releasenotes/notes/bug-1798744-5512256baf4dc633.yaml @@ -0,0 +1,4 @@ +--- +features: + - Add ``--project`` option to ``limit list`` command. + [Bug `1798744 `_]