sync code between _update and _delete
This commit is contained in:
parent
b49772f1ec
commit
dd3cd6139f
@ -320,15 +320,15 @@ def _update(host, hostname, ipaddr, secure=False, logger=None):
|
|||||||
# not available is like it doesn't exist
|
# not available is like it doesn't exist
|
||||||
return Response('nohost')
|
return Response('nohost')
|
||||||
try:
|
try:
|
||||||
ipaddr = str(ipaddr) # bug in dnspython: crashes if ipaddr is unicode, wants a str!
|
# bug in dnspython: crashes if ipaddr is unicode, wants a str!
|
||||||
# https://github.com/rthalley/dnspython/issues/41
|
# https://github.com/rthalley/dnspython/issues/41
|
||||||
# TODO: reproduce and submit traceback to issue 41
|
# TODO: reproduce and submit traceback to issue 41
|
||||||
|
ipaddr = str(ipaddr)
|
||||||
kind = check_ip(ipaddr, ('ipv4', 'ipv6'))
|
kind = check_ip(ipaddr, ('ipv4', 'ipv6'))
|
||||||
except (ValueError, UnicodeError):
|
except (ValueError, UnicodeError):
|
||||||
# invalid ip address string
|
# invalid ip address string
|
||||||
# some people manage to even give a non-ascii string instead of an ip addr
|
# some people manage to even give a non-ascii string instead of an ip addr
|
||||||
return Response('dnserr') # there should be a better response code for this
|
return Response('dnserr') # there should be a better response code for this
|
||||||
|
|
||||||
host.poke(kind, secure)
|
host.poke(kind, secure)
|
||||||
try:
|
try:
|
||||||
update(hostname, ipaddr)
|
update(hostname, ipaddr)
|
||||||
@ -381,16 +381,16 @@ def _delete(host, hostname, ipaddr, secure=False, logger=None):
|
|||||||
if not host.available:
|
if not host.available:
|
||||||
# not available is like it doesn't exist
|
# not available is like it doesn't exist
|
||||||
return Response('nohost')
|
return Response('nohost')
|
||||||
ipaddr = str(ipaddr) # bug in dnspython: crashes if ipaddr is unicode, wants a str!
|
|
||||||
# https://github.com/rthalley/dnspython/issues/41
|
|
||||||
# TODO: reproduce and submit traceback to issue 41
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# bug in dnspython: crashes if ipaddr is unicode, wants a str!
|
||||||
|
# https://github.com/rthalley/dnspython/issues/41
|
||||||
|
# TODO: reproduce and submit traceback to issue 41
|
||||||
|
ipaddr = str(ipaddr)
|
||||||
kind = check_ip(ipaddr, ('ipv4', 'ipv6'))
|
kind = check_ip(ipaddr, ('ipv4', 'ipv6'))
|
||||||
except ValueError:
|
except (ValueError, UnicodeError):
|
||||||
# invalid ip address string
|
# invalid ip address string
|
||||||
|
# some people manage to even give a non-ascii string instead of an ip addr
|
||||||
return Response('dnserr') # there should be a better response code for this
|
return Response('dnserr') # there should be a better response code for this
|
||||||
|
|
||||||
host.poke(kind, secure)
|
host.poke(kind, secure)
|
||||||
try:
|
try:
|
||||||
rdtype = 'A' if kind == 'ipv4' else 'AAAA'
|
rdtype = 'A' if kind == 'ipv4' else 'AAAA'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user