Example #1
0
 def recursiveRename(self, newName):
     if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
         print utils.whoami()
         print utils.whataremyargs()
     
     self.__envAgent.agentName = newName + '_env'
     self.__envAgent.recursiveRename(newName)
Example #2
0
    def setMotherAgent(self, mother, realName):

#        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
#            print utils.whoami()
#            print utils.whataremyargs()
#
#        self.agentName = realName
#        self.__realName = realName
#        #if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
#        #    print self.agentName, " inherits from ", mother.agentName
#        self.__motherAgent = mother
#        mother.__childrenAgents[self.agentName] = self
#
#
#        self.recursiveRename('_' + self.agentName)
#        self.__envAgent.server = self.agentName
#        self.__envAgent.getFstab().server = self.agentName
#

        #More recent system, but with a flaw
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()
        
        self.agentName = realName
        #if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
        #    print self.agentName, " inherits from ", mother.agentName
        self.__motherAgent = mother
        mother.__childrenAgents[self.agentName] = self
        self.recursiveRename(self.agentName)
        self.__envAgent.server = self.agentName
        self.__envAgent.getFstab().server = self.agentName
Example #3
0
    def recursiveRename(self, suffix):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()
            
        for fa in self.__fileAgentList:
            #fa.agentName += suffix
            nn = self.getNeedName(fa)
            fa.recursiveRename(suffix)

        for fa in self.__folderAgentList:
            nn = self.getNeedName(fa)
            fa.recursiveRename(suffix)

        for pa in self.__processAgentList:
            nn = self.getNeedName(pa)
            #pa.agentName += suffix
            pa.recursiveRename(suffix)
        for co in self.__coordinatorList:
            #if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            #    print "I change name of ", co.agentName
            nn = self.getNeedName(co)
            co.__selfRename(suffix)
            co.recursiveRename("_" + nn + suffix)
            
        #experimental and probably not the good solution : 
        # rename also the destination of the triggers
        for fa in self.__fileAgentList:
            fa.renameTriggers(suffix)

        for fa in self.__folderAgentList:
            fa.renameTriggers(suffix)

        for pa in self.__processAgentList:
            pa.renameTriggers(suffix)
Example #4
0
    def addAttachedCoordinator(self, coord):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        if coord not in self.attachedCoords:
            self.attachedCoords.append(coord)
Example #5
0
    def addAttachedCoordinatorName(self, coordName):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.attachedCoordNames.append(coordName)
        print "ATTACHED %s"%self.attachedCoordNames
Example #6
0
    def assignNeeds(self, needName, needValue):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()
        
        # if there was already a need, writing on top of the needsAssignmentDic is not enough
        # we need to remove also the object in the process/file/folder/coord list
        print "needsAssignmentDic : %s"%self
        if ( needName in self.__needsAssignmentDic ):
            listFromWhichToDel = None
            agentToDel = self.__needsAssignmentDic[needName]
            print "STEP 1 agent to del : --%s--"%agentToDel
            if self.__needsDic[needName] == "Coordinator":
                listFromWhichToDel = self.__coordinatorList
            elif (self.__needsDic[needName] == "ProcessAgent"):
                listFromWhichToDel = self.__processAgentList
            elif self.__needsDic[needName] == "FileAgent":
                listFromWhichToDel = self.__fileAgentList
            elif self.__needsDic[needName] == "FolderAgent":
                listFromWhichToDel = self.__folderAgentList
            
            listFromWhichToDel.remove(agentToDel)

    
        self.__needsAssignmentDic[needName] = needValue
        if self.__needsDic[needName] == "Coordinator":
            self.__coordinatorList.append(needValue)
            if needValue.totalSet == False:
                needValue.total = self.__needsTotal[needName]    
        elif (self.__needsDic[needName] == "ProcessAgent"):
            self.__processAgentList.append(needValue)
        elif self.__needsDic[needName] == "FileAgent":
            self.__fileAgentList.append(needValue)
        elif self.__needsDic[needName] == "FolderAgent":
            self.__folderAgentList.append(needValue)
Example #7
0
    def setMotherAgent(self, mother, realName):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()
        
        self.agentName = realName
        self.__realName = realName
        self.totalSet = True
        #if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
        #    print self.agentName, " inherits from ", mother.agentName
        self.__motherAgent = mother
        mother.__childrenAgents[self.agentName] = self


        #OLD SYSTEM, DOES NOT WORK BUT KEEP FOR RECORD
        #copy of the mother attributes
        #self.__variables = copy.deepcopy(mother.__variables)
        #self.__needsDic = copy.deepcopy(mother.__needsDic)
        
        #self.__needsAssignmentDic = copy.deepcopy(mother.__needsAssignmentDic )
        #self.__fileAgentList = copy.deepcopy(mother.__fileAgentList)
        #self.__processAgentList = copy.deepcopy(mother.__processAgentList)
        #self.__coordinatorList = copy.deepcopy(mother.__coordinatorList)

        #NEW METHOD, NOT SURE IF THIS WILL REALLY WORK...
        #realName = self.agentName
        #self = copy.deepcopy(mother)
        #self.agentName = realName


        self.recursiveRename('_' + self.agentName)
Example #8
0
    def __selfRename(self, suffix):
#        print "I rename myself (%s, %s) + %s -> %s" % (self.__realName, self.__suffix, suffix, self.__realName + suffix)
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.__suffix = suffix
        self.agentName = self.__realName + suffix
Example #9
0
    def __init__(self, agentName):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        fileAgentParser.FileAgent.__init__(self,agentName)
        self.maxDepth = 0
        self.filenameFilters = []
Example #10
0
    def setMotherAgent(self, mother):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD :
            print utils.whoami()
            print utils.whataremyargs()

        self.contents = copy.deepcopy(mother.contents)
        #self.envVarFile.agentName = 'babla'
        MetaAgent.setMotherAgent(self, mother)
Example #11
0
    def removeAttachedCoordinatorName(self, coordName):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        try:
            self.attachedCoordNames.remove(coordName)
        except:
            raise 'No Coordinator "%s" attached to server %s'%(coordName, self.agentName)
Example #12
0
    def setMotherAgent(self, mother):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.envVarFile = copy.deepcopy(mother.envVarFile)
        # self.envVarFile.agentName = 'babla'
        self.envVarFile.recursiveRename(self.agentName)
        MetaAgent.setMotherAgent(self, mother)
Example #13
0
    def recursiveRename(self, suffix):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        MetaAgent.recursiveRename(self, suffix)
        if self.__childProcessAgent:
            self.__childProcessAgent.recursiveRename("_c_" + suffix)
        self.envVarFile.recursiveRename(suffix)
Example #14
0
    def assignVariable(self, varName, value):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        MetaAgent.assignVariable(self, varName, value)
        if self.__childProcessAgent:
            self.__childProcessAgent.assignVariable(varName, value)
        self.envVarFile.assignVariable(varName, value)
Example #15
0
    def setClassification(self, classification):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.classification = classification
        cId = 0
        for c in self.__coordinatorList:
            c.setClassification("%s-%s"%(classification,cId))
            cId += 1
Example #16
0
 def addNeeds(self, name, typeOfNeed, occurrence, total=None):
     if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
         print utils.whoami()
         print utils.whataremyargs()
         
     self.__needsDic[name] = typeOfNeed
     self.__needsOccurrence[name] = occurrence       
     if total:
         #total should be != None only if we have a coordinator
         self.__needsTotal[name] = total
Example #17
0
    def __init__(self, agentName):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.agentName = agentName
        
        self.__isFullyDefined = None
        self.__childrenAgents = {}
        self.attachedCoords = []
        self.attachedCoordNames = []
Example #18
0
    def addAttribute(self, attribute, value):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        if attribute in self.allowedAttributes:
            setattr(self, attribute, value)
        else:
            self.__envAgent.addAttribute(attribute, value)
        for child in self.__childrenAgents.values():
            child.addAttribute(attribute, value)
Example #19
0
    def __init__(self, agentName):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

	self.maxLoad = 2
	self.maxMemory = 100
	self.maxSwap = 99
        self.ignoredFS = Set([])

        self.agentName = agentName
Example #20
0
    def __init__(self, agentName):
        MetaAgent.__init__(self, agentName)
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.__limits = {}
        self.command = ""
        self.service = ""
        self.maxCpu = 100
        self.maxMemory = 100
        self.multiplicity = -1
Example #21
0
    def __init__(self, agentName):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        MetaAgent.__init__(self,agentName)
        self.contents = []
        
        self.owner = ''
        self.grp = ''
        self.attributes = ''
        self.permissions = ''
        self.md5 = ''
Example #22
0
    def addAttribute(self, attribute, value):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        if attribute in self.__limit_names.keys():
            self.__limits[self.__limit_names[attribute]] = value
        elif attribute == "envVar":
            self.envVarFileUsed = True
            self.envVarFile.addContent(value)
        else:
            MetaAgent.addAttribute(self, attribute, value)
        if attribute == "server":
            self.envVarFile.addAttribute(attribute, value)
Example #23
0
    def setParentProcessAgent(self, parent):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print self.agentName, " has parents ", parent.agentName
        self.__parentProcessAgent = parent
        parent.__childProcessAgent = self
        # copy of the parent attributes
        self.variables = copy.deepcopy(parent.variables)
        self.__limits = copy.deepcopy(parent.__limits)
        for arg in self.__dir__():
            setattr(self, arg, getattr(parent, arg))

        # TEST TO SEE IF my envFile can inherit from the one of my parent process
        self.envVarFileUsed = parent.envVarFileUsed
        self.envVarFile.setMotherAgent(parent.envVarFile)
Example #24
0
    def addAttribute(self, attribute, value):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        if (value[0] == '$'):
            if (value in self.__variables): #if the variable name already exists
                self.__variables[value].append(attribute)
            
            else:
                self.__variables[value] = [attribute]
        #setattr(self, attribute, value)
        if attribute in self.allowedAttributes:
            setattr(self, attribute, value)
        elif attribute == "mountpoint":
            self.__fstabAgent.addContent(value)
        elif attribute == "ignoreFs":
            self.ignoredFS.add(value)
        else:
            print "SPE (%s, %s)"%(attribute, value)
Example #25
0
    def assignVariable (self, varName, value):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()
        
        #is this first if statement ever true??
        if (self.__variables.has_key(varName)):

            # test to see if we could use : "requires $var"
            # Conclusion : does not work yet because what is append to __requiredCoordinator
            # are object and not text
            #if varName in self.__requiredCoordinator:
            #    del self.__requiredCoordinator[varName]
            #    self.__requiredCoordinator.append(value)
                
            for att in self.__variables[varName]: 
                #make sure we did not modify the variable yet
                if getattr(self, att) == varName:
                    setattr(self, att, value)
                else:
                    pass 
            #remove the variable from the list
            del self.__variables[varName]

        for fa in self.__fileAgentList:
            #print "Coord forward (%s,%s) to %s" % (varName, value, fa.agentName)
            fa.assignVariable(varName, value)

        for fa in self.__folderAgentList:
            #print "Coord forward (%s,%s) to %s" % (varName, value, fa.agentName)
            fa.assignVariable(varName, value)

        for pa in self.__processAgentList:
            #print "Coord forward (%s,%s) to %s" % (varName, value, pa.agentName)

            pa.assignVariable(varName, value)

        for co in self.__coordinatorList:
            #print "Coord forward (%s,%s) to %s" % (varName, value, co.agentName)
            co.assignVariable(varName, value)
Example #26
0
    def addAttribute (self, attribute, value):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()
        

        for fa in self.__fileAgentList:
            #print "Coord forward (%s,%s) to %s" % (attribute, value, fa.agentName)
            fa.addAttribute(attribute, value)

        for fa in self.__folderAgentList:
            #print "Coord forward (%s,%s) to %s" % (attribute, value, fa.agentName)
            fa.addAttribute(attribute, value)

        for pa in self.__processAgentList:
            #print "Coord forward (%s,%s) to %s" % (attribute, value, pa.agentName)

            pa.addAttribute(attribute, value)

        for co in self.__coordinatorList:
            #print "Coord forward (%s,%s) to %s" % (attribute, value, co.agentName)
            co.addAttribute(attribute, value)
Example #27
0
    def __init__(self, agentName):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.agentName = agentName
        self.__realName = agentName
        self.__childrenAgents = {} #name : agent
        self.__variables = {} # variable name, arg that uses it
        self.__needsDic = {}
        self.__needsTotal = {}
        self.__needsOccurrence = {}
        self.__needsAssignmentDic = {}
        self.__fileAgentList = []
        self.__folderAgentList = []
        self.__processAgentList = []
        self.__coordinatorList = []
        self.__isFullyDefined = None
        self.totalSet = False
        self.__classification = ""
        self.__requiredCoordinator = []
        self.tolerate = 0
        self.veto = []
Example #28
0
    def addContent(self, content):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.contents.append(content)
Example #29
0
    def addFilenameFilter(self, nameFilter):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.filenameFilters.append(nameFilter)
Example #30
0
    def setIsFullyDefined(self, value):
        if runtime.DEBUG_MODE & runtime.OBJ_METHOD:
            print utils.whoami()
            print utils.whataremyargs()

        self.__isFullyDefined = value