Merge "Add limit option to "image list" command"
This commit is contained in:
doc/source/command-objects
openstackclient
releasenotes/notes
@ -167,6 +167,7 @@ List available images
|
|||||||
[--property <key=value>]
|
[--property <key=value>]
|
||||||
[--long]
|
[--long]
|
||||||
[--sort <key>[:<direction>]]
|
[--sort <key>[:<direction>]]
|
||||||
|
[--limit <limit>]
|
||||||
|
|
||||||
.. option:: --public
|
.. option:: --public
|
||||||
|
|
||||||
@ -195,6 +196,10 @@ List available images
|
|||||||
Sort output by selected keys and directions(asc or desc) (default: asc),
|
Sort output by selected keys and directions(asc or desc) (default: asc),
|
||||||
multiple keys and directions can be specified separated by comma
|
multiple keys and directions can be specified separated by comma
|
||||||
|
|
||||||
|
.. option:: --limit <limit>
|
||||||
|
|
||||||
|
Maximum number of images to display.
|
||||||
|
|
||||||
image save
|
image save
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@ -431,6 +431,12 @@ class ListImage(command.Lister):
|
|||||||
"(default: asc), multiple keys and directions can be "
|
"(default: asc), multiple keys and directions can be "
|
||||||
"specified separated by comma",
|
"specified separated by comma",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--limit",
|
||||||
|
metavar="<limit>",
|
||||||
|
type=int,
|
||||||
|
help="Maximum number of images to display.",
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -443,6 +449,8 @@ class ListImage(command.Lister):
|
|||||||
kwargs['private'] = True
|
kwargs['private'] = True
|
||||||
if parsed_args.shared:
|
if parsed_args.shared:
|
||||||
kwargs['shared'] = True
|
kwargs['shared'] = True
|
||||||
|
if parsed_args.limit:
|
||||||
|
kwargs['limit'] = parsed_args.limit
|
||||||
|
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
columns = (
|
columns = (
|
||||||
|
@ -655,6 +655,23 @@ class TestImageList(TestImage):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.datalist, tuple(data))
|
self.assertEqual(self.datalist, tuple(data))
|
||||||
|
|
||||||
|
def test_image_list_limit_option(self):
|
||||||
|
arglist = [
|
||||||
|
'--limit', str(1),
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('limit', 1),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
self.api_mock.image_list.assert_called_with(
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(len(self.datalist), len(tuple(data)))
|
||||||
|
|
||||||
|
|
||||||
class TestRemoveProjectImage(TestImage):
|
class TestRemoveProjectImage(TestImage):
|
||||||
|
|
||||||
|
6
releasenotes/notes/bug-1540988-17841cfd5accf7f5.yaml
Normal file
6
releasenotes/notes/bug-1540988-17841cfd5accf7f5.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``--limit`` option to ``image list`` to limit the number of images
|
||||||
|
in output.
|
||||||
|
[Bug `1540988 <https://bugs.launchpad.net/bugs/1540988>`_]
|
Reference in New Issue
Block a user