From c7fb3b36556a6e7622dd7b2bf2ddb5209e518773 Mon Sep 17 00:00:00 2001 From: Richard Theis Date: Wed, 15 Jun 2016 08:53:00 -0500 Subject: Add "--device-owner" option to "port list" Add "--device-owner" option to the "port list" command to enable listing ports based on device owner. Change-Id: I0a538ec41800b9f842e86dceb6ca4180ef239c95 Implements: blueprint neutron-client --- openstackclient/network/v2/port.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'openstackclient/network') diff --git a/openstackclient/network/v2/port.py b/openstackclient/network/v2/port.py index 1c5db706..71dc1083 100644 --- a/openstackclient/network/v2/port.py +++ b/openstackclient/network/v2/port.py @@ -169,7 +169,8 @@ def _add_updatable_args(parser): parser.add_argument( '--device-owner', metavar='', - help=_("Device owner of this port") + help=_("Device owner of this port. This is the entity that uses " + "the port (for example, network:dhcp).") ) parser.add_argument( '--vnic-type', @@ -309,6 +310,13 @@ class ListPort(command.Lister): def get_parser(self, prog_name): parser = super(ListPort, self).get_parser(prog_name) + parser.add_argument( + '--device-owner', + metavar='', + help=_("List only ports with the specified device owner. " + "This is the entity that uses the port (for example, " + "network:dhcp).") + ) parser.add_argument( '--router', metavar='', @@ -334,10 +342,12 @@ class ListPort(command.Lister): ) filters = {} + if parsed_args.device_owner is not None: + filters['device_owner'] = parsed_args.device_owner if parsed_args.router: _router = client.find_router(parsed_args.router, ignore_missing=False) - filters = {'device_id': _router.id} + filters['device_id'] = _router.id data = client.ports(**filters) -- cgit v1.2.1