diff options
| author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2022-08-12 16:51:25 +1200 |
|---|---|---|
| committer | Douglas Bagnall <dbagnall@samba.org> | 2022-09-06 21:12:36 +0000 |
| commit | 38ccbf460dc7d687f0bf4bc4dbea53d982ec6c9b (patch) | |
| tree | 60d48d3fa58123970fbfb048d29515dd156acc32 /python | |
| parent | bee727a559a827c1e15a3b382fd9363c5bf285c0 (diff) | |
| download | samba-38ccbf460dc7d687f0bf4bc4dbea53d982ec6c9b.tar.gz samba-38ccbf460dc7d687f0bf4bc4dbea53d982ec6c9b.tar.bz2 samba-38ccbf460dc7d687f0bf4bc4dbea53d982ec6c9b.zip | |
samba-tool dns: add 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.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py index e3a26b53a23..2fcbc40b457 100644 --- a/python/samba/netcmd/dns.py +++ b/python/samba/netcmd/dns.py @@ -1154,15 +1154,17 @@ class cmd_add_record(Command): add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF() add_rec_buf.rec = rec - try: - dns_conn.DnssrvUpdateRecord2(dnsserver.DNS_CLIENT_VERSION_LONGHORN, - 0, server, zone, name, add_rec_buf, None) - 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 added. zone[%s] name[%s]' % (zone, name)) - if e.args[0] == werror.WERR_DNS_ERROR_RECORD_ALREADY_EXISTS: - raise CommandError('Record already exists; record could not be added. 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 added. ' + f'zone[{zone}] name[{name}'), + werror.WERR_DNS_ERROR_RECORD_ALREADY_EXISTS: ( + 'Record already exists; record could not be added. ' + f'zone[{zone}] name[{name}]') + } + dns_conn.DnssrvUpdateRecord2(dnsserver.DNS_CLIENT_VERSION_LONGHORN, + 0, server, zone, name, add_rec_buf, None, + messages=messages) self.outf.write('Record added successfully\n') |
