Show
Ignore:
Timestamp:
04/13/12 10:48:59 (14 months ago)
Author:
edent
Message:

edit WebDash? javascript

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/jsnyder/trunk/tools/cornetApps/DomainMan/views.py

    r11096 r11098  
    1212 
    1313""" 
    14 Testing login 
    15 """ 
    16 def cornet_login(request): 
    17     user = request.user 
    18     return render_to_response('DomainMan/cornet_login.html', locals(), context_instance=RequestContext(request)) 
    19  
     14Checks if running locally or on the web by testing which Django settings are used 
     15""" 
     16def isOnWeb(): 
     17    if environ['DJANGO_SETTINGS_MODULE'] == 'cornetApps.settingsWeb': 
     18        return 1 
     19    if environ['DJANGO_SETTINGS_MODULE'] == 'cornetApps.settings': 
     20        return 0 
     21     
    2022""" 
    2123Connects to a server through a given ip, port and associated username and password  
     
    3133    return client 
    3234 
     35""" 
     36Connects to a node given its floor and number 
     37Returns the SSHClient connected to the server 
     38""" 
     39def connectViaNode(floor, num, user, password): 
     40    floor = int(floor) 
     41    num = int(num) 
     42    node = Node(floor, num) 
     43    ip = node.ip 
     44    port = node.port 
     45    client = SSHClient() 
     46    client.set_missing_host_key_policy(AutoAddPolicy()) 
     47    try: 
     48        client.connect(ip, int(port), user, password) 
     49    except: 
     50        raise Http404(u'Incorrect username and password combination') 
     51    return client 
     52 
    3353''' 
    3454Tests if nodebooter is running. 
     
    5171    return 0 
    5272 
    53 ''' 
    54 Starts nodeBooter at a given ip and port 
     73""" 
     74Views the available nodeBooters to start 
     75""" 
     76def selectNodeboter(request, floor, num, user, password): 
     77    client = connectViaNode(floor, num, user, password) 
     78     
     79    client.close 
     80    return 
     81 
     82''' 
     83Starts default nodeBooter at a given ip and port 
    5584@param ip: The ip address of the server for the nodes 
    5685@param port: The port, typically 22 
     
    6897    client.exec_command('cd /sdr ; nodeBooter -D -d dev/nodes/default_GPP_node/DeviceManager.dcd.xml') 
    6998    runningNodebooter = nodeBooter_running(client) 
     99    client.close 
    70100    return render_to_response('DomainMan/runningNodebooter.html', locals(), context_instance=RequestContext(request)) 
    71101 
     
    93123    ip = node.ip 
    94124    port = node.port 
    95     client = connect(ip, port, user, password) 
     125    client = connect(ip, port, user, password)    
    96126    stdin, stdout, stderr = client.exec_command('killall nodeBooter && killall GPP') 
    97127    runningNodebooter = nodeBooter_running(client) 
     128    client.close 
    98129    return render_to_response('DomainMan/runningNodebooter.html', locals(), context_instance=RequestContext(request)) 
    99130 
     
    114145        stdin, stdout, stderr = client.exec_command('cd /sdr; nodeBooter -D -d dev/nodes/default_GPP_node/DeviceManager.dcd.xml') 
    115146    runningNodebooter = nodeBooter_running(client) 
     147    client.close 
    116148    return render_to_response('DomainMan/console.html', locals(), context_instance=RequestContext(request)) 
    117149 
    118 """ 
    119 Views the available nodeBooters to start 
    120 """ 
    121 def selectNodeboter(): 
    122     return 
     150 
    123151 
    124152""" 
     
    137165        client = connect(ip, port, user, password) 
    138166        runningNodebooter = nodeBooter_running(client) 
     167        client.close 
    139168    else: 
    140169        message = 'Missing ssh connection parameters' 
     
    159188    ip = node.ip 
    160189    port = node.port 
     190    if isOnWeb(): 
     191        address = str(ip) + ":" + str(port) 
     192    else: 
     193        address = str(ip) 
    161194    #index2(request, ip) 
    162195    return render_to_response("DomainMan/nodes.html", locals(), context_instance=RequestContext(request))