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 `_]