Skip to content

Commit

Permalink
updating ssh_handler.py now logging locally (and affected modules)
Browse files Browse the repository at this point in the history
  • Loading branch information
XaverStiensmeier committed Aug 11, 2023
1 parent c88e6ad commit 1703c38
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions bibigrid/core/utility/handler/ssh_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
from bibigrid.models.exceptions import ConnectionException, ExecutionException

PRIVATE_KEY_FILE = ".ssh/id_ecdsa" # to name bibigrid-temp keys identically on remote
ANSIBLE_SETUP = [aC.NO_UPDATE, aC.UPDATE,
aC.PYTHON3_PIP, aC.ANSIBLE_PASSLIB,
(f"chmod 600 {PRIVATE_KEY_FILE}", "Adjust private key permissions."),
aC.PLAYBOOK_HOME,
aC.PLAYBOOK_HOME_RIGHTS,
aC.ADD_PLAYBOOK_TO_LINUX_HOME]
ANSIBLE_SETUP = [aC.NO_UPDATE, aC.UPDATE, aC.PYTHON3_PIP, aC.ANSIBLE_PASSLIB,
(f"chmod 600 {PRIVATE_KEY_FILE}", "Adjust private key permissions."), aC.PLAYBOOK_HOME,
aC.PLAYBOOK_HOME_RIGHTS, aC.ADD_PLAYBOOK_TO_LINUX_HOME]
# ANSIBLE_START = [aC.WAIT_READY, aC.UPDATE, aC.MV_ANSIBLE_CONFIG, aC.EXECUTE] # another UPDATE seems to not necessary.
ANSIBLE_START = [aC.WAIT_READY, aC.MV_ANSIBLE_CONFIG, aC.EXECUTE]
VPN_SETUP = [("echo Example", "Echos an Example")]
Expand All @@ -38,16 +35,14 @@ def get_ac_command(providers, name):
if auth.get("application_credential_id") and auth.get("application_credential_secret"):
wanted_keys = ["auth", "region_name", "interface", "identity_api_version", "auth_type"]
ac_cloud_specification = {wanted_key: cloud_specification[wanted_key] for wanted_key in wanted_keys if
wanted_key in
cloud_specification}
wanted_key in cloud_specification}
else:
wanted_keys = ["region_name", "interface", "identity_api_version"]
ac = provider.create_application_credential(name=name) # pylint: disable=invalid-name
ac_dict = {"application_credential_id": ac["id"], "application_credential_secret": ac["secret"],
"auth_type": "v3applicationcredential", "auth_url": auth["auth_url"]}
ac_cloud_specification = {wanted_key: cloud_specification[wanted_key] for wanted_key in wanted_keys if
wanted_key in
cloud_specification}
wanted_key in cloud_specification}
ac_cloud_specification.update(ac_dict)
ac_clouds_yaml["clouds"][cloud_specification["identifier"]] = ac_cloud_specification
return (f"echo '{yaml.safe_dump(ac_clouds_yaml)}' | sudo install -D /dev/stdin /etc/openstack/clouds.yaml",
Expand Down Expand Up @@ -219,10 +214,7 @@ def execute_ssh(floating_ip, private_key, username, log, commands=None, filepath
with paramiko.SSHClient() as client:
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
is_active(client=client,
floating_ip_address=floating_ip,
username=username,
private_key=paramiko_key,
is_active(client=client, floating_ip_address=floating_ip, username=username, private_key=paramiko_key,
log=log)
except ConnectionException as exc:
log.error(f"Couldn't connect to floating ip {floating_ip} using private key {private_key}.")
Expand Down

0 comments on commit 1703c38

Please sign in to comment.