Add formatting of output data
Show records on seperate lines when doing show / commands on recordsets. Remove resource['link'] Change-Id: I93e5e7c382d0b97c37b8e4b6c8cfad94488290ba
This commit is contained in:
parent
9803b87a31
commit
32ead48dc8
@ -26,6 +26,11 @@ from designateclient import utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _format_blacklist(blacklist):
|
||||
# Remove unneeded fields for display output formatting
|
||||
blacklist.pop('links', None)
|
||||
|
||||
|
||||
class ListBlacklistsCommand(lister.Lister):
|
||||
"""List blacklists"""
|
||||
|
||||
@ -52,6 +57,7 @@ class ShowBlacklistCommand(show.ShowOne):
|
||||
def take_action(self, parsed_args):
|
||||
client = self.app.client_manager.dns
|
||||
data = client.blacklists.get(parsed_args.id)
|
||||
_format_blacklist(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -73,6 +79,7 @@ class CreateBlacklistCommand(show.ShowOne):
|
||||
data = client.blacklists.create(
|
||||
parsed_args.pattern, parsed_args.description)
|
||||
|
||||
_format_blacklist(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -106,6 +113,7 @@ class SetBlacklistCommand(show.ShowOne):
|
||||
|
||||
updated = client.blacklists.update(parsed_args.id, data)
|
||||
|
||||
_format_blacklist(updated)
|
||||
return zip(*sorted(six.iteritems(updated)))
|
||||
|
||||
|
||||
|
@ -26,6 +26,12 @@ from designateclient import utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _format_recordset(recordset):
|
||||
# Remove unneeded fields for display output formatting
|
||||
recordset['records'] = "\n".join(recordset['records'])
|
||||
recordset.pop('links', None)
|
||||
|
||||
|
||||
class ListRecordSetsCommand(lister.Lister):
|
||||
"""List recordsets"""
|
||||
|
||||
@ -43,6 +49,8 @@ class ListRecordSetsCommand(lister.Lister):
|
||||
|
||||
cols = self.columns
|
||||
data = client.recordsets.list(parsed_args.zone_id)
|
||||
|
||||
map(_format_recordset, data)
|
||||
return cols, (utils.get_item_properties(s, cols) for s in data)
|
||||
|
||||
|
||||
@ -60,6 +68,8 @@ class ShowRecordSetCommand(show.ShowOne):
|
||||
def take_action(self, parsed_args):
|
||||
client = self.app.client_manager.dns
|
||||
data = client.recordsets.get(parsed_args.zone_id, parsed_args.id)
|
||||
|
||||
_format_recordset(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -90,6 +100,7 @@ class CreateRecordSetCommand(show.ShowOne):
|
||||
description=parsed_args.description,
|
||||
ttl=parsed_args.ttl)
|
||||
|
||||
_format_recordset(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -140,6 +151,8 @@ class SetRecordSetCommand(show.ShowOne):
|
||||
parsed_args.id,
|
||||
data)
|
||||
|
||||
_format_recordset(updated)
|
||||
|
||||
return zip(*sorted(six.iteritems(updated)))
|
||||
|
||||
|
||||
|
@ -26,6 +26,11 @@ from designateclient import utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _format_floatingip(fip):
|
||||
# Remove unneeded fields for display output formatting
|
||||
fip.pop('links', None)
|
||||
|
||||
|
||||
class ListFloatingIPCommand(lister.Lister):
|
||||
"""List floatingip ptr records"""
|
||||
|
||||
@ -52,6 +57,7 @@ class ShowFloatingIPCommand(show.ShowOne):
|
||||
def take_action(self, parsed_args):
|
||||
client = self.app.client_manager.dns
|
||||
data = client.floatingips.get(parsed_args.floatingip_id)
|
||||
_format_floatingip(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -95,6 +101,7 @@ class SetFloatingIPCommand(show.ShowOne):
|
||||
parsed_args.description,
|
||||
parsed_args.ttl)
|
||||
|
||||
_format_floatingip(fip)
|
||||
return zip(*sorted(six.iteritems(fip)))
|
||||
|
||||
|
||||
|
@ -26,6 +26,11 @@ from designateclient import utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _format_tld(tld):
|
||||
# Remove unneeded fields for display output formatting
|
||||
tld.pop('links', None)
|
||||
|
||||
|
||||
class ListTLDsCommand(lister.Lister):
|
||||
"""List tlds"""
|
||||
|
||||
@ -53,6 +58,7 @@ class ShowTLDCommand(show.ShowOne):
|
||||
def take_action(self, parsed_args):
|
||||
client = self.app.client_manager.dns
|
||||
data = client.tlds.get(parsed_args.id)
|
||||
_format_tld(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -70,6 +76,7 @@ class CreateTLDCommand(show.ShowOne):
|
||||
def take_action(self, parsed_args):
|
||||
client = self.app.client_manager.dns
|
||||
data = client.tlds.create(parsed_args.name, parsed_args.description)
|
||||
_format_tld(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -101,6 +108,7 @@ class SetTLDCommand(show.ShowOne):
|
||||
client = self.app.client_manager.dns
|
||||
|
||||
data = client.tlds.update(parsed_args.id, data)
|
||||
_format_tld(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
|
@ -27,6 +27,11 @@ from designateclient import utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _format_zone(zone):
|
||||
zone.pop('links', None)
|
||||
zone['masters'] = ", ".join(zone['masters'])
|
||||
|
||||
|
||||
class ListZonesCommand(lister.Lister):
|
||||
"""List zones"""
|
||||
|
||||
@ -67,6 +72,7 @@ class ShowZoneCommand(show.ShowOne):
|
||||
|
||||
data = client.zones.get(parsed_args.id)
|
||||
|
||||
_format_zone(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -113,6 +119,8 @@ class CreateZoneCommand(show.ShowOne):
|
||||
|
||||
data = client.zones.create(
|
||||
parsed_args.name, parsed_args.type, **payload)
|
||||
|
||||
_format_zone(data)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
|
||||
|
||||
@ -158,6 +166,7 @@ class SetZoneCommand(show.ShowOne):
|
||||
data['masters'] = parsed_args.masters
|
||||
|
||||
updated = client.zones.update(parsed_args.id, data)
|
||||
_format_zone(updated)
|
||||
return zip(*sorted(six.iteritems(updated)))
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user