diff --git a/nipap/nipap/backend.py b/nipap/nipap/backend.py index f8b309226..365b0ab32 100644 --- a/nipap/nipap/backend.py +++ b/nipap/nipap/backend.py @@ -1335,7 +1335,10 @@ def remove_vrf(self, auth, spec): self.remove_prefix(auth, spec = v6spec, recursive = True) where, params = self._expand_vrf_spec(spec) - sql = "DELETE FROM ip_net_vrf WHERE %s" % where + sql = """LOCK TABLE ip_net_plan IN EXCLUSIVE MODE; +LOCK TABLE ip_net_vrf IN EXCLUSIVE MODE; +LOCK TABLE ip_net_pool IN EXCLUSIVE MODE; +DELETE FROM ip_net_vrf WHERE %s""" % where self._execute(sql, params) # write to audit table @@ -1875,7 +1878,10 @@ def remove_pool(self, auth, spec): pools = self.list_pool(auth, spec) where, params = self._expand_pool_spec(spec) - sql = "DELETE FROM ip_net_pool AS po WHERE %s" % where + sql = """LOCK TABLE ip_net_plan IN EXCLUSIVE MODE; +LOCK TABLE ip_net_vrf IN EXCLUSIVE MODE; +LOCK TABLE ip_net_pool IN EXCLUSIVE MODE; +DELETE FROM ip_net_pool AS po WHERE %s""" % where self._execute(sql, params) # write to audit table @@ -3095,7 +3101,10 @@ def _db_remove_prefix(self, spec, recursive = False): else: where, params = self._expand_prefix_spec(spec) - sql = "DELETE FROM ip_net_plan AS p WHERE %s" % where + sql = """LOCK TABLE ip_net_plan IN EXCLUSIVE MODE; +LOCK TABLE ip_net_vrf IN EXCLUSIVE MODE; +LOCK TABLE ip_net_pool IN EXCLUSIVE MODE; +DELETE FROM ip_net_plan AS p WHERE %s""" % where self._execute(sql, params) @@ -3934,7 +3943,10 @@ def remove_asn(self, auth, asn): # remove where, params = self._expand_asn_spec(asn) - sql = "DELETE FROM ip_net_asn WHERE " + where + sql = """LOCK TABLE ip_net_plan IN EXCLUSIVE MODE; +LOCK TABLE ip_net_vrf IN EXCLUSIVE MODE; +LOCK TABLE ip_net_pool IN EXCLUSIVE MODE; +DELETE FROM ip_net_asn WHERE """ + where self._execute(sql, params) # write to audit table