Monday, September 27, 2010

SAN Shutdown Script

Here's a short python script that you can use to automate a clean shutdown of a Equallogics PS6000xv. I threw it together so that I could run/schedule it from an ESX 4 host; it implements the telnetlib module to automate a telnet session with a Dell PS6000xv (tested on firmware v4.1.3, R91175). I thought it might come in handy for someone else, as Dell/Equallogics doesn't publish any code to do this kind of work for you. Make sure that when you run this, you don't have any active I/O going on.


import sys
import telnetlib

hostIP = "192.168.0.2"
user: "sanadminaccount"
password: "password"

tn = telnetlib.Telnet(hostIP)
tn.read_until("login: ")
tn.write(user + "\r\n")
tn.write(password + "\r\n")
tn.read_until("SANNAME> ")
shutdownstring = tn.write("shutdown" + "\r\n")
tn.read_until("[no]")
shutdownresponse = tn.write("yes" + "\r\n")
tn.write("logout" + "\r\n")

print tn.read_all()


No comments: