Exemple #1
0
def server_edit_view(request):
    serverName = request.matchdict['serverName']
    
    configPath= _getServerConfigPath(serverName)
    INIFileDict = _loadServerConfig(serverName)
    
    #testerType = INIFileDict["tester"]["type"]
    INIFileTemplate = _loadServerINITemplate()
    
    INIFileDict = __fillINIwithTemplate(INIFileTemplate,INIFileDict)
    
    multiListChoices = _makeMultichoice("server","tests",lambda: getAvailableServerTesters(serverName),INIFileDict)
    multiListChoices = _makeMultichoice("server","outlets",lambda: getAvailableServerOutlets(serverName),INIFileDict,multiListChoices)
    multiListChoices = _makeMultichoice("server","controls",lambda: getAvailableServerControls(serverName),INIFileDict,multiListChoices)
    
    multiListChoices = _makeMultichoice("server","dependencies",lambda: getServerAvilableDependencies(serverName),INIFileDict,multiListChoices)
    
    #multiListChoices = _makeSelectMulitChoice(testerType,"tester",getAvailableTestersList)

    return {"layout": site_layout(),
            "config_sidebar_head" : config_sidebar_head(),
            "config_sidebar_body" : config_sidebar_body(),
            "INI_InputArea_head" : INI_InputArea_head(),
            "INI_InputArea_body" : INI_InputArea_body(),
            "INIFileDict" : INIFileDict,
            "INIFileTemplate" : INIFileTemplate,
            "configPath" : configPath,
            "serverName" : serverName,
            "multiListChoices" : multiListChoices,
            "deleteCallback" : "server",
            "objectName" : str(serverName),
            "redirectURL" : "/",
            
            "page_title": "Server Edit: " + str(serverName)}
Exemple #2
0
def _server_obj_edit_view(request,obj,objGenerator,objGeneratorConfigCallback,getObjGeneratorsCallback,objGeneratorTemplateCallback):
    ''' Get the edit dict of a server object (like outlet, tester, etc)
    
    :param obj: the name of the object in the server (eg. outlet)
    :param objName: The name of the object
    :param objGenerator: the name of the object generator (eg. pdu)
    :param objGeneratorConfigCallback: a callback the returns the object's config dict 
    :param getObjGeneratorsCallback: A callback that gets the available object generators
    :param objGeneratorTemplateCallback: A callback that gets the template dict of the object generator
    :param existingOBJJavascriptCallback: The ockle javascript command to check if 
    :return: dict for the edit view
    '''
    serverName = request.matchdict['serverName']
    objName = request.matchdict[obj]
    objParam = obj +  "Params"
    
    configPath= _getServerConfigPath(serverName)
    tmpINIFileDict = _loadServerConfig(serverName)
    INIFileDict = OrderedDict() 
    INIFileDict[objName] = tmpINIFileDict[objName]
    objGeneratorName =  INIFileDict[objName][objGenerator.lower()]
    
    objType = objGeneratorConfigCallback(objGeneratorName)[objGenerator.lower()]["type"]
    INIFileTemplate = objGeneratorTemplateCallback(objType)
    
    #pop the main dict
    INIFileTemplate.pop(objGenerator.lower())
    
    if not objParam in INIFileTemplate:
        INIFileTemplate[objParam] = {}
    
    #add the type name
    INIFileTemplate[objParam][objGenerator.lower()] =["select",True]
    
    #Move outlet Params to the right name
    INIFileTemplate[objName] = INIFileTemplate[objParam]
    INIFileTemplate.pop(objParam)
    
    multiListChoices= _makeSelectMulitChoice(objGeneratorName,objName,objGenerator.lower(),getObjGeneratorsCallback)
    INIFileDict = __fillINIwithTemplate(INIFileTemplate,INIFileDict)
    
    return {"layout": site_layout(),
            "config_sidebar_head" : config_sidebar_head(),
            "config_sidebar_body" : config_sidebar_body(),

            "INI_InputArea_head" : INI_InputArea_head(),
            "INI_InputArea_body" : INI_InputArea_body(),            
            "INIFileDict" : INIFileDict,
            "INIFileTemplate" : INIFileTemplate,
            "multiListChoices" : multiListChoices,
            "OBJnameSection" : objName,
            "matchdict" : json.dumps(request.matchdict),
            "changeSavePathToName" : 'false',
            
            #Name field variables
            "configPath": configPath,
            #"existingOBJCallback" : existingOBJJavascriptCallback,
            
            #delete variables
            "deleteCallback" : obj,
            "objectName" : objName,
            "redirectURL" : "/server/" + serverName + "/edit" ,
            #section delete stuff
            "sectionDelete" : json.dumps({"sectionDelete" : objName}), #we are deleting a section only
            
            "page_title": serverName + ": Edit " + obj +" " + objName
            }