Author: gnichols
Date: 2010-06-15 17:28:26 +0000 (Tue, 15 Jun 2010)
New Revision: 550
Modified:
trunk/v7/hardwaretest.py
Log:
568518 - FEAT: add a BMC fencing testing
Modified: trunk/v7/hardwaretest.py
===================================================================
--- trunk/v7/hardwaretest.py 2010-06-15 17:28:18 UTC (rev 549)
+++ trunk/v7/hardwaretest.py 2010-06-15 17:28:26 UTC (rev 550)
@@ -43,6 +43,7 @@
from v7.command import Command, V7CommandException
from v7.resultsengine import ResultsEngine
from v7.redhatrelease import RedHatRelease
+from v7.daemon import V7Daemon
class HardwareTestHarness(Controller):
@@ -176,7 +177,7 @@
# do the command
try:
self.commands[self.command]()
- except KeyError:
+ except KeyError, e:
print "unknown command: " + self.command
self.releaseLock()
return result
@@ -192,7 +193,7 @@
command = self.options.command
if command == "print":
self.doPrint(format="html")
- elif (command == 'run'):
+ elif (command == 'run' or command == 'server' or command ==
'daemon'):
result = self.addTask()
elif command == "status":
self.doWebStatus()
@@ -418,7 +419,8 @@
subcommand = "start"
if subcommand == "daemon":
- return self.doDaemon()
+ daemon = V7Daemon(self.environment, self.options)
+ return daemon.run()
planner = Planner(self.options, virtualization=None)
@@ -431,53 +433,39 @@
if rv != 0:
result = rv
return result
-
- def doDaemon(self):
- while True:
- if self.Debugging != Constants.off:
- print "checking for tasks"
- try:
- taskFile = open(self.environment.getTaskFilePath())
- for line in taskFile.readlines():
- if not line:
- break
- try:
- print "\"" + line.strip() + "\""
- if line.strip() == "shutdown":
- print "v7 daemon shutdown"
- # delete the lines from the file
- open(self.environment.getTaskFilePath(),
"w").close()
- return 0
- # otherwise
- # only run v7 - nothing else
- if line.split()[0] == "v7" and ";" not in
line:
- print "Running: " + line
- task = Command(line)
- task.echo()
- else:
- print "unsupported command: " + line
- except V7CommandException, e:
- print "Error: " + e.message
- taskFile.close()
- # delete the lines from the file
- open(self.environment.getTaskFilePath(), "w").close()
- time.sleep(10)
- except IOError, e:
- print e/v7/results.xml
- return False
-
+
def addTask(self):
print "<pre>"
- command = "v7 " + self.webOptions["command"] + " "
- for option in self.webOptions.keys():
- if option != "command" and self.webOptions[option]:
- command += "--" + option + " " +
self.webOptions[option] + " "
- command += "\n"
- print "Adding Task: " + command
+ command = None
+ try:
+ command = "v7 " + self.webOptions["command"] + "
" + self.webOptions["subcommand"] + " "
+ except KeyError, e:
+ print "Error: missing URL parameter:"
+ print e
+ if command:
+ for option in self.webOptions.keys():
+ if "command" not in option and self.webOptions[option]:
+ command += "--" + option + " " +
self.webOptions[option] + " "
+ command += "\n"
+ print "Adding Task: " + command
+ sys.stdout.flush()
+ taskInFile = os.open(self.environment.getTaskFilePath() + ".in",
os.O_WRONLY)
+ print "opened task file"
+ sys.stdout.flush()
+ os.write(taskInFile, command)
+ os.write(taskInFile, "\n")
+ os.close(taskInFile)
+ print "Reading Results"
+ taskOutFile = open(self.environment.getTaskFilePath()+".out",
"r")
+ while True:
+ line = taskOutFile.readline()
+ if line:
+ print line
+ else:
+ break
+ taskOutFile.close()
+ print "done"
sys.stdout.flush()
- taskFile = open(self.environment.getTaskFilePath(), "a")
- taskFile.write(command)
- taskFile.close()
print "</pre>"
def doWebStatus(self):
@@ -745,10 +733,12 @@
requestedTests.append(mandatoryTest)
# reboot test is a special case - really needs to run last
- reboot = requestedTestDict["reboot"]
- if reboot:
+ try:
+ reboot = requestedTestDict["reboot"]
requestedTests.remove(reboot)
requestedTests.append(reboot)
+ except:
+ pass
return requestedTests
Show replies by date