Merge "Allow cli to query "v2/recordsets""

This commit is contained in:
Jenkins 2016-06-29 16:19:04 +00:00 committed by Gerrit Code Review
commit f5a49f2787
3 changed files with 16 additions and 3 deletions

View File

@ -54,7 +54,8 @@ class ListRecordSetsCommand(lister.Lister):
parser.add_argument('--action', help="RecordSet Action",
required=False)
parser.add_argument('zone_id', help="Zone ID")
parser.add_argument('zone_id', help="Zone ID. To list all"
" recordsets specify 'all'")
return parser
@ -85,8 +86,13 @@ class ListRecordSetsCommand(lister.Lister):
cols = self.columns
data = get_all(client.recordsets.list, args=[parsed_args.zone_id],
criterion=criterion)
if parsed_args.zone_id == 'all':
data = get_all(client.recordsets.list_all_zones,
criterion=criterion)
cols.insert(2, 'zone_name')
else:
data = get_all(client.recordsets.list, args=[parsed_args.zone_id],
criterion=criterion)
for i, rs in enumerate(data):
data[i] = _format_recordset(rs)

View File

@ -74,6 +74,12 @@ class RecordSetController(V2Controller):
return self._get(url, response_key='recordsets')
def list_all_zones(self, criterion=None, marker=None, limit=None):
url = self.build_url('/recordsets', criterion, marker, limit)
return self._get(url, response_key='recordsets')
def get(self, zone, recordset):
zone = v2_utils.resolve_by_name(self.client.zones.list, zone)
recordset = v2_utils.resolve_by_name(self.list, recordset, zone)

View File

@ -96,6 +96,7 @@ zone set Set zone properties
zone delete Delete zone
recordset create Create new recordset
recordset list List recordsets
recordset list all List all recordsets in all zones
recordset show Show recordset details
recordset set Set recordset properties
recordset delete Delete recordset