mirror of
https://github.com/thegeeklab/corenetworks.git
synced 2024-11-21 21:20:38 +00:00
add a workaround to prevent CNAME creation if a record with the same name already exists
This commit is contained in:
parent
0edfc084d7
commit
6db805d507
@ -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
|
||||
|
@ -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. "
|
||||
|
Loading…
Reference in New Issue
Block a user