Merge "neutron port-list -f csv outputs poorly formatted JSON strings"
This commit is contained in:
@@ -663,6 +663,14 @@ class ListCommand(NeutronCommand, lister.Lister):
|
|||||||
return (_columns, (utils.get_item_properties(
|
return (_columns, (utils.get_item_properties(
|
||||||
s, _columns, formatters=self._formatters, )
|
s, _columns, formatters=self._formatters, )
|
||||||
for s in info), )
|
for s in info), )
|
||||||
|
if parsed_args.formatter == 'csv':
|
||||||
|
return (_columns, (utils.get_item_properties(
|
||||||
|
s, _columns, formatters=self._formatters_csv)
|
||||||
|
for s in info),)
|
||||||
|
else:
|
||||||
|
return (_columns, (utils.get_item_properties(
|
||||||
|
s, _columns, formatters=self._formatters)
|
||||||
|
for s in info),)
|
||||||
|
|
||||||
def get_data(self, parsed_args):
|
def get_data(self, parsed_args):
|
||||||
self.log.debug('get_data(%s)', parsed_args)
|
self.log.debug('get_data(%s)', parsed_args)
|
||||||
|
@@ -31,11 +31,19 @@ def _format_fixed_ips(port):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
def _format_fixed_ips_csv(port):
|
||||||
|
try:
|
||||||
|
return [utils.dumps(ip) for ip in port['fixed_ips']]
|
||||||
|
except Exception:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class ListPort(neutronV20.ListCommand):
|
class ListPort(neutronV20.ListCommand):
|
||||||
"""List ports that belong to a given tenant."""
|
"""List ports that belong to a given tenant."""
|
||||||
|
|
||||||
resource = 'port'
|
resource = 'port'
|
||||||
_formatters = {'fixed_ips': _format_fixed_ips, }
|
_formatters = {'fixed_ips': _format_fixed_ips, }
|
||||||
|
_formatters_csv = {'fixed_ips': _format_fixed_ips_csv, }
|
||||||
list_columns = ['id', 'name', 'mac_address', 'fixed_ips']
|
list_columns = ['id', 'name', 'mac_address', 'fixed_ips']
|
||||||
pagination_support = True
|
pagination_support = True
|
||||||
sorting_support = True
|
sorting_support = True
|
||||||
|
Reference in New Issue
Block a user