summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-08-12 17:17:16 +1200
committerDouglas Bagnall <dbagnall@samba.org>2022-09-06 21:12:36 +0000
commit99d48c857f41f01a722b86720893b6827171dad8 (patch)
treef6027f3b805c6bf10b7aabb83491f4b87c8ba27a /python
parent38ccbf460dc7d687f0bf4bc4dbea53d982ec6c9b (diff)
downloadsamba-99d48c857f41f01a722b86720893b6827171dad8.tar.gz
samba-99d48c857f41f01a722b86720893b6827171dad8.tar.bz2
samba-99d48c857f41f01a722b86720893b6827171dad8.zip
samba-tool dns: delete uses DnsConnWrapper messages
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/dns.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py
index 2fcbc40b457..b7402f9979b 100644
--- a/python/samba/netcmd/dns.py
+++ b/python/samba/netcmd/dns.py
@@ -1292,20 +1292,22 @@ class cmd_delete_record(Command):
del_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
del_rec_buf.rec = rec
- try:
- dns_conn.DnssrvUpdateRecord2(dnsserver.DNS_CLIENT_VERSION_LONGHORN,
- 0,
- server,
- zone,
- name,
- None,
- del_rec_buf)
- except WERRORError as e:
- if e.args[0] == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
- raise CommandError('Zone does not exist; record could not be deleted. zone[%s] name[%s]' % (zone, name))
- if e.args[0] == werror.WERR_DNS_ERROR_RECORD_DOES_NOT_EXIST:
- raise CommandError('Record does not exist; record could not be deleted. zone[%s] name[%s]' % (zone, name))
- raise e
+ messages = {
+ werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST: (
+ 'Zone does not exist; record could not be deleted. '
+ f'zone[{zone}] name[{name}'),
+ werror.WERR_DNS_ERROR_RECORD_ALREADY_EXISTS: (
+ 'Record already exists; record could not be deleted. '
+ f'zone[{zone}] name[{name}]')
+ }
+ dns_conn.DnssrvUpdateRecord2(dnsserver.DNS_CLIENT_VERSION_LONGHORN,
+ 0,
+ server,
+ zone,
+ name,
+ None,
+ del_rec_buf,
+ messages=messages)
self.outf.write('Record deleted successfully\n')