import paramiko import json import os # import modules with open("conf.json", "r") as file: cfg = json.load(file) # yeah yeah i should probably use YAML but i don't really want to fool with it rn lol -64 sshc = paramiko.client.SSHClient() healthstatus = "" healthpassing = True # define sshc so we don't have to type the whole thing every time we want a client as well as set our healthpassing variable def healthcheck(): global healthstatus response = os.system("ping -c 2 " + cfg["server"]) if response != 0: healthstatus = "err" else: healthstatus = "ok" def deploy(): # deployment shit here sshc.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # so we don't get whined at and crash over a unrecognized host-key sshc.connect(cfg["server"],port=cfg["port"],password=cfg["ssh-password"]) while True: healthcheck() if healthstatus != "ok": print(healthstatus) print("ONT is not responding!! Did we lose network connection, or is the ONT rebooting? Waiting for a successful ping then deploying!") healthpassing = False while healthpassing == False: if healthcheck() == "ok": print("ONT responded, deploying payload!") healthpassing == True; else: print(healthstatus)