Beispiel #1
0
    def removeTestbed(self, testbedName):
        """
        Remove a testbed from the list: allTestbedNames
        """

        if self.testbedExists(testbedName) == True:
            # Write to a temp file
            tempFile = self.allTestbedNamesFile + '.temp'
            os.system('touch %s' % (tempFile))

            for eachTestbed in fileContents:
                if eachTestbed != testbedName:
                    infraLib.writeToFile(tempFile, eachTestbed + '\n')

            os.system('mv %s %s' % (tempFile, self.allTestbedNamesFile))
            print ('\n', 'Testbed %s removed' % testbedName, '\n')

        else:
            self.printErrorMsg('Error: No such testbed name to remove: %s' % testbedName)
Beispiel #2
0
    def Reprioritized(self, submissionId, newPriority):
        # Get a list of all the files with .manual-lock-waiting and .job-waiting.
        #    Check the submissionID
        #    If match, write existing contents to a temp file 
        #       and change the priority number

        if int(newPriority) > 7:
            print ('\n', 'Error: Priority number range is 0-7')
            print ('\t', 'You entered: %s' % (newPriority), '\n')
            exit

        # For reprioritization, we only do this for jobs that are waiting.
        # Otherwise, it doesn't matter
        waitingFileList = glob.glob(self.testbedDir + '*' + '.*waiting')

        if waitingFileList != []:
            isThereSuchSubmissionIdFlag = 0
            for eachWaitingFile in waitingFileList:
                fileContents = infraLib.getFileContents( eachWaitingFile )

                typeOfLock    = fileContents[0].split('=')[1]
                user          = fileContents[1].split('=')[1]
                date          = fileContents[2].split('=')[1]
                time          = fileContents[3].split('=')[1]
                priority      = fileContents[4].split('=')[1]
                submissionId2 = fileContents[5].split('=')[1]

                if submissionId == submissionId2:
                    isThereSuchSubmissionIdFlag = 1

                    # Change the priority by rewriting the waiting file with
                    # the new priority number
                    tempFile = eachWaitingFile + '.temp'
                    os.system('touch ' + tempFile)

                    infraLib.writeToFile(tempFile, 'typeOfLock=' + typeOfLock + '\n')
                    infraLib.writeToFile(tempFile, 'user='******'\n')
                    infraLib.writeToFile(tempFile, 'date=' + date + '\n')
                    infraLib.writeToFile(tempFile, 'time=' + time + '\n')
                    infraLib.writeToFile(tempFile, 'priority=' + newPriority + '\n')
                    infraLib.writeToFile(tempFile, 'submissionId=' + submissionId + '\n')

                    os.system('rm %s' % (eachWaitingFile))
                    os.system('mv %s %s' % (tempFile, eachWaitingFile))

            if isThereSuchSubmissionIdFlag == 0:
                self.printErrorMsg('No such submissionID found: %s' % submissionId)