handle name resolution errors more gracefully from shell.py

This change will catch socket.gaierror exceptions from shell.py and
return a more friendly message to the user
pull/15949/head
Peter Sprygada 9 years ago
parent ff346a199c
commit 309aba128c

@ -101,12 +101,15 @@ class Shell(object):
if not look_for_keys: if not look_for_keys:
look_for_keys = password is None look_for_keys = password is None
self.ssh.connect(host, port=port, username=username, password=password, try:
timeout=timeout, look_for_keys=look_for_keys, pkey=pkey, self.ssh.connect(host, port=port, username=username, password=password,
key_filename=key_filename, allow_agent=allow_agent) timeout=timeout, look_for_keys=look_for_keys, pkey=pkey,
key_filename=key_filename, allow_agent=allow_agent)
self.shell = self.ssh.invoke_shell()
self.shell.settimeout(timeout) self.shell = self.ssh.invoke_shell()
self.shell.settimeout(timeout)
except socket.gaierror:
raise ShellError("unable to resolve host name")
if self.kickstart: if self.kickstart:
self.shell.sendall("\n") self.shell.sendall("\n")

Loading…
Cancel
Save