Explorar el Código

fix(api): fix creating domains after user unlock

Peter Thomassen hace 8 años
padre
commit
7ed51f1336
Se han modificado 2 ficheros con 5 adiciones y 15 borrados
  1. 5 2
      api/desecapi/models.py
  2. 0 13
      api/desecapi/pdns.py

+ 5 - 2
api/desecapi/models.py

@@ -153,9 +153,12 @@ class Domain(models.Model, mixins.SetterMixin):
         Re-Syncing is relatively expensive and should not happen routinely.
         """
 
-        # Create zone if needed
-        if not pdns.zone_exists(self):
+        # Create zone if it does not exist yet
+        try:
             pdns.create_zone(self)
+        except pdns.PdnsException as e:
+            if e.status_code == 422 and e.detail.endswith(' already exists'):
+                pass
 
         # update zone to latest information
         pdns.set_dyn_records(self)

+ 0 - 13
api/desecapi/pdns.py

@@ -176,19 +176,6 @@ def set_rrsets(domain, rrsets):
     _pdns_patch('/zones/' + domain.pdns_id, data)
 
 
-def zone_exists(domain):
-    """
-    Returns whether pdns knows a zone with the given name.
-    """
-    r = _pdns_get('/zones/' + domain.pdns_id)
-    if r.status_code == 200:
-        return True
-    elif r.status_code == 422 and 'Could not find domain' in r.text:
-        return False
-    else:
-        raise PdnsException(r)
-
-
 def notify_zone(domain):
     """
     Commands pdns to notify the zone to the pdns slaves.