Exemple #1
0
def index_view(request):
    ''' View of the server network
    '''
    #get Dot data
    dot= getServerTree()
    
    #Add generate an xdot file from the dot we got from the server
    gv = pgv.AGraph(string=dot,weights=False)
    #TODO: fix this ugly escape character, ie add a javascript variable wrapper
    #gv.node_attr.update(href="javascript:void(click_node(\\'\\\N\\'))")
    gv.node_attr.update(href="server/\\\N")
    gv.node_attr.update(title="\\\N")
    gv.node_attr.update(tooltip="\\\N")
    gv.node_attr.update(shape="ellipse")
    gv.node_attr.update(style="filled")
    gv.node_attr.update(fillcolor="#CBE6FF")
    gv.node_attr.update(fontname="Arial")
    gv.graph_attr.update(bgcolor="#F4F4F4")

    
    for node in gv.nodes():
        print node.get_name()
    
    gv.layout(prog='dot')
    
    #get autocontrol stuff
    autoControlStatus = getAutoControlStatus()["status"]
    return {"layout": site_layout(),
            "page_title": "Server Network View",
            "autoControlStatus" : autoControlStatus,
            "xdottree" : gv.draw(format="xdot").replace('\n','\\n\\\n')}
Exemple #2
0
def sendOckleCommand(request):
    ''' The function explicitly lists the commands we accept from the browser and then pass to Ockle as real commands
    '''
    command = request.json_body["command"]
    
    dataDict = {}
    try:
        dataDict = request.json_body["dataDict"]
    except:
        pass
    
    print command
    if command == "restart":
        restartOckle()
    
    if command == "checkExistingPDUs":
        try:
            return {"reply" : dataDict["name"] in getPDUDict()}
        except:
            return {"reply" : "Error"}
    
    if command == "checkExistingTesters":
        try:
            return {"reply" : dataDict["name"] in getTesterDict()}
        except:
            return {"reply" : "Error"}
    
    if command == "checkExistingServerOutlets":
        try:
            return {"reply" : dataDict["name"] in getAvailableServerOutlets(dataDict["matchdict"]["serverName"])}
        except:
            return {"reply" : "Error"}
    
    if command == "checkExistingServerTests":
        try:
            return {"reply" : dataDict["name"] in getAvailableServerTesters(dataDict["matchdict"]["serverName"])}
        except:
            return {"reply" : "Error"}
    
    if command == "checkExistingServerControls":
        try:
            return {"reply" : dataDict["name"] in getAvailableServerControls(dataDict["matchdict"]["serverName"])}
        except:
            return {"reply" : "Error"}
        
    if command == "checkExistingServers":
        try:
            return {"reply" : dataDict["name"] in getServerDict()}            
        except:
            return {"reply" : "Error"}
            
    if command == "deleteObject":
        return deleteObject(dataDict)
    
    if command == "setServer":
        return setServer(dataDict)
    
    if command == "switchOutlet":
        return switchOutlet(dataDict)
        
    if command == "switchControl":
        return switchControl(dataDict)
    
    if command == "runTest":
        return runTest(dataDict)
    
    if command == "getAutoControlStatus":
        return getAutoControlStatus()
    
    if command == "setAutoControlStatus":
        return setAutoControlStatus(dataDict)
    
    if command == "switchNetwork":
        return switchNetwork(dataDict)
        
    return dataDict