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 "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)   
            Tasks.Command.displayTaskState(cld.getStat())

        if taskno == 3:
            #configure the performance counter and log size
            cnld = ConfigLinuxDiagTask()
            Tasks.Command.displayTaskState(cnld.getStat())
            state = cnld.execute(s)
            Tasks.Command.displayTaskState(cnld.getStat())

        if taskno == 4:
            #configure iserver
            cus = ConfigUnixIServerTask()
            Tasks.Command.displayTaskState(cus.getStat())
            state = cus.execute(s)
            Tasks.Command.displayTaskState(cus.getStat())

        if taskno == 5: 
            #start iserver on Linux
            st = StartServerTask();
            Tasks.Command.displayTaskState(st.getStat())