Corrects error message for ping errors from server behavior

* Modified ServerUnreachable message to return whatever message
  is passed to it
* Modified Windows and Linux clients to pass a full failure message
  rather than just an IP address.

Change-Id: Ifc64b28063b1a3584568711f9ff8e4b77b5be399
This commit is contained in:
Daryl Walleck
2014-07-21 21:39:36 -05:00
parent 822d759541
commit 0fd9fa7da1
3 changed files with 9 additions and 5 deletions

View File

@@ -57,7 +57,9 @@ class LinuxClient(RemoteInstanceClient):
break
time.sleep(retry_interval)
if int(time.time()) - start >= connection_timeout:
raise ServerUnreachable(ip_address)
raise ServerUnreachable(
'Could not reach the server at {ip_address}'.format(
ip_address=ip_address))
if key is not None:
auth_strategy = SSHAuthStrategy.KEY_STRING

View File

@@ -49,7 +49,9 @@ class WindowsClient(RemoteInstanceClient):
if not self._is_instance_reachable(
ip_address=ip_address, retry_interval=retry_interval,
timeout=connection_timeout):
raise ServerUnreachable(ip_address)
raise ServerUnreachable(
'Could not reach the server at {ip_address}'.format(
ip_address=ip_address))
self.ip_address = ip_address
self.username = username

View File

@@ -157,15 +157,15 @@ class WinRMConnectionException(Exception):
def __init__(self, ip_address):
self.message = (
'Unable to connect to {ip_address} via WinRM.').format(
ip_address=ip_address)
ip_address=ip_address)
def __str__(self):
return repr(self.message)
class ServerUnreachable(Exception):
def __init__(self, address):
self.message = 'Could not reach the server at %s.' % address
def __init__(self, message):
self.message = message
def __str__(self):
return repr(self.message)