Batch restart Cloud service for CUBE
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import csv
|
||||
import paramiko
|
||||
import time
|
||||
from cube_activate_ssh import activate_ssh
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import re
|
||||
from azure.iot.hub import IoTHubRegistryManager
|
||||
from azure.iot.hub.models import Twin, TwinProperties
|
||||
|
||||
load_dotenv(override=True)
|
||||
|
||||
@@ -14,11 +11,9 @@ ip_address_prefix = "10.162.48."
|
||||
ssh_command = "hostname"
|
||||
|
||||
csv_filename = "lacabana01.csv"
|
||||
SITE_NAME = "LACABANA"
|
||||
|
||||
ssh_username = os.getenv("DEFAULT_CUBE_LINUX_ADMIN_USER")
|
||||
ssh_password = os.getenv("DEFAULT_CUBE_LINUX_ADMIN_PASSWORD")
|
||||
CONNECTION_STRING = str(os.getenv("CONNECTION_STRING_INOX_PROD"))
|
||||
|
||||
def execute_ssh_command(ip, command):
|
||||
client = paramiko.SSHClient()
|
||||
@@ -78,10 +73,6 @@ def main():
|
||||
writer = csv.writer(file)
|
||||
writer.writerow(["Number", "IP address", "Cube ID", "Environment", "Correct configuration"])
|
||||
|
||||
registry_manager = IoTHubRegistryManager.from_connection_string(CONNECTION_STRING)
|
||||
|
||||
results = []
|
||||
|
||||
numbers = range(133, 157) #133 to 156
|
||||
for i in numbers:
|
||||
ip_address = f"{ip_address_prefix}{i}"
|
||||
@@ -90,7 +81,7 @@ def main():
|
||||
try:
|
||||
activate_ssh(ip_address)
|
||||
except Exception as e:
|
||||
print("Failed!")
|
||||
print(f"Failed! {e}")
|
||||
writer.writerow([i, ip_address, "UNREACHABLE", "NA", "NA"])
|
||||
file.flush()
|
||||
continue
|
||||
@@ -101,7 +92,7 @@ def main():
|
||||
try:
|
||||
cube_id = execute_ssh_command(ip_address, ssh_command)
|
||||
except Exception as e:
|
||||
print("Failed!")
|
||||
print(f"Failed! {e}")
|
||||
writer.writerow([i, ip_address, "UNREACHABLE", "NA", "NA"])
|
||||
file.flush()
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user