From b36b477e8106978669f653e4721ff023006772c6 Mon Sep 17 00:00:00 2001 From: Tang Chen Date: Tue, 17 Nov 2015 21:41:47 +0800 Subject: [PATCH] Add --marker option to "server list" command. This option will give user a chance to display the server list from wherever they want. Change-Id: I92cca5e98cd473f1113a9106eb9d1f490694b1fe --- doc/source/command-objects/server.rst | 6 ++++++ openstackclient/compute/v2/server.py | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/source/command-objects/server.rst b/doc/source/command-objects/server.rst index 6ae4d2543d..41d484ee97 100644 --- a/doc/source/command-objects/server.rst +++ b/doc/source/command-objects/server.rst @@ -187,6 +187,7 @@ List servers [--all-projects] [--project [--project-domain ]] [--long] + [--marker ] .. option:: --reservation-id @@ -250,6 +251,11 @@ List servers List additional fields in output +.. option:: --marker + + The last server (name or ID) of the previous page. Display list of servers + after marker. Display all servers if not specified. + server lock ----------- diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index 875b9a137d..2e5cd99ce2 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -747,6 +747,14 @@ class ListServer(lister.Lister): default=False, help=_('List additional fields in output'), ) + parser.add_argument( + '--marker', + metavar='', + default=None, + help=('The last server (name or ID) of the previous page. Display' + ' list of servers after marker. Display all servers if not' + ' specified.') + ) return parser @utils.log_method(log) @@ -830,7 +838,14 @@ class ListServer(lister.Lister): 'Networks', ) mixed_case_fields = [] - data = compute_client.servers.list(search_opts=search_opts) + + marker_id = None + if parsed_args.marker: + marker_id = utils.find_resource(compute_client.servers, + parsed_args.marker).id + + data = compute_client.servers.list(search_opts=search_opts, + marker=marker_id) return (column_headers, (utils.get_item_properties( s, columns,