def __init__(self, ip_address, username='******', password=None, key=None, connection_timeout=600, retry_interval=10): self.client_log = cclogging.getLogger( cclogging.get_object_namespace(self.__class__)) # Verify the IP address has a valid format try: IP(ip_address) except ValueError: raise InvalidAddressFormat(ip_address) # Verify the server can be pinged before attempting to connect PingClient.ping_until_reachable(ip_address, timeout=connection_timeout, interval_time=retry_interval) self.ip_address = ip_address self.username = username self.password = password self.client = WinRMClient(username=username, password=password, host=ip_address) connected = self.client.connect_with_retries() if not connected: raise WinRMConnectionException(ip_address=ip_address)
def __init__(self, ip_address, username='******', password=None, key=None, connection_timeout=600, retry_interval=10): self.client_log = cclogging.getLogger( cclogging.get_object_namespace(self.__class__)) # Verify the IP address has a valid format try: IP(ip_address) except ValueError: raise ServerUnreachable(ip_address) if not self._is_instance_reachable(ip_address=ip_address, retry_interval=retry_interval, timeout=connection_timeout): raise ServerUnreachable(ip_address) self.ip_address = ip_address self.username = username self.password = password self.client = WinRMClient(username=username, password=password, host=ip_address) self.client.connect_with_retries()