From a332423c4584f9939a4c18f3fc3026e18443e778 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 11 May 2020 22:23:13 +0200 Subject: [PATCH] ensure CNAME records could not mixed with other types using the same name --- CHANGELOG.md | 6 +----- corenetworks/client.py | 5 +++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa6321d..c0c6dd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,2 @@ -* ENHANCEMENT - * make `ttl` mandatory for add function - * add `requests` to requirements * BUGFIX - * update (delete + create) records with different `ttl` to prevent duplicate entries - * add a workaround to prevent CNAME creation if a record with the same name already exists + * extend the workaround to ensure CNAME records could not mixed with other types using the same name diff --git a/corenetworks/client.py b/corenetworks/client.py index d21db8c..5bc702f 100644 --- a/corenetworks/client.py +++ b/corenetworks/client.py @@ -209,8 +209,9 @@ class CoreNetworks(): if params["name"] == "@": raise CorenetworksError("CNAME records are not allowed for the zone itself.") - records = self.records(zone, params={"name": params["name"]}) - for r in records: + records = self.records(zone, params={"name": params["name"]}) + for r in records: + if params["type"] == "CNAME" or r["type"] == "CNAME": raise CorenetworksError( "A record with the same name already exist ({name}). " "CNAME records cannot use the same name with other records.".format(