def _pdns_delete(url):
# We first delete the zone from nslord, the main authoritative source of our DNS data.
# However, we do not want to wait for the zone to expire on the slave ("nsmaster").
# We thus issue a second delete request on nsmaster to delete the zone there immediately.
r1 = requests.delete(settings.NSLORD_PDNS_API + url, headers=headers_nslord)
if r1.status_code < 200 or r1.status_code >= 300:
# Deletion technically does not fail if the zone didn't exist in the first place
if r1.status_code == 422 and 'Could not find domain' in r1.text:
pass
else:
raise PdnsException(r1)
# Delete from nsmaster as well
r2 = requests.delete(settings.NSMASTER_PDNS_API + url, headers=headers_nsmaster)
if r2.status_code < 200 or r2.status_code >= 300:
# Deletion technically does not fail if the zone didn't exist in the first place
if r2.status_code == 422 and 'Could not find domain' in r2.text:
pass
else:
raise PdnsException(r2)
return (r1, r2)
评论列表
文章目录