Ejemplo n.º 1
0
def server_create_view(request):
    INIFileTemplate = _loadServerINITemplate()
    
    INIFileTemplate['server']["name"] =["name",""]
    
    INIFileDict = __fillINIwithTemplate(INIFileTemplate,{})    
    
    
    
    INIFileDict['server']["tests"] =[]
    INIFileDict['server']["outlets"] =[]
    INIFileDict['server']["controls"] =[]
    INIFileDict['server']["dependencies"] =[]
    
    multiListChoices = _makeMultichoice("server","tests",lambda: {},INIFileDict)
    multiListChoices = _makeMultichoice("server","outlets",lambda: {},INIFileDict,multiListChoices)
    multiListChoices = _makeMultichoice("server","controls",lambda: {},INIFileDict,multiListChoices)
    multiListChoices = _makeMultichoice("server","dependencies",lambda: {},INIFileDict,multiListChoices)
    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" : "server",
            
            "configPathPrefix": getServerFolder() + "/",
            "existingOBJCallback" : "checkExistingServers" ,
            
            "page_title": "Add new Server"
            }
Ejemplo n.º 2
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)}
Ejemplo n.º 3
0
def _server_obj_create(request,obj,objGenerator,objGeneratorConfigCallback,objGeneratorTemplateCallback,getObjGeneratorsCallback,objNameExistJavascriptCallback):
    serverName = request.matchdict['serverName']
    PDU = request.matchdict[objGenerator]
    
    tmpName =  obj +"Params"
    #serverName
    pduType = objGeneratorConfigCallback(PDU)[objGenerator.lower()]["type"]
    tmpINIFileTemplate = objGeneratorTemplateCallback(pduType)
    
    #Here we move the template dict to the right name
    
    INIFileTemplate = {}
    INIFileTemplate[tmpName] = {}
    try:
        INIFileTemplate[tmpName] = tmpINIFileTemplate[obj +"Params"]
    except KeyError:
        pass    
    
    INIFileTemplate[tmpName]["name"] =["name",""]
    INIFileTemplate[tmpName][objGenerator.lower()] =["select",True]
    
    
    #Remove the pdu params if exist, we handle them in the server section
    try:
        INIFileTemplate.pop(objGenerator.lower())
    except KeyError:
        pass
    
    INIFileDict = __fillINIwithTemplate(INIFileTemplate)
    try:
        INIFileDict[tmpName][objGenerator.lower()] = PDU
    except KeyError:
        INIFileDict[tmpName] = {}
        INIFileDict[tmpName][objGenerator.lower()] = PDU
        
    multiListChoices= _makeSelectMulitChoice(PDU,tmpName,objGenerator.lower(),getObjGeneratorsCallback)
    
    configPath= os.path.join(getServerFolder() , serverName + '.ini')
    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" : tmpName,
            "matchdict" : json.dumps(request.matchdict),
            "changeSavePathToName" : 'false',
            
            "configPath": configPath,
            "existingOBJCallback" : objNameExistJavascriptCallback,
            
            "page_title": serverName + ": Add new " + obj +" using " + PDU
            }
Ejemplo n.º 4
0
def _obj_add_list_view(request,objGenerator,TypeList):
    return {"layout": site_layout(),
            "config_sidebar_head" : config_sidebar_head(),
            "config_sidebar_body" : config_sidebar_body(),
            "INI_InputArea_head" : INI_InputArea_head(),
            "TypeList" : TypeList,
            "typeCreatePath" :  objGenerator.lower() + "Create",
            "TypeCreateName" : "type of " + objGenerator +" to create:",
            "page_title": "Add new " + objGenerator +" - Select type from list"
            }
Ejemplo n.º 5
0
def servers_view(request):
    return {"layout": site_layout(),
            "config_sidebar_head" : config_sidebar_head(),
            "config_sidebar_body" : config_sidebar_body(),
            "ObjectList" : getServerDict(),
            "ObjectName" : "server",
            "ObjectClassName" : "server",
            "AddURL" : "/server_add",
            "ObjectURLCallback" : _objectEditUrl,
            "page_title": "Servers"}
Ejemplo n.º 6
0
def controllers_view(request):
    return {"layout": site_layout(),
            "config_sidebar_head" : config_sidebar_head(),
            "config_sidebar_body" : config_sidebar_body(),
            "ObjectList" : getControllerDict(),
            "ObjectName" : "controller",
            "ObjectClassName" : "controller",
            "AddURL" : "/controllers_add_list",
            "ObjectURLCallback" : _objectEditUrl,
            "page_title": "Controllers"}
Ejemplo n.º 7
0
def pdus_view(request):
    return {"layout": site_layout(),
            "config_sidebar_head" : config_sidebar_head(),
            "config_sidebar_body" : config_sidebar_body(),
            "ObjectList" : getPDUDict(),
            "ObjectName" : "PDU",
            "ObjectClassName" : "pdu",
            "AddURL" : "/pdus_add_list",
            "ObjectURLCallback" : _objectEditUrl,
            "page_title": "PDUs"}
Ejemplo n.º 8
0
def _servers_obj_add_list_view(request,obj,objDict,objGenerator):
    serverName = request.matchdict['serverName']
    
    for key in objDict.keys():
        objDict[key] = str(objDict[key][objGenerator]["comment"])

    return {"layout": site_layout(),
            "config_sidebar_head" : config_sidebar_head(),
            "config_sidebar_body" : config_sidebar_body(),
            "INI_InputArea_head" : INI_InputArea_head(),
            "TypeList" : objDict,
            "typeCreatePath" : "server/" + serverName + "/" + obj + "Create",
            "TypeCreateName" : "from which " + obj + " the outlet is located",
            "page_title": serverName + ": Add new Server "+ obj +" - Select " + objGenerator +" from list"
            }
Ejemplo n.º 9
0
def _objGenerator_edit_view(request,objName,objGenerator,objURLName,getObjGenertorFolderCallback,objGeneratorConfigCallback,objGeneratorTemplateCallback,getAvilableObjGenetorsList):   
    ''' Make an edit view for an object generator (like a PDU or tester)
    
    :param request: The request from pyramid
    :param objName: the object name
    :param objGenerator: The name of the object generator
    :param objURLName: The url name that holds the name of the current object we are editing
    :param getObjGenertorFolderCallback: A function that returns the path of the object generator folder
    :param objGeneratorConfigCallback: A function the returns the object generator config
    :param objGeneratorTemplateCallback: A function that returns the template of the current object generator
    :param getAvilableObjGenetorsList: A callback that returns the current available object generators
    :return: A ready to render dict for the edit page
    '''
    PDUName = request.matchdict[objURLName]
    
    configPath= os.path.join(getObjGenertorFolderCallback() , PDUName + '.ini')
    INIFileDict = objGeneratorConfigCallback(PDUName)
    
    outletType = INIFileDict[objGenerator.lower()]["type"]
    INIFileTemplate = objGeneratorTemplateCallback(outletType)
    
    INIFileDict = __fillINIwithTemplate(INIFileTemplate,INIFileDict)
    
    #Remove the obj params if exist, we handle them in the server section
    try:
        INIFileTemplate.pop(objName + "Params")
    except:
        pass
    
    multiListChoices = _makeSelectMulitChoice(outletType,objGenerator.lower(),"type",getAvilableObjGenetorsList)

    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,
            "multiListChoices" : multiListChoices,
            "page_title": objGenerator + " Edit: " + str(PDUName),
            
            #delete-variables
            "deleteCallback" : objGenerator.lower(),
            "objectName" : PDUName,
            "redirectURL" : "/" + objGenerator.lower()  +"s"}
Ejemplo n.º 10
0
def _objGenerator_create(request,objName,objGenerator,loadObjGeneratorTemplate,getAvailableObjGeneratorsList,getObjGeneretorFolder):
    ''' Create a dict for an object Generator page
    
    :param objName: The name of the Server Object
    :param objGenerator: The name of the Server Object Generator
    :param loadObjGeneratorTemplate:  a callback to get the template of the object Generator
    :param getAvailableObjGeneratorsList: Get a list of the object generators
    :param getObjGeneretorFolder: Get the folder of the object generator
    :return: a dict ready to be rendered
    '''
    PDUType = request.matchdict[objGenerator.lower() + 'Type']
    INIFileTemplate = loadObjGeneratorTemplate(PDUType)

    #Remove the outlet params if exist, we handle them in the server section
    try:
        INIFileTemplate.pop(objName +"Params")
    except:
        pass

    INIFileTemplate[objGenerator.lower()]["name"] =["name",""]
    
    INIFileDict = __fillINIwithTemplate(INIFileTemplate,{})    
    
    INIFileDict[objGenerator.lower()]["type"] = PDUType
    multiListChoices = _makeSelectMulitChoice(PDUType,objGenerator.lower(),"type",getAvailableObjGeneratorsList)
    
    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" : objGenerator.lower(),
            
            "configPathPrefix": getObjGeneretorFolder() + "/",
            "existingOBJCallback" : "checkExisting"+ objGenerator +"s" ,
            
            "page_title": "Add new "+ objGenerator + ": " + PDUType
            }    
Ejemplo n.º 11
0
def config_view(request):
    
    pluginList = getINIFolderTemplate("plugins")
    
    configPath = "config.ini"
    INIFileDict = loadINIFileConfig(configPath)
    iniTemplate = loadINIFileTemplate([configPath] + pluginList)
    INIFileDict = __fillINIwithTemplate(iniTemplate,INIFileDict)
    
    multiListChoices = _makeMultichoice("plugins","pluginlist",getAvailablePluginsList,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(),
            "page_title": "General",
            "INIFileDict" : INIFileDict,
            "INIFileTemplate" : iniTemplate,
            "configPath" : configPath,
            "multiListChoices" : multiListChoices}
Ejemplo n.º 12
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
            }