From eedd4ac142200474520371fbb589be98124bcac8 Mon Sep 17 00:00:00 2001 From: Graham Hayes Date: Wed, 1 Jun 2016 17:38:20 +0100 Subject: [PATCH] Allow cli to query "v2/recordsets" The allows users to list all recordsets in the system. running ``openstack recordset list all`` will show all rrsets Change-Id: Id47961c80484550c99c1834a554afe31165b69ca --- designateclient/v2/cli/recordsets.py | 12 +++++++++--- designateclient/v2/recordsets.py | 6 ++++++ doc/source/shell-v2.rst | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/designateclient/v2/cli/recordsets.py b/designateclient/v2/cli/recordsets.py index 00d93486..55f01c57 100644 --- a/designateclient/v2/cli/recordsets.py +++ b/designateclient/v2/cli/recordsets.py @@ -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) diff --git a/designateclient/v2/recordsets.py b/designateclient/v2/recordsets.py index 5096a69f..188148cc 100644 --- a/designateclient/v2/recordsets.py +++ b/designateclient/v2/recordsets.py @@ -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) diff --git a/doc/source/shell-v2.rst b/doc/source/shell-v2.rst index 1eff928d..482126c3 100644 --- a/doc/source/shell-v2.rst +++ b/doc/source/shell-v2.rst @@ -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