Projects STRLCPY geneva Commits 3b3fdff8
🤬
  • Updated evaluator's handling of remote clients to prefer hostnames to IP addresses if they are defined

  • Loading...
  • Kkevsterrr committed 4 years ago
    3b3fdff8
    1 parent 9874ce08
  • ■ ■ ■ ■ ■
    evaluator.py
    skipped 24 lines
    25 25  # Suppress unfixed Paramiko warnings (see Paramiko issue #1386)
    26 26  warnings.filterwarnings(action='ignore',module='.*paramiko.*')
    27 27   
     28 +# Placeholder for a docker import (see below why we cannot import docker here)
     29 +docker = None
    28 30  BASEPATH = os.path.dirname(os.path.abspath(__file__))
    29 31  PROJECT_ROOT = BASEPATH
    30 32   
    skipped 724 lines
    755 757   paramiko_logger = paramiko.util.logging.getLogger()
    756 758   paramiko_logger.setLevel(logging.WARN)
    757 759   worker = actions.utils.get_worker(self.external_client, self.logger)
     760 + 
    758 761   if self.use_docker:
    759 762   worker["ip"] = "0.0.0.0"
    760  - self.logger.debug("Connecting to worker %s@%s" % (worker["username"], worker["ip"]))
     763 + 
     764 + # Pull the destination to connect to this worker. Preference hostnames over IP addresses.
     765 + destination = worker["hostname"]
     766 + if not destination:
     767 + destination = worker["ip"]
     768 + 
     769 + self.logger.debug("Connecting to worker %s@%s" % (worker["username"], destination))
    761 770   remote = paramiko.SSHClient()
    762 771   remote.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    763 772   max_tries = 5
    skipped 2 lines
    766 775   try:
    767 776   if "keyfile" in worker:
    768 777   k = paramiko.RSAKey.from_private_key_file(worker["keyfile"])
    769  - remote.connect(worker["ip"], username=worker["username"], pkey=k, port=worker["port"], timeout=60)
     778 + remote.connect(destination, username=worker["username"], pkey=k, port=worker["port"], timeout=60)
    770 779   else:
    771  - remote.connect(worker["ip"], username=worker["username"], password=worker["password"], port=worker["port"], timeout=60)
     780 + remote.connect(destination, username=worker["username"], password=worker["password"], port=worker["port"], timeout=60)
    772 781   break
    773 782   except socket.timeout:
    774  - self.logger.error("Could not connect to worker %s" % worker["ip"])
     783 + self.logger.error("Could not connect to worker %s" % destination)
    775 784   i += 1
    776 785   return remote
    777 786   
    skipped 380 lines
Please wait...
Page is in error, reload to recover