From 2aa5b56b7919ceedef7937c7f3ea17bd2e8ccde2 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Sat, 13 Aug 2022 12:55:01 +1200 Subject: [PATCH] samba-tool dns: use DnsconnWrapper in zonecreate Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- python/samba/netcmd/dns.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py index 0da55c6898e..b449b9da319 100644 --- a/python/samba/netcmd/dns.py +++ b/python/samba/netcmd/dns.py @@ -958,14 +958,14 @@ class cmd_zonecreate(Command): name_and_param.pszNodeName = 'AllowUpdate' name_and_param.dwParam = dnsp.DNS_ZONE_UPDATE_SECURE - try: - dns_conn.DnssrvOperation2(client_version, 0, server, zone, - 0, 'ResetDwordProperty', typeid, - name_and_param) - except WERRORError as e: - if e.args[0] == werror.WERR_DNS_ERROR_ZONE_ALREADY_EXISTS: - self.outf.write('Zone already exists.') - raise e + messages = { + werror.WERR_DNS_ERROR_ZONE_ALREADY_EXISTS: ( + f'Zone "{zone}" already exists.') + } + + dns_conn.DnssrvOperation2(client_version, 0, server, zone, + 0, 'ResetDwordProperty', typeid, + name_and_param, messages=messages) self.outf.write('Zone %s created successfully\n' % zone) -- 2.47.3