def connect(self, user=locals.USER): # show('Connecting to %s' % self.fqdn) success = False timeout = 0 show('Connecting..') while not (success or timeout > 60): try: self.client = SSHClient() self.client.set_missing_host_key_policy(WarningPolicy()) self.client.connect(self.ip, username=user, key_filename=locals.PRIVATE_KEY) success = True except UserWarning: show.debug('UserWarning ignored') except Exception, e: show.debug('Caught exception: %s' % e) sleep(2) timeout += 2
def connect(self, user=locals.USER, pkey_path=locals.PRIVATE_KEY): # show('Connecting to %s' % self.fqdn) success = False timeout = 0 show('Connecting..') while not (success or timeout > 60): try: self.client = SSHClient() self.client.set_missing_host_key_policy(WarningPolicy()) self.client.connect(self.ip, username=user, key_filename=pkey_path) success = True except UserWarning: show.debug('UserWarning ignored') except Exception, e: show.debug('Caught exception: %s' % e) sleep(2) timeout += 2
def print_out(line): if silent: show(line.strip()) else: show.debug(line.strip())
def __init__(self, name, backend, hostname, domain, ip): "Creates a connection to the client" self.name = name self.backend = backend self.hostname = hostname self.domain = domain self.ip = ip self.fqdn = '%s.%s' % (self.hostname, self.domain) self.locals = dict() show.debug("New VM object!") show.debug("Name: %s" % self.name) show.debug("Backend: %s" % self.backend) show.debug("Hostname: %s" % self.hostname) show.debug("Domain: %s" % self.domain) show.debug("IP: %s" % self.ip)