Grandpuits proxy setup

This commit is contained in:
Quentin WEPHRE
2025-10-14 09:58:15 +02:00
parent a994661294
commit 20ec50badf
4 changed files with 15 additions and 17 deletions

View File

@@ -10,11 +10,11 @@ from azure.iot.hub.models import Twin, TwinProperties
load_dotenv(override=True) load_dotenv(override=True)
ip_address_prefix = "10.188.11." ip_address_prefix = "10.81.60."
ssh_command = "hostname" ssh_command = "hostname"
csv_filename = "hoohana7.csv" csv_filename = "Grandpuits_01.csv"
SITE_NAME = "HOOHANA" SITE_NAME = "Grandpuits"
ssh_username = os.getenv("DEFAULT_CUBE_LINUX_ADMIN_USER") ssh_username = os.getenv("DEFAULT_CUBE_LINUX_ADMIN_USER")
ssh_password = os.getenv("DEFAULT_CUBE_LINUX_ADMIN_PASSWORD") ssh_password = os.getenv("DEFAULT_CUBE_LINUX_ADMIN_PASSWORD")
@@ -82,7 +82,7 @@ def main():
results = [] results = []
numbers = [16, 18, 34, 35] numbers = [193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214]
for i in numbers: for i in numbers:
ip_address = f"{ip_address_prefix}{i}" ip_address = f"{ip_address_prefix}{i}"
print(f"Activating SSH for {ip_address}:", end=" ") print(f"Activating SSH for {ip_address}:", end=" ")

View File

@@ -48,10 +48,10 @@ def update_cloud_config(ip, new_content):
def main(): def main():
ip_address_prefix = "10.84.171." ip_address_prefix = "10.81.60."
start_ip = 1 start_ip = 193
end_ip = 5 end_ip = 214
SITE_NAME = "MYRTLE" SITE_NAME = "Grandpuits"
print(f"Site: {SITE_NAME}") print(f"Site: {SITE_NAME}")
print(f"From {ip_address_prefix}{str(start_ip)} to {ip_address_prefix}{str(end_ip)}") print(f"From {ip_address_prefix}{str(start_ip)} to {ip_address_prefix}{str(end_ip)}")

View File

@@ -7,4 +7,5 @@ pandas
openpyxl openpyxl
scp scp
textual textual
fabric fabric
ruamel.yaml

View File

@@ -12,14 +12,9 @@ import base64
def execute_command(c, command): def execute_command(c, command):
"""Executes a simple command on the remote device.""" """Executes a simple command on the remote device."""
# print(f"--- [{c.host}] Executing: {command} ---")
try: try:
result = c.run(command, hide=True) result = c.run(command, hide=True)
return result.stdout return result.stdout
# print("STDOUT:")
# print(result.stdout)
# print("STDERR:")
# print(result.stderr)
except Exception as e: except Exception as e:
print(f"Error executing {command}: {e}") print(f"Error executing {command}: {e}")
@@ -443,9 +438,9 @@ def write_remote_config_base64_sudo(c, remote_path, content, sudo_pass, user_own
def main(): def main():
"""Main function to parse arguments and orchestrate tasks.""" """Main function to parse arguments and orchestrate tasks."""
ip_address_prefix = "10.81.35." # Carling subnet ip_address_prefix = "10.81.60." # Grandpuits subnet
ip_address_range = list(range(68, 75)) # Fronm 65 to 74 ip_address_range = [ 198, 212 ]#list(range(193, 215)) # Fronm 193 to 214 # TODO: 198, 212
ip_address_range.append(85) # Add 85 after 74. # ip_address_range.append(85) # Add 85 after 74.
hosts = [f"{ip_address_prefix}{suffix}" for suffix in ip_address_range] hosts = [f"{ip_address_prefix}{suffix}" for suffix in ip_address_range]
ssh_port = 11022 ssh_port = 11022
@@ -457,6 +452,8 @@ def main():
connect_args["banner_timeout"] = 3 connect_args["banner_timeout"] = 3
connect_args["auth_timeout"] = 60 connect_args["auth_timeout"] = 60
connect_args["channel_timeout"] = 60 connect_args["channel_timeout"] = 60
connect_args["look_for_keys"] = False
connect_args["allow_agent"] = False
for host in hosts: for host in hosts: