Skip to content

Commit

Permalink
Handle more ipv6 error as an exception #33299 (#33300)
Browse files Browse the repository at this point in the history
* Handle ipv6 exception in scp_file()

* Handle ipv6 exception in sftp_file()
  • Loading branch information
jbonachera authored and Nicole Thomas committed May 17, 2016
1 parent eb47a15 commit 7a181f2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions salt/utils/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1836,9 +1836,12 @@ def scp_file(dest_path, contents=None, kwargs=None, local_file=None):
)
)

if socket.inet_pton(socket.AF_INET6, kwargs['hostname']):
ipaddr = '[{0}]'.format(kwargs['hostname'])
else:
try:
if socket.inet_pton(socket.AF_INET6, kwargs['hostname']):
ipaddr = '[{0}]'.format(kwargs['hostname'])
else:
ipaddr = kwargs['hostname']
except socket.error:
ipaddr = kwargs['hostname']

cmd = (
Expand Down Expand Up @@ -1943,9 +1946,12 @@ def sftp_file(dest_path, contents=None, kwargs=None, local_file=None):
)
)

if socket.inet_pton(socket.AF_INET6, kwargs['hostname']):
ipaddr = '[{0}]'.format(kwargs['hostname'])
else:
try:
if socket.inet_pton(socket.AF_INET6, kwargs['hostname']):
ipaddr = '[{0}]'.format(kwargs['hostname'])
else:
ipaddr = kwargs['hostname']
except socket.error:
ipaddr = kwargs['hostname']

cmd = 'echo "put {0} {1} {2}" | sftp {3} {4[username]}@{5}'.format(
Expand Down

0 comments on commit 7a181f2

Please sign in to comment.