New tools for restarting services and fixes
This commit is contained in:
@@ -6,6 +6,7 @@ import os
|
||||
import urllib3
|
||||
from dotenv import load_dotenv
|
||||
import io
|
||||
import time
|
||||
|
||||
load_dotenv(override=True)
|
||||
|
||||
@@ -31,8 +32,7 @@ def authenticate(base_url):
|
||||
}
|
||||
|
||||
try:
|
||||
print(f"Authenticating as {username}...")
|
||||
response = requests.post(auth_url, files=files, verify=False)
|
||||
response = requests.post(auth_url, files=files, verify=False, timeout=10)
|
||||
response.raise_for_status() # Raise exception for 4XX/5XX responses
|
||||
|
||||
# Extract token from response
|
||||
@@ -40,9 +40,9 @@ def authenticate(base_url):
|
||||
token = auth_data.get("token")
|
||||
|
||||
if not token:
|
||||
print("Error: No token received in authentication response")
|
||||
print("Authentication failure!")
|
||||
|
||||
print("Authentication successful.")
|
||||
print("Authentication success!", end = " ")
|
||||
return token
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
@@ -66,16 +66,16 @@ def set_ssh_status(base_url, token):
|
||||
payload = { "currentStatus": True }
|
||||
|
||||
try:
|
||||
print(f"Sending request to enable SSH...")
|
||||
response = requests.post(ssh_url, headers=headers, json=payload, verify=False)
|
||||
response = requests.post(ssh_url, headers=headers, json=payload, verify=False, timeout=10)
|
||||
response.raise_for_status()
|
||||
|
||||
print(f"SSH enabled successfully!")
|
||||
print(f"SSH activation success!")
|
||||
|
||||
return True
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"SSH activation failed: {e}")
|
||||
print("SSH activation failure!")
|
||||
print(f"Exception: {e}")
|
||||
if hasattr(e, 'response') and e.response:
|
||||
print(f"Response: {e.response.text}")
|
||||
return False
|
||||
@@ -88,10 +88,8 @@ def activate_ssh(ip_address):
|
||||
# Convert http:// to https:// or add https:// if no protocol specified
|
||||
if url.startswith("http://"):
|
||||
url = "https://" + url[7:]
|
||||
print(f"Converting to HTTPS: {url}")
|
||||
else:
|
||||
url = "https://" + url
|
||||
print(f"Adding HTTPS protocol: {url}")
|
||||
if not url.endswith(":9080"):
|
||||
url = url + ":9080"
|
||||
|
||||
@@ -102,5 +100,5 @@ def activate_ssh(ip_address):
|
||||
token = authenticate(url)
|
||||
if not token:
|
||||
return
|
||||
|
||||
time.sleep(3)
|
||||
set_ssh_status(url, token)
|
||||
Reference in New Issue
Block a user