incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rg...@apache.org
Subject svn commit: r1053440 - in /incubator/tashi/branches/zoni-dev/trunk/src/zoni: client/zoni-cli.py hardware/delldrac.py hardware/systemmanagement.py
Date Tue, 28 Dec 2010 21:18:26 GMT
Author: rgass
Date: Tue Dec 28 21:18:24 2010
New Revision: 1053440

URL: http://svn.apache.org/viewvc?rev=1053440&view=rev
Log:
adding catch for issuing a command on a node already powered up or down.

fixing zoni-cli to allow bypassing systemmanagement and issuing commands directly to hardware
specified
Fix systemmanagement bugs

Modified:
    incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py
    incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/delldrac.py
    incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py

Modified: incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py?rev=1053440&r1=1053439&r2=1053440&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py (original)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py Tue Dec 28 21:18:24
2010
@@ -210,7 +210,7 @@ def main():
 		host = data.getHostInfo(options.nodeName)
 		if options.hardwareType == "ipmi":
 		#hardware = zoni.hardware.systemmanagement.SystemManagement(configs,data)
-			hw = Ipmi(options.nodeName, host["ipmi_user"], host["ipmi_password"])
+			hw = Ipmi(configs, options.nodeName, host)
 #
 		if options.hardwareType == "pdu":
 			hw = raritanDominionPx(configs, host)
@@ -223,6 +223,36 @@ def main():
 				mesg = "Host (" + options.nodeName + ") does not have a DRAC card!!\n"
 				sys.stdout.write(mesg)
 				exit(1)
+		if (options.REBOOTNODE or options.POWERCYCLE  or options.POWEROFF or \
+			options.POWERON or options.POWERSTATUS or options.CONSOLE or \
+			options.POWERRESET) and options.nodeName:
+
+			if options.verbosity:
+				hw.setVerbose(True)
+
+			if options.REBOOTNODE:
+				hw.powerReset()
+				exit()
+			if options.POWERCYCLE: 
+				hw.powerCycle()
+				exit()
+			if options.POWEROFF:
+				hw.powerOff()
+				exit()
+			if options.POWERON:
+				hw.powerOn()
+				exit()
+			if options.POWERRESET:
+				hw.powerReset()
+				exit()
+			if options.POWERSTATUS:
+				hw.getPowerStatus()
+				exit()
+			if options.CONSOLE:
+				hw.activateConsole()
+				exit()
+			hw.getPowerStatus()
+			exit()
 	else:
 		hw = zoni.hardware.systemmanagement.SystemManagement(configs,data)
 

Modified: incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/delldrac.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/delldrac.py?rev=1053440&r1=1053439&r2=1053440&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/delldrac.py (original)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/delldrac.py Tue Dec 28 21:18:24
2010
@@ -111,8 +111,8 @@ class dellDrac(SystemManagementInterface
 		code = 0
 		fout = tempfile.TemporaryFile()
 		if self.powerStatus == 1:
-			mesg = self.hostname + " Power On\n\n"
-			return 0
+			self.log.info("Hardware power on : %s", self.hostname)
+			return 1
 			
 		child = self.__login()
 		child.logfile = fout
@@ -120,15 +120,15 @@ class dellDrac(SystemManagementInterface
 		child.sendline(cmd)
 		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
 		fout.seek(0)
+		self.log.info("Hardware power on : %s", self.hostname)
 		for val in fout.readlines():
 			if "OK" in val:
-				mesg = self.hostname + " Power On\n\n"
-				self.log.info(mesg)
 				code = 1 
-			else:
-				mesg = self.hostname + " Power On Fail\n\n"
-				self.log.info(mesg)
-				code = -1
+			if "ALREADY POWER-ON" in val:
+				code = 1 
+				self.log.info("Hardware already powered on : %s", self.hostname)
+		if code < 1:
+			self.log.info("Hardware power on failed : %s", self.hostname)
 		fout.close()
 		child.terminate()
 		return code
@@ -143,16 +143,15 @@ class dellDrac(SystemManagementInterface
 		child.sendline(cmd)
 		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
 		fout.seek(0)
+		self.log.info("Hardware power off : %s", self.hostname)
 		for val in fout.readlines():
 			if "OK" in val:
-				mesg = self.hostname + " Power Off\n\n"
-				self.log.info(mesg)
 				code = 1
-			else:
-				mesg = self.hostname + " Power Off Fail\n\n"
-				self.log.info(mesg)
-				code = -1
-		#i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+ 			if "CURRENTLY POWER-OFF" in val:
+				self.log.info("Hardware already power off : %s", self.hostname)
+				code = 1
+		if code < 1:
+			self.log.info("Hardware power off failed : %s", self.hostname)
 		child.terminate()
 		fout.close()
 		return code
@@ -167,15 +166,12 @@ class dellDrac(SystemManagementInterface
 		child.sendline(cmd)
 		i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
 		fout.seek(0)
+		self.log.info("Hardware power cycle : %s", self.hostname)
 		for val in fout.readlines():
 			if "OK" in val:
-				mesg = self.hostname + " Power Cycle\n\n"
-				self.log.info(mesg)
 				code = 1
-			else:
-				mesg = self.hostname + " Power Cycle Fail\n\n"
-				self.log.info(mesg)
-				code = -1
+		if code < 1:
+			self.log.info("Hardware power cycle failed : %s", self.hostname)
 		child.terminate()
 		fout.close()
 		return code
@@ -194,10 +190,8 @@ class dellDrac(SystemManagementInterface
 			if "OK" in val:
 				self.log.info("Hardware power reset : %s", self.nodeName)
 				code = 1
-				break
-		if code == 0:
+		if code < 1:
 			self.log.info("Hardware power reset fail: %s", self.nodeName)
-			code = -1
 
 		child.terminate()
 		fout.close()

Modified: incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py?rev=1053440&r1=1053439&r2=1053440&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py (original)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py Tue Dec
28 21:18:24 2010
@@ -62,6 +62,7 @@ class SystemManagement(SystemManagementI
 		#  [0] = hw method
 		#  [1] = hw method userid
 		#  [2] = hw method password
+		success = 0
 		for i in hw:
 			inst = instantiateImplementation(self.config['hardwareControl'][i[0]]['class'], self.config,
nodeName, self.host)
 			a = "inst.%s" % mycmd
@@ -69,9 +70,12 @@ class SystemManagement(SystemManagementI
 				doit = eval(a)
 				if doit  > 0:
 					self.log.info("%s method success (%s) on %s (attempt %s)", i[0], mycmd, nodeName, count
+ 1)
+					success = 1
 					break
 				else:
 					self.log.error("%s method failed (%s) on %s (attempt %s)", i[0], mycmd, nodeName, count
+ 1)
+			if success:
+				break
 
 		return doit
 



Mime
View raw message