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)
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
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)
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)
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
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)
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)
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
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 = []
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)
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)
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)
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)
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)
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
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
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 = []
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)
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
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
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 = ''
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)
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)
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)
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)
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)
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 = []
def addContent(self, content): if runtime.DEBUG_MODE & runtime.OBJ_METHOD: print utils.whoami() print utils.whataremyargs() self.contents.append(content)
def addFilenameFilter(self, nameFilter): if runtime.DEBUG_MODE & runtime.OBJ_METHOD: print utils.whoami() print utils.whataremyargs() self.filenameFilters.append(nameFilter)
def setIsFullyDefined(self, value): if runtime.DEBUG_MODE & runtime.OBJ_METHOD: print utils.whoami() print utils.whataremyargs() self.__isFullyDefined = value