import paramiko import time import urllib.request import ssl ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE def main(): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('140.44.4.71', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) print("=== STEP 1: Updating nginx-proxy-manager_app to Dual-Node Swarm Placement ===") cmd = ( "sudo docker service update " "--constraint-rm 'node.hostname == snshpd4lnxswm04' " "--constraint-add 'node.labels.npm == true' " "--replicas 2 " "--update-order start-first " "nginx-proxy-manager_app" ) stdin, stdout, stderr = ssh.exec_command(cmd) print("Service update output:\n", stdout.read().decode()) print("Service update stderr:\n", stderr.read().decode()) print("=== STEP 2: Waiting for tasks to stabilize ===") time.sleep(10) stdin, stdout, stderr = ssh.exec_command("sudo docker service ps nginx-proxy-manager_app --no-trunc") print("Tasks:\n", stdout.read().decode()) ssh.close() print("=== STEP 3: Verifying HTTP / HTTPS endpoints ===") for ip in ['140.44.4.70', '140.44.4.71', '140.44.4.72']: # Port 80 try: req = urllib.request.Request(f"http://{ip}", headers={"Host": "test.snarfnet.net"}) with urllib.request.urlopen(req, timeout=4) as r: print(f"[{ip}:80] HTTP {r.status}") except urllib.error.HTTPError as e: print(f"[{ip}:80] HTTP {e.code} (NPM responding)") except Exception as e: print(f"[{ip}:80] Error: {e}") # Port 81 (Admin UI) try: req = urllib.request.Request(f"http://{ip}:81") with urllib.request.urlopen(req, timeout=4) as r: print(f"[{ip}:81] HTTP {r.status} (Admin UI responding)") except urllib.error.HTTPError as e: print(f"[{ip}:81] HTTP {e.code}") except Exception as e: print(f"[{ip}:81] Error: {e}") if __name__ == '__main__': main()