Merge "Add "--device-owner" option to "port list""
This commit is contained in:
commit
4b61efe3f9
@ -45,7 +45,8 @@ Create new port
|
|||||||
|
|
||||||
.. option:: --device-owner <device-owner>
|
.. option:: --device-owner <device-owner>
|
||||||
|
|
||||||
Device owner of this port
|
Device owner of this port. This is the entity that uses
|
||||||
|
the port (for example, network:dhcp).
|
||||||
|
|
||||||
.. option:: --vnic-type <vnic-type>
|
.. option:: --vnic-type <vnic-type>
|
||||||
|
|
||||||
@ -113,8 +114,14 @@ List ports
|
|||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
os port list
|
os port list
|
||||||
|
[--device-owner <device-owner>]
|
||||||
[--router <router>]
|
[--router <router>]
|
||||||
|
|
||||||
|
.. option:: --device-owner <device-owner>
|
||||||
|
|
||||||
|
List only ports with the specified device owner. This is
|
||||||
|
the entity that uses the port (for example, network:dhcp).
|
||||||
|
|
||||||
.. option:: --router <router>
|
.. option:: --router <router>
|
||||||
|
|
||||||
List only ports attached to this router (name or ID)
|
List only ports attached to this router (name or ID)
|
||||||
@ -154,7 +161,8 @@ Set port properties
|
|||||||
|
|
||||||
.. option:: --device-owner <device-owner>
|
.. option:: --device-owner <device-owner>
|
||||||
|
|
||||||
Device owner of this port
|
Device owner of this port. This is the entity that uses
|
||||||
|
the port (for example, network:dhcp).
|
||||||
|
|
||||||
.. option:: --vnic-type <vnic-type>
|
.. option:: --vnic-type <vnic-type>
|
||||||
|
|
||||||
|
@ -196,7 +196,8 @@ def _add_updatable_args(parser):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--device-owner',
|
'--device-owner',
|
||||||
metavar='<device-owner>',
|
metavar='<device-owner>',
|
||||||
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(
|
parser.add_argument(
|
||||||
'--vnic-type',
|
'--vnic-type',
|
||||||
@ -336,6 +337,13 @@ class ListPort(command.Lister):
|
|||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(ListPort, self).get_parser(prog_name)
|
parser = super(ListPort, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
'--device-owner',
|
||||||
|
metavar='<device-owner>',
|
||||||
|
help=_("List only ports with the specified device owner. "
|
||||||
|
"This is the entity that uses the port (for example, "
|
||||||
|
"network:dhcp).")
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--router',
|
'--router',
|
||||||
metavar='<router>',
|
metavar='<router>',
|
||||||
@ -361,10 +369,12 @@ class ListPort(command.Lister):
|
|||||||
)
|
)
|
||||||
|
|
||||||
filters = {}
|
filters = {}
|
||||||
|
if parsed_args.device_owner is not None:
|
||||||
|
filters['device_owner'] = parsed_args.device_owner
|
||||||
if parsed_args.router:
|
if parsed_args.router:
|
||||||
_router = client.find_router(parsed_args.router,
|
_router = client.find_router(parsed_args.router,
|
||||||
ignore_missing=False)
|
ignore_missing=False)
|
||||||
filters = {'device_id': _router.id}
|
filters['device_id'] = _router.id
|
||||||
|
|
||||||
data = client.ports(**filters)
|
data = client.ports(**filters)
|
||||||
|
|
||||||
|
@ -369,6 +369,47 @@ 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_owner_opt(self):
|
||||||
|
arglist = [
|
||||||
|
'--device-owner', self._ports[0].device_owner,
|
||||||
|
]
|
||||||
|
|
||||||
|
verifylist = [
|
||||||
|
('device_owner', self._ports[0].device_owner)
|
||||||
|
]
|
||||||
|
|
||||||
|
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_owner': self._ports[0].device_owner
|
||||||
|
})
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, list(data))
|
||||||
|
|
||||||
|
def test_port_list_all_opt(self):
|
||||||
|
arglist = [
|
||||||
|
'--device-owner', self._ports[0].device_owner,
|
||||||
|
'--router', 'fake-router-name',
|
||||||
|
]
|
||||||
|
|
||||||
|
verifylist = [
|
||||||
|
('device_owner', self._ports[0].device_owner),
|
||||||
|
('router', 'fake-router-name')
|
||||||
|
]
|
||||||
|
|
||||||
|
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_owner': self._ports[0].device_owner,
|
||||||
|
'device_id': 'fake-router-id'
|
||||||
|
})
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, list(data))
|
||||||
|
|
||||||
|
|
||||||
class TestSetPort(TestPort):
|
class TestSetPort(TestPort):
|
||||||
|
|
||||||
|
@ -7,3 +7,6 @@ features:
|
|||||||
- Add ``geneve`` choice to the ``network create`` command
|
- Add ``geneve`` choice to the ``network create`` command
|
||||||
``--provider-network-type`` option.
|
``--provider-network-type`` option.
|
||||||
[Blueprint :oscbp:`neutron-client`]
|
[Blueprint :oscbp:`neutron-client`]
|
||||||
|
- Add ``--device-owner`` option to the ``port list`` command
|
||||||
|
to enable listing ports based on device owner.
|
||||||
|
[Blueprint :oscbp:`neutron-client`]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user