From c135dc7e95980bf18038573959a645a0e48930c8 Mon Sep 17 00:00:00 2001 From: Graham Hayes Date: Tue, 31 Jan 2017 17:14:12 +0000 Subject: [PATCH] Validate NS records on a pool during an update Calls validation on a pool ns_records list during an update. Closes-Bug: #1655042 Change-Id: I53342b9602ebfb6e0c4dffbba3c8cf1d5399787a --- designate/manage/pool.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/designate/manage/pool.py b/designate/manage/pool.py index cdeb1bb9d..431270295 100644 --- a/designate/manage/pool.py +++ b/designate/manage/pool.py @@ -142,6 +142,16 @@ class PoolCommands(base.Commands): pool = DesignateAdapter.parse('YAML', xpool, pool) + # TODO(graham): We should be doing a full validation, but right + # now there is quirks validating through nested objects. + + for ns_record in pool.ns_records: + try: + ns_record.validate() + except exceptions.InvalidObject as e: + LOG.error(e.errors.to_list()[0]['message']) + sys.exit(1) + if dry_run: output_msg.append("Update Pool: %s" % pool) else: @@ -149,7 +159,12 @@ class PoolCommands(base.Commands): except exceptions.PoolNotFound: pool = DesignateAdapter.parse('YAML', xpool, objects.Pool()) - # pool = objects.Pool.from_dict(xpool) + for ns_record in pool.ns_records: + try: + ns_record.validate() + except exceptions.InvalidObject as e: + LOG.error(e.errors.to_list()[0]['message']) + sys.exit(1) if dry_run: output_msg.append("Create Pool: %s" % pool) else: