Skip to content

Commit

Permalink
fixed ssh not using gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
XaverStiensmeier committed Sep 21, 2023
1 parent 65c3ca2 commit ea051d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion bibigrid/core/actions/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from functools import partial

import paramiko
import sympy
import yaml

from bibigrid.core.actions import terminate
Expand Down Expand Up @@ -431,8 +432,17 @@ def log_cluster_start_info(self):
Detailed cluster info: How to log detailed info about the created cluster
:return:
"""
gateway = self.configurations[0].get("gateway")
ssh_ip = self.master_ip
port = None
if gateway:
octets = {f'oct{enum + 1}': int(elem) for enum, elem in enumerate(self.master_ip.split("."))}
port = int(sympy.sympify(gateway["portFunction"]).subs(dict(octets)))
ssh_ip = gateway["ip"]
self.log.log(42, f"Cluster {self.cluster_id} with master {self.master_ip} up and running!")
self.log.log(42, f"SSH: ssh -i '{KEY_FOLDER}{self.key_name}' {self.ssh_user}@{self.master_ip}")
self.log.log(42,
f"SSH: ssh -i '{KEY_FOLDER}{self.key_name}' {self.ssh_user}@{ssh_ip}"
f"{f' -p {port}' if gateway else ''}")
self.log.log(42, f"Terminate cluster: ./bibigrid.sh -i '{self.config_path}' -t -cid {self.cluster_id}")
self.log.log(42, f"Detailed cluster info: ./bibigrid.sh -i '{self.config_path}' -l -cid {self.cluster_id}")
if self.configurations[0].get("ide"):
Expand Down
4 changes: 2 additions & 2 deletions bibigrid/core/utility/handler/ssh_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def is_active(client, floating_ip_address, private_key, username, log, gateway,
if gateway:
log.info(f"Using SSH Gateway {gateway.get('ip')}")
octets = {f'oct{enum+1}': int(elem) for enum, elem in enumerate(floating_ip_address.split("."))}
port = sympy.sympify(gateway["portFunction"]).subs(dict(octets))
port = int(sympy.sympify(gateway["portFunction"]).subs(dict(octets)))
client.connect(hostname=gateway.get("ip") or floating_ip_address, username=username,
pkey=private_key, timeout=7, auth_timeout=5, port=int(port))
pkey=private_key, timeout=7, auth_timeout=5, port=port)
establishing_connection = False
log.info(f"Successfully connected to {floating_ip_address}")
except paramiko.ssh_exception.NoValidConnectionsError as exc:
Expand Down

0 comments on commit ea051d9

Please sign in to comment.