
UNSOLVED
Closed
Python script to shutdown Storage Array + UPS script
Hi community contributors,
Is there any pre-built Python script to remote shutdown ME5024 via ssh? or can we trust the script below?
import subprocess
# Set the IP address, username, and password for the storage array
ip_address = 'x.x.x.x'
username = 'admin'
password = 'password'
# Build the SSH command to connect to the storage array
ssh_cmd = f'sshpass -p {password} ssh -o StrictHostKeyChecking=no {admin}@{x.x.x.x}'
# Run the shutdown command on the storage array
cmd = f'echo y | {ssh_cmd} "shutdown both"'
result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode != 0:
print('Failed to initiate shutdown')
# Close the SSH connection
subprocess.run(f'{ssh_cmd} "exit"')
Responses (0)
Solutions (0)
