Hi Srikath,
First and foremost, you did a great job - the script is very clean and easy to follow. A few suggestions:
1) Your comments say the script only expects one parameter when it actually expects two: clusterName and cellName
2) You check to make sure the two parameters have been specified in the run command, but you don't check that the correct parameters have been entered before issuing the stop. Name errors most often mean the script can't find the arguement entered - this is usually due to typos. For example you could add a function to check the arguments like this -
def argcheck():
if (len(AdminControl.getid("/ServerCluster:"+arg1+"") == []):
print " Cluster name entered not found, please try again..."
exit(1) #make sure you define and keep record of your error codes so you can refer to them if an error is thrown - an exit code 0 means the script executed successfully - any number assigned to the exit code means there was an issue
else:
print " Cluster name" + arg1 + " found..."
if (AdminControl.getCell() != arg2):
print " Cell name entered not found, please try again..."
exit(2)
else:
print " Cell name found..."
You can also add logic that sends an alert letting you know when an error is encountered, so you know right away if someone ran your script and is having issues.
Lastly, there an easier way to do this in which you can start/stop a cluster using the name of an application installed on the cluster. This method is most effective if you have isolated your applications to a 1:1 ratio - 1 application per cluster. If you have multiple applications installed on the same cluster, this may not be the best method to use.
Hope this helps - Happy Scripting!!!
Danielle