Add option to filter instances by AZ

Since nova API microversion 2.83 it is possible for users to filter
instances by AZ. However even before that this functionality was available
for admin role.

Change-Id: Ife4c8e81aad2ff1dde50d9f23913d9dd9397b00c
This commit is contained in:
Dmitriy Rabotyagov 2020-12-01 12:44:30 +02:00
parent 8387b114e3
commit 0f02029d91
2 changed files with 9 additions and 0 deletions
openstackclient
compute/v2
tests/unit/compute/v2

@ -1365,6 +1365,13 @@ class ListServer(command.Lister):
def get_parser(self, prog_name):
parser = super(ListServer, self).get_parser(prog_name)
parser.add_argument(
'--availability-zone',
metavar='<availability-zone>',
help=_('Only return instances that match the availability zone. '
'Note that this option will be ignored for non-admin users '
'when using ``--os-compute-api-version`` prior to 2.83.'),
)
parser.add_argument(
'--reservation-id',
metavar='<reservation-id>',
@ -1574,6 +1581,7 @@ class ListServer(command.Lister):
ignore_missing=False).id
search_opts = {
'availability_zone': parsed_args.availability_zone,
'reservation_id': parsed_args.reservation_id,
'ip': parsed_args.ip,
'ip6': parsed_args.ip6,

@ -2962,6 +2962,7 @@ class TestServerList(TestServer):
super(TestServerList, self).setUp()
self.search_opts = {
'availability_zone': None,
'reservation_id': None,
'ip': None,
'ip6': None,