summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-08-18 09:21:39 +1200
committerDouglas Bagnall <dbagnall@samba.org>2022-09-06 21:12:36 +0000
commitca82806f68ac86c842717d634407632bf0fd8127 (patch)
treee254b2991ddc3ea3f67280cb2bd56d100659cfd0 /python
parent99d48c857f41f01a722b86720893b6827171dad8 (diff)
downloadsamba-ca82806f68ac86c842717d634407632bf0fd8127.tar.gz
samba-ca82806f68ac86c842717d634407632bf0fd8127.tar.bz2
samba-ca82806f68ac86c842717d634407632bf0fd8127.zip
samba-tool dns: update_record uses DnsConnWrapper
The special thing about this one is the dns_conn is also used in the dns_record_match() library function, which wants a real dns connection. 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.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py
index b7402f9979b..0da55c6898e 100644
--- a/python/samba/netcmd/dns.py
+++ b/python/samba/netcmd/dns.py
@@ -1214,11 +1214,11 @@ class cmd_update_record(Command):
self.lp = sambaopts.get_loadparm()
self.creds = credopts.get_credentials(self.lp)
- dns_conn = dns_connect(server, self.lp, self.creds)
+ dns_conn = DnsConnWrapper(server, self.lp, self.creds)
try:
- rec_match = dns_record_match(dns_conn, server, zone, name, record_type,
- olddata)
+ rec_match = dns_record_match(dns_conn.dns_conn, server, zone,
+ name, record_type, olddata)
except DNSParseError as e:
raise CommandError(*e.args) from None
@@ -1237,18 +1237,19 @@ class cmd_update_record(Command):
del_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
del_rec_buf.rec = rec_match
- try:
- dns_conn.DnssrvUpdateRecord2(dnsserver.DNS_CLIENT_VERSION_LONGHORN,
- 0,
- server,
- zone,
- name,
- add_rec_buf,
- 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 updated.')
- raise e
+ messages = {
+ werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST: (
+ f'Zone {zone} does not exist; record could not be updated.'),
+ }
+
+ dns_conn.DnssrvUpdateRecord2(dnsserver.DNS_CLIENT_VERSION_LONGHORN,
+ 0,
+ server,
+ zone,
+ name,
+ add_rec_buf,
+ del_rec_buf,
+ messages=messages)
self.outf.write('Record updated successfully\n')