New tools for restarting services and fixes
This commit is contained in:
@@ -13,7 +13,7 @@ load_dotenv(override=True)
|
||||
ip_address_prefix = "10.188.11."
|
||||
ssh_command = "hostname"
|
||||
|
||||
csv_filename = "hoohana6.csv"
|
||||
csv_filename = "hoohana7.csv"
|
||||
SITE_NAME = "HOOHANA"
|
||||
|
||||
ssh_username = os.getenv("DEFAULT_CUBE_LINUX_ADMIN_USER")
|
||||
@@ -52,6 +52,24 @@ def update_cloud_config(ip, new_content):
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
def restart_cloudagent(ip):
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
try:
|
||||
client.connect(ip, port=11022, username=ssh_username, password=ssh_password, allow_agent=False, look_for_keys=False)
|
||||
stdin, stdout, stderr = client.exec_command(f'sudo -S bash -c \'systemctl restart cube-web-cloudagent << EOF\n\nEOF\'\n')
|
||||
stdin.write(ssh_password + "\n")
|
||||
stdin.flush()
|
||||
stdoutput = [line for line in stdout]
|
||||
stderroutput = [line for line in stderr]
|
||||
for output in stdoutput:
|
||||
print(output.strip())
|
||||
except Exception as e:
|
||||
print(f"SSH Error: {str(e)}")
|
||||
raise
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
def main():
|
||||
|
||||
print("Starting...")
|
||||
@@ -64,7 +82,8 @@ def main():
|
||||
|
||||
results = []
|
||||
|
||||
for i in range (54, 55):
|
||||
numbers = [16, 18, 34, 35]
|
||||
for i in numbers:
|
||||
ip_address = f"{ip_address_prefix}{i}"
|
||||
print(f"Activating SSH for {ip_address}:", end=" ")
|
||||
|
||||
@@ -162,6 +181,8 @@ def main():
|
||||
continue
|
||||
print("Done!")
|
||||
|
||||
restart_cloudagent(ip_address)
|
||||
|
||||
writer.writerow([i, ip_address, cube_id, migration, status])
|
||||
file.flush()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user