Allow ports filtering with device_id
Right now, if a neutron port is owned by a container powered by Kuryr, there is no way to list and filter those ports because OSC assumed a neutron port is owned by either a server or router. This patch adds support for that by introducing an option '--device-id' to the 'port list' command. Change-Id: Ib1fd27e8d843a99fb02ccabd8a12a24ac27cec9c
This commit is contained in:
parent
b13a323128
commit
5fdd0730c8
@ -170,7 +170,7 @@ List ports
|
|||||||
|
|
||||||
openstack port list
|
openstack port list
|
||||||
[--device-owner <device-owner>]
|
[--device-owner <device-owner>]
|
||||||
[--router <router> | --server <server>]
|
[--router <router> | --server <server> | --device-id <device-id>]
|
||||||
[--network <network>]
|
[--network <network>]
|
||||||
[--mac-address <mac-address>]
|
[--mac-address <mac-address>]
|
||||||
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
|
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
|
||||||
@ -192,6 +192,10 @@ List ports
|
|||||||
|
|
||||||
List only ports attached to this server (name or ID)
|
List only ports attached to this server (name or ID)
|
||||||
|
|
||||||
|
.. option:: --device-id <device-id>
|
||||||
|
|
||||||
|
List only ports with the specified device ID
|
||||||
|
|
||||||
.. option:: --network <network>
|
.. option:: --network <network>
|
||||||
|
|
||||||
List only ports attached to this network (name or ID)
|
List only ports attached to this network (name or ID)
|
||||||
|
@ -499,6 +499,11 @@ class ListPort(command.Lister):
|
|||||||
metavar='<server>',
|
metavar='<server>',
|
||||||
help=_("List only ports attached to this server (name or ID)"),
|
help=_("List only ports attached to this server (name or ID)"),
|
||||||
)
|
)
|
||||||
|
device_group.add_argument(
|
||||||
|
'--device-id',
|
||||||
|
metavar='<device-id>',
|
||||||
|
help=_("List only ports with the specified device ID")
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--mac-address',
|
'--mac-address',
|
||||||
metavar='<mac-address>',
|
metavar='<mac-address>',
|
||||||
@ -553,6 +558,8 @@ class ListPort(command.Lister):
|
|||||||
column_headers += ('Security Groups', 'Device Owner', 'Tags')
|
column_headers += ('Security Groups', 'Device Owner', 'Tags')
|
||||||
if parsed_args.device_owner is not None:
|
if parsed_args.device_owner is not None:
|
||||||
filters['device_owner'] = parsed_args.device_owner
|
filters['device_owner'] = parsed_args.device_owner
|
||||||
|
if parsed_args.device_id is not None:
|
||||||
|
filters['device_id'] = parsed_args.device_id
|
||||||
if parsed_args.router:
|
if parsed_args.router:
|
||||||
_router = network_client.find_router(parsed_args.router,
|
_router = network_client.find_router(parsed_args.router,
|
||||||
ignore_missing=False)
|
ignore_missing=False)
|
||||||
|
@ -759,6 +759,25 @@ class TestListPort(TestPort):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, list(data))
|
self.assertEqual(self.data, list(data))
|
||||||
|
|
||||||
|
def test_port_list_device_id_opt(self):
|
||||||
|
arglist = [
|
||||||
|
'--device-id', self._ports[0].device_id,
|
||||||
|
]
|
||||||
|
|
||||||
|
verifylist = [
|
||||||
|
('device_id', self._ports[0].device_id)
|
||||||
|
]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.network.ports.assert_called_once_with(**{
|
||||||
|
'device_id': self._ports[0].device_id
|
||||||
|
})
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, list(data))
|
||||||
|
|
||||||
def test_port_list_device_owner_opt(self):
|
def test_port_list_device_owner_opt(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--device-owner', self._ports[0].device_owner,
|
'--device-owner', self._ports[0].device_owner,
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``--device-id`` option to the ``port list`` command.
|
Loading…
Reference in New Issue
Block a user