def execute(self): #get all config files self.getAllConfigFiles(self.configPath) #start each node in cluster stateList = [] for cfl in self.configList: s = State() configlocation = cfl cf = ConfigParser.ConfigParser() cf.read(configlocation) parameters=cf.items("Config") for item in parameters: s.put(item[0], item[1]) #init the email tolist emailToListStr = s.get(Tasks.StaticVariables.EMAILTOLIST) emailToList = emailToListStr.split(";") s.put(Tasks.StaticVariables.EMAILTOLIST.lower(), emailToList) #init the logger logger = Logger(s.get(Tasks.StaticVariables.SERVERNAME)+"_"+s.get(Tasks.StaticVariables.BUILDNO),1) s.put(Tasks.StaticVariables.LINUXTESTLOGGER,logger) stateList.append(copy.deepcopy(s)) #install build on Linux inb = InstallLinuxBuildTask() Tasks.Command.displayTaskState(inb.getStat()) state = inb.execute(s) Tasks.Command.displayTaskState(inb.getStat()) if state != TaskStatus.PASS: exit() #configure dsn on Linux cld = CreateLinuxDSNTask() Tasks.Command.displayTaskState(cld.getStat()) state = cld.execute(s) Tasks.Command.displayTaskState(cld.getStat()) if state != TaskStatus.PASS: exit() #configure the performance counter and log size cnld = ConfigLinuxDiagTask() Tasks.Command.displayTaskState(cnld.getStat()) state = cnld.execute(s) Tasks.Command.displayTaskState(cnld.getStat()) if state != TaskStatus.PASS: exit() #configure iserver cus = ConfigUnixIServerTask() Tasks.Command.displayTaskState(cus.getStat()) state = cus.execute(s) Tasks.Command.displayTaskState(cus.getStat()) if state != TaskStatus.PASS: exit() #start iserver on Linux st = StartServerTask(); Tasks.Command.displayTaskState(st.getStat()) state = st.execute(s) Tasks.Command.displayTaskState(st.getStat()) if state != TaskStatus.PASS: exit() #cluster nodes try: self.client = Tasks.Command.getConnect(stateList[0].get(Tasks.StaticVariables.SERVERNAME), stateList[0].get(Tasks.StaticVariables.SERVERLOGIN), stateList[0].get(Tasks.StaticVariables.SERVERPASSWORD)) except Exception, e: #print "connect fialed" self.info = "cannot connect to remote Linux machine." + str(e) self.info = self.info+"machine:"+stateList[0].get(Tasks.StaticVariables.SERVERNAME)+ "\nlogin:"******"\npwd:"+stateList[0].get(Tasks.StaticVariables.SERVERPASSWORD) print self.info stateList[0].get(Tasks.StaticVariables.LINUXTESTLOGGER).log(self.info) exit()
def execute(self): s = State() configlocation = self.configPath cf = ConfigParser.ConfigParser() cf.read(configlocation) parameters=cf.items("Config") for item in parameters: s.put(item[0], item[1]) #init the email tolist emailToListStr = s.get(Tasks.StaticVariables.EMAILTOLIST) emailToList = emailToListStr.split(";") s.put(Tasks.StaticVariables.EMAILTOLIST.lower(), emailToList) #init the logger logger = Logger(s.get(Tasks.StaticVariables.SERVERNAME)+"_"+s.get(Tasks.StaticVariables.BUILDNO),1) s.put(Tasks.StaticVariables.LINUXTESTLOGGER,logger) Ibuildno = raw_input("please input the build number:") if Ibuildno != "": s.put(Tasks.StaticVariables.BUILDNO,Ibuildno) Ibuildversion = raw_input("please input the build versiton(DEBUG/RELEASE):") if Ibuildno != "": s.put(Tasks.StaticVariables.BUILDVERSION,Ibuildversion.upper()) #install build on Linux inb = InstallLinuxBuildTask() Tasks.Command.displayTaskState(inb.getStat()) state = inb.execute(s) Tasks.Command.displayTaskState(inb.getStat()) if state != TaskStatus.PASS: exit() #configure dsn on Linux cld = CreateLinuxDSNTask() Tasks.Command.displayTaskState(cld.getStat()) state = cld.execute(s) Tasks.Command.displayTaskState(cld.getStat()) if state != TaskStatus.PASS: exit() #configure the performance counter and log size cnld = ConfigLinuxDiagTask() Tasks.Command.displayTaskState(cnld.getStat()) state = cnld.execute(s) Tasks.Command.displayTaskState(cnld.getStat()) if state != TaskStatus.PASS: exit() #configure iserver cus = ConfigUnixIServerTask() Tasks.Command.displayTaskState(cus.getStat()) state = cus.execute(s) Tasks.Command.displayTaskState(cus.getStat()) if state != TaskStatus.PASS: exit() #start iserver on Linux st = StartServerTask(); Tasks.Command.displayTaskState(st.getStat()) state = st.execute(s) Tasks.Command.displayTaskState(st.getStat()) # #start the test script on client. if state == TaskStatus.PASS: sct = StartClientTask() Tasks.Command.displayTaskState(sct.getStat()) sct.execute(s) Tasks.Command.displayTaskState(sct.getStat()) # monitor iserver mls = MonitorLinuxServerTask() Tasks.Command.displayTaskState(mls.getStat()) mls.execute(s) Tasks.Command.displayTaskState(mls.getStat()) #stop client stct = StopClientTask() Tasks.Command.displayTaskState(stct.getStat()) stct.execute(s) Tasks.Command.displayTaskState(stct.getStat()) # monitor iserver dlf = DownloadLogFileTask() Tasks.Command.displayTaskState(dlf.getStat()) state = dlf.execute(s) Tasks.Command.displayTaskState(dlf.getStat())
print "[9]:download log files" print "[10]:simulate iserver[quit]" print "[0]:quit" try: taskno = input("please choose the task you want to run:") except Exception as e: taskno = -1 while taskno<0 or taskno >10 : try: taskno = input("please input the right task number you want to execute:") except Exception as e: taskno = -1 if taskno == 1: #install build on Linux inb = InstallLinuxBuildTask() Tasks.Command.displayTaskState(inb.getStat()) try: state = inb.execute(s) except Exception as e: print "install build failed"+str(e) Tasks.Command.displayTaskState(inb.getStat()) if taskno == 2: #configure dsn on Linux cld = CreateLinuxDSNTask() Tasks.Command.displayTaskState(cld.getStat()) try: state = cld.execute(s) except Exception as e: print "create DSN failed."+str(e)