File tree Expand file tree Collapse file tree
doc/source/command-objects Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ List ports
117117 [--device-owner <device-owner>]
118118 [--router <router> | --server <server>]
119119 [--network <network>]
120+ [--long]
120121
121122.. option:: --device-owner <device-owner>
122123
@@ -135,6 +136,10 @@ List ports
135136
136137 List only ports attached to this network (name or ID)
137138
139+ .. option:: --long
140+
141+ List additional fields in output
142+
138143port set
139144--------
140145
Original file line number Diff line number Diff line change @@ -360,6 +360,12 @@ def get_parser(self, prog_name):
360360 metavar = '<server>' ,
361361 help = _ ("List only ports attached to this server (name or ID)" ),
362362 )
363+ parser .add_argument (
364+ '--long' ,
365+ action = 'store_true' ,
366+ default = False ,
367+ help = _ ("List additional fields in output" )
368+ )
363369 return parser
364370
365371 def take_action (self , parsed_args ):
@@ -371,15 +377,20 @@ def take_action(self, parsed_args):
371377 'name' ,
372378 'mac_address' ,
373379 'fixed_ips' ,
380+ 'status' ,
374381 )
375382 column_headers = (
376383 'ID' ,
377384 'Name' ,
378385 'MAC Address' ,
379386 'Fixed IP Addresses' ,
387+ 'Status' ,
380388 )
381389
382390 filters = {}
391+ if parsed_args .long :
392+ columns += ('security_groups' , 'device_owner' ,)
393+ column_headers += ('Security Groups' , 'Device Owner' ,)
383394 if parsed_args .device_owner is not None :
384395 filters ['device_owner' ] = parsed_args .device_owner
385396 if parsed_args .router :
Original file line number Diff line number Diff line change @@ -317,6 +317,17 @@ class TestListPort(TestPort):
317317 'Name' ,
318318 'MAC Address' ,
319319 'Fixed IP Addresses' ,
320+ 'Status' ,
321+ )
322+
323+ columns_long = (
324+ 'ID' ,
325+ 'Name' ,
326+ 'MAC Address' ,
327+ 'Fixed IP Addresses' ,
328+ 'Status' ,
329+ 'Security Groups' ,
330+ 'Device Owner' ,
320331 )
321332
322333 data = []
@@ -326,6 +337,19 @@ class TestListPort(TestPort):
326337 prt .name ,
327338 prt .mac_address ,
328339 utils .format_list_of_dicts (prt .fixed_ips ),
340+ prt .status ,
341+ ))
342+
343+ data_long = []
344+ for prt in _ports :
345+ data_long .append ((
346+ prt .id ,
347+ prt .name ,
348+ prt .mac_address ,
349+ utils .format_list_of_dicts (prt .fixed_ips ),
350+ prt .status ,
351+ utils .format_list (prt .security_groups ),
352+ prt .device_owner ,
329353 ))
330354
331355 def setUp (self ):
@@ -439,6 +463,23 @@ def test_port_list_all_opt(self):
439463 self .assertEqual (self .columns , columns )
440464 self .assertEqual (self .data , list (data ))
441465
466+ def test_list_port_with_long (self ):
467+ arglist = [
468+ '--long' ,
469+ ]
470+
471+ verifylist = [
472+ ('long' , True ),
473+ ]
474+
475+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
476+
477+ columns , data = self .cmd .take_action (parsed_args )
478+
479+ self .network .ports .assert_called_once_with ()
480+ self .assertEqual (self .columns_long , columns )
481+ self .assertEqual (self .data_long , list (data ))
482+
442483
443484class TestSetPort (TestPort ):
444485
Original file line number Diff line number Diff line change 1+ ---
2+ features :
3+ - |
4+ Add a new column ``status`` and ``--long`` option to the result of the
5+ ``os port list`` command.
6+ [Bug `1613995 <https://bugs.launchpad.net/bugs/1613995>`_]
7+ [Bug `1614321 <https://bugs.launchpad.net/bugs/1614321>`_]
You can’t perform that action at this time.
0 commit comments