summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2018-01-31 11:52:34 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-02-08 04:58:10 +0100
commitd82687e77fc8467fb7a2c845220dde1f90fd30bf (patch)
treebe6e92e64babd27922746a42d03d12e02a03f850 /python
parent178f86848d15b0a1b59e8a4535649f264a0d12c4 (diff)
downloadsamba-d82687e77fc8467fb7a2c845220dde1f90fd30bf.tar.gz
remove_dc: Allow remove_dns_references to ignore missing server names
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/dns.py3
-rw-r--r--python/samba/remove_dc.py14
2 files changed, 14 insertions, 3 deletions
diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py
index 5a5bd14757d..04c3d8bf2d1 100644
--- a/python/samba/netcmd/dns.py
+++ b/python/samba/netcmd/dns.py
@@ -1111,7 +1111,8 @@ class cmd_cleanup_record(Command):
session_info=system_session(),
credentials=creds, lp=lp)
- remove_dc.remove_dns_references(samdb, logger, dnshostname)
+ remove_dc.remove_dns_references(samdb, logger, dnshostname,
+ ignore_no_name=True)
class cmd_dns(SuperCommand):
diff --git a/python/samba/remove_dc.py b/python/samba/remove_dc.py
index 4c8ee892464..f273a515856 100644
--- a/python/samba/remove_dc.py
+++ b/python/samba/remove_dc.py
@@ -84,7 +84,7 @@ def remove_sysvol_references(samdb, logger, dc_name):
raise
-def remove_dns_references(samdb, logger, dnsHostName):
+def remove_dns_references(samdb, logger, dnsHostName, ignore_no_name=False):
# Check we are using in-database DNS
zones = samdb.search(base="", scope=ldb.SCOPE_SUBTREE,
@@ -100,7 +100,11 @@ def remove_dns_references(samdb, logger, dnsHostName):
(dn, primary_recs) = samdb.dns_lookup(dnsHostName)
except RuntimeError as (enum, estr):
if enum == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
- return
+ if ignore_no_name:
+ remove_hanging_dns_references(samdb, logger,
+ dnsHostNameUpper,
+ zones)
+ return
raise DemoteException("lookup of %s failed: %s" % (dnsHostName, estr))
samdb.dns_replace(dnsHostName, [])
@@ -154,6 +158,11 @@ def remove_dns_references(samdb, logger, dnsHostName):
(a_name, len(a_recs), orig_num_recs - len(a_recs)))
samdb.dns_replace(a_name, a_recs)
+ remove_hanging_dns_references(samdb, logger, dnsHostNameUpper, zones)
+
+
+def remove_hanging_dns_references(samdb, logger, dnsHostNameUpper, zones):
+
# Find all the CNAME, NS, PTR and SRV records that point at the
# name we are removing
@@ -194,6 +203,7 @@ def remove_dns_references(samdb, logger, dnsHostName):
# has been done in the list comprehension above
samdb.dns_replace_by_dn(record.dn, values)
+
def offline_remove_server(samdb, logger,
server_dn,
remove_computer_obj=False,