Merge "Add a new column and a new option the 'os port list' cmd"
This commit is contained in:
commit
fd60e579c8
@ -117,6 +117,7 @@ List ports
|
|||||||
[--device-owner <device-owner>]
|
[--device-owner <device-owner>]
|
||||||
[--router <router> | --server <server>]
|
[--router <router> | --server <server>]
|
||||||
[--network <network>]
|
[--network <network>]
|
||||||
|
[--long]
|
||||||
|
|
||||||
.. option:: --device-owner <device-owner>
|
.. option:: --device-owner <device-owner>
|
||||||
|
|
||||||
@ -135,6 +136,10 @@ List ports
|
|||||||
|
|
||||||
List only ports attached to this network (name or ID)
|
List only ports attached to this network (name or ID)
|
||||||
|
|
||||||
|
.. option:: --long
|
||||||
|
|
||||||
|
List additional fields in output
|
||||||
|
|
||||||
port set
|
port set
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -360,6 +360,12 @@ 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)"),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--long',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help=_("List additional fields in output")
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -371,15 +377,20 @@ class ListPort(command.Lister):
|
|||||||
'name',
|
'name',
|
||||||
'mac_address',
|
'mac_address',
|
||||||
'fixed_ips',
|
'fixed_ips',
|
||||||
|
'status',
|
||||||
)
|
)
|
||||||
column_headers = (
|
column_headers = (
|
||||||
'ID',
|
'ID',
|
||||||
'Name',
|
'Name',
|
||||||
'MAC Address',
|
'MAC Address',
|
||||||
'Fixed IP Addresses',
|
'Fixed IP Addresses',
|
||||||
|
'Status',
|
||||||
)
|
)
|
||||||
|
|
||||||
filters = {}
|
filters = {}
|
||||||
|
if parsed_args.long:
|
||||||
|
columns += ('security_groups', 'device_owner',)
|
||||||
|
column_headers += ('Security Groups', 'Device Owner',)
|
||||||
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.router:
|
if parsed_args.router:
|
||||||
|
@ -317,6 +317,17 @@ class TestListPort(TestPort):
|
|||||||
'Name',
|
'Name',
|
||||||
'MAC Address',
|
'MAC Address',
|
||||||
'Fixed IP Addresses',
|
'Fixed IP Addresses',
|
||||||
|
'Status',
|
||||||
|
)
|
||||||
|
|
||||||
|
columns_long = (
|
||||||
|
'ID',
|
||||||
|
'Name',
|
||||||
|
'MAC Address',
|
||||||
|
'Fixed IP Addresses',
|
||||||
|
'Status',
|
||||||
|
'Security Groups',
|
||||||
|
'Device Owner',
|
||||||
)
|
)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
@ -326,6 +337,19 @@ class TestListPort(TestPort):
|
|||||||
prt.name,
|
prt.name,
|
||||||
prt.mac_address,
|
prt.mac_address,
|
||||||
utils.format_list_of_dicts(prt.fixed_ips),
|
utils.format_list_of_dicts(prt.fixed_ips),
|
||||||
|
prt.status,
|
||||||
|
))
|
||||||
|
|
||||||
|
data_long = []
|
||||||
|
for prt in _ports:
|
||||||
|
data_long.append((
|
||||||
|
prt.id,
|
||||||
|
prt.name,
|
||||||
|
prt.mac_address,
|
||||||
|
utils.format_list_of_dicts(prt.fixed_ips),
|
||||||
|
prt.status,
|
||||||
|
utils.format_list(prt.security_groups),
|
||||||
|
prt.device_owner,
|
||||||
))
|
))
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -439,6 +463,23 @@ 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_list_port_with_long(self):
|
||||||
|
arglist = [
|
||||||
|
'--long',
|
||||||
|
]
|
||||||
|
|
||||||
|
verifylist = [
|
||||||
|
('long', True),
|
||||||
|
]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.network.ports.assert_called_once_with()
|
||||||
|
self.assertEqual(self.columns_long, columns)
|
||||||
|
self.assertEqual(self.data_long, list(data))
|
||||||
|
|
||||||
|
|
||||||
class TestSetPort(TestPort):
|
class TestSetPort(TestPort):
|
||||||
|
|
||||||
|
7
releasenotes/notes/bug-1613995-10bb3895d702c063.yaml
Normal file
7
releasenotes/notes/bug-1613995-10bb3895d702c063.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add a new column ``status`` and ``--long`` option to the result of the
|
||||||
|
``os port list`` command.
|
||||||
|
[Bug `1613995 <https://bugs.launchpad.net/bugs/1613995>`_]
|
||||||
|
[Bug `1614321 <https://bugs.launchpad.net/bugs/1614321>`_]
|
Loading…
Reference in New Issue
Block a user