0
0
mirror of https://github.com/thegeeklab/corenetworks.git synced 2024-11-14 06:40:39 +00:00

add a workaround to prevent CNAME creation if a record with the same name already exists

This commit is contained in:
Robert Kaussow 2020-05-11 18:42:57 +02:00
parent 0edfc084d7
commit 6db805d507
2 changed files with 15 additions and 1 deletions

View File

@ -2,3 +2,4 @@
* make `ttl` mandatory for add function
* 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

View File

@ -205,10 +205,23 @@ class CoreNetworks():
schema["required"] = ["name", "type", "data", "ttl"]
self.__validate(params, schema)
if params["type"] == "CNAME":
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:
raise CorenetworksError(
"A record with the same name already exist ({name}). "
"CNAME records cannot use the same name with other records.".format(
name=r["name"]
)
)
curr = copy.deepcopy(params)
curr.pop("ttl")
records = self.records(zone, curr)
if len(records) > 1:
raise CorenetworksError(
"More than one record already exists for the given attributes. "