Esempio n. 1
0
def parseAction_process_start(token):
    if runtime.DEBUG_MODE & runtime.OBJ_TRIGGER:
        print utils.whoami(), token
    if len(token) >= 2:  # only "processAgent" and the name of the agent
        ag = ProcessAgent(token[1])

    if len(token) == 2:  # only "processAgent" and the name of the agent

        envVarFile = FileAgent("envVariables_" + token[1])
        # envVarFile.recursiveRename(token[1])
        envVarFile.addAttribute("filename", "/proc/[pid]/env")
        ag.envVarFile = envVarFile

    if len(token) == 3:
        try:
            ag.setMotherAgent(runtime.core.getProcessAgent(token[2]))
        except Exception as inst:
            print "Cannot find mother agent called %s" % token[2]
            sys.exit(1)

    runtime.core.addProcessAgent(ag)
Esempio n. 2
0
def parseAction_server_start(token):
    print "SERVER START MERDE"
    if runtime.DEBUG_MODE & runtime.OBJ_TRIGGER:
        print utils.whoami(), token

    ag = Server(token[1])

    if len(token) == 2: #no inheritance

        env = EnvironmentAgent("%s_env" % token[1])
        env.addAttribute("server", token[1])
        fstabAg = FileAgent("%s_fstab" % token[1])
        fstabAg.addAttribute("server", token[1])
        fstabAg.addAttribute('filename', '/etc/fstab')
        env.setFstab(fstabAg)
        ag.setEnvironmentAgent(env)
        
    if len(token) == 3:

        # If just making a deepcopy, we copy everything, including the __childrenAgents attribute,
        # which is huge and useless (and wrong I think...). The memory grows exponentially,
        # and the parsing is stuck. So we save the __childrenAgents attribute of the mother,
        # empty it, copy the mother, and put it back to her
        motherChildren = runtime.core.getServer(token[2]).getChildrenAgents()
        runtime.core.getServer(token[2]).setChildrenAgents({})
        ag = copy.deepcopy(runtime.core.getServer(token[2]))
        runtime.core.getServer(token[2]).setChildrenAgents(motherChildren)

        ag.setMotherAgent(runtime.core.getServer(token[2]), token[1])




        #ag = copy.deepcopy(runtime.core.getServer(token[2]))
        #ag.setMotherAgent(runtime.core.getServer(token[2]), token[1])
        
    runtime.core.addServer(ag)