Changeset 11100

Show
Ignore:
Timestamp:
05/09/12 14:55:03 (13 months ago)
Author:
edent
Message:

give options for domain and device managers

Location:
ossiedev/branches/jsnyder/trunk/tools/cornetApps
Files:
4 added
5 modified

Legend:

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

    r11098 r11100  
    77from WebDash.views import index2 
    88 
    9 """Views for DomainMan application 
     9""" 
     10Views for DomainMan application 
    1011Starts and stops nodeBooter/naming service through paramiko 
    1112""" 
    1213 
    13 """ 
    14 Checks if running locally or on the web by testing which Django settings are used 
     14"""Checks if running locally or on the web by testing which Django settings are used 
    1515""" 
    1616def isOnWeb(): 
     
    7171    return 0 
    7272 
    73 """ 
    74 Views the available nodeBooters to start 
    75 """ 
    76 def selectNodeboter(request, floor, num, user, password): 
    77     client = connectViaNode(floor, num, user, password) 
    78      
    79     client.close 
    80     return 
    81  
    8273''' 
    8374Starts default nodeBooter at a given ip and port 
     
    110101#    return render_to_response('DomainMan/runningNodebooter.html', locals(), context_instance=RequestContext(request)) 
    111102 
    112 ''' 
    113 Kills all nodeBooter processes at a given ip and port 
     103"""Choose a device manager from a populated list 
     104""" 
     105def getDomainManagerCommand(): 
     106    return 
     107 
     108"""Populate the list of device managers 
     109""" 
     110def getDeviceManagers(floor, num, user, password): 
     111    client = connectViaNode(floor, num, user, password) 
     112    stdin, stdout, stderr = client.exec_command('cd /sdr; ls --format single-column dev/nodes/') 
     113    #stdin, stdout, stderr = client.exec_command('cd /sdr; ls') 
     114    client.close 
     115    return stdout.readlines() 
     116  
     117"""View for displaying device and domain managers 
     118""" 
     119def manager_view(request, floor, num, user, password): 
     120    deviceManagers = getDeviceManagers(floor, num, user, password) 
     121    try: 
     122        request.session["user"] = user 
     123        request.session["password"] = password 
     124        print "user: "+user, password 
     125    except: 
     126        raise Http404(u'Could not set user and password in session variables') 
     127    if len(deviceManagers) == 0: 
     128        message = "No device managers on this node" 
     129    floors = range(1,5) 
     130    nodes = range(1,13) 
     131    return render_to_response('DomainMan/managers.html', locals(), context_instance=RequestContext(request)) 
     132 
     133""" 
     134Start a device manager and a domain manager 
     135""" 
     136def startManager(request): 
     137    if 'floor' in request.POST and 'node' in request.POST: 
     138        if request.session.get('user') and request.session.get('password'): 
     139            sessionUser = request.session.get('user') 
     140            sessionPass = request.session.get('password') 
     141        else: 
     142            raise Http404(u'Could not get session user and password') 
     143        floor = int(request.POST['floor']) 
     144        node = int(request.POST['node']) 
     145        user = str(sessionUser) 
     146        password = str(sessionPass) 
     147        client = connectViaNode(floor, node, user, password) 
     148    else: 
     149        raise Exception('client could not connect with POST variables') 
     150     
     151    domain = getDomain(request) 
     152    device = getDeviceXML(request) 
     153    domainIP = getDomainIP(request) 
     154     
     155    command = "cd /sdr; nodeBooter "+domain+" "+device+" "+domainIP 
     156    print command 
     157    client.exec_command(command) 
     158    client.close 
     159    return render_to_response('DomainMan/runningNodebooter.html', {'command' : command}, context_instance=RequestContext(request)) 
     160 
     161""" 
     162Gets the parameters to run domain manager 
     163""" 
     164def getDomain(request): 
     165    if 'domainLocation' in request.POST: 
     166        if request.POST['domainLocation'] == 'same': 
     167            domain = "-D" 
     168        elif request.POST['domainLocation'] == 'remote': 
     169            domain = "" 
     170    else: 
     171        raise Http404(u'Could not get domain location from POST Request') 
     172    return domain 
     173 
     174""" 
     175Gets the device manager's xml file to run based on a given POST request 
     176""" 
     177def getDeviceXML(request): 
     178    if 'deviceManager' in request.POST: 
     179        if 'device' in request.POST: 
     180            deviceName = str(request.POST['device']) 
     181        else: 
     182            raise Http404(u'Could not get device manager name from POST request') 
     183        #rstrip removes the trailing \n character 
     184        deviceXML = "-d dev/nodes/"+deviceName.rstrip()+"/DeviceManager.dcd.xml" 
     185    else: 
     186        raise Http404(u'DeviceManager not selected in POST request') 
     187    return deviceXML 
     188 
     189""" 
     190Sets up the domain manager ip address to run based on a given POST request 
     191""" 
     192def getDomainIP(request): 
     193    if 'domain' in request.POST and 'floor' in request.POST and 'node' in request.POST: 
     194        if request.POST['domainLocation'] == 'remote': 
     195            floor = int(request.POST['floor']) 
     196            num = int(request.POST['node']) 
     197            node = Node(floor, num) 
     198            domainIP = "-ORBInitRef NameService=corbaname::"+node.ip 
     199        elif request.POST['domainLocation'] == 'same': 
     200            domainIP = "" 
     201    else: 
     202        raise Http404(u'POST request does not have a floor and node number') 
     203    return domainIP 
     204 
     205"""Kills all nodeBooter processes at a given ip and port 
    114206@param ip: The ip address of the server for the nodes 
    115207@param port: The port, typically 22 
    116208@param user: The user's username with access to the node 
    117209@param password: The user's password 
    118 ''' 
     210""" 
    119211def stopNodebooter(request, floor, num, user, password): 
    120212    floor = int(floor) 
  • ossiedev/branches/jsnyder/trunk/tools/cornetApps/templates/DomainMan/nodes.html

    r11099 r11100  
    1 <p>{{node}}<p> <p>IP: {{ip}} Port: {{port}}</p> 
    2 <div id="node_space"> 
     1<p>{{node}}</p> <p>IP: {{ip}} Port: {{port}}</p> 
     2<p><div id="node_space"> 
     3 
    34<!-- 
    45<a href='javascript:loadHrefToDiv("#node_space", "{{MEDIA_URL}}/connect/{{floor}}/{{num}}");'>Check Nodebooter</a> 
    56--> 
    67<a href="#" onclick='javascript:window.open("{{MEDIA_URL}}/connect/{{floor}}/{{num}}", "","width=400,height=300,location=0");'>Check Nodebooter</a> 
    7 </div> 
    8 <a href='javascript:loadHrefToDiv("#workspace", "{{MEDIA_URL}}/WebDash/index2/{{ip}}");'>View Waveforms</a> 
     8</div><p> 
     9 
     10<p><a href='javascript:loadHrefToDiv("#workspace", "{{MEDIA_URL}}/WebDash/index2/{{ip}}");'>View Waveforms</a></p> 
  • ossiedev/branches/jsnyder/trunk/tools/cornetApps/templates/DomainMan/runningNodebooter.html

    r11093 r11100  
    1212        <p><a href='{{MEDIA_URL}}/startNodeBooter/{{floor}}/{{num}}/{{user}}/{{password}}'>Start Nodebooter</a></p> 
    1313{% endif %} 
     14<p><a href="{{MEDIA_URL}}/DomainMan/managers/{{floor}}/{{num}}/{{user}}/{{password}}">Start Domain and Device Managers</a></p> 
  • ossiedev/branches/jsnyder/trunk/tools/cornetApps/urls.py

    r11098 r11100  
    4141    url(r'^connect/(\d{1})/(\d+)/$', 'DomainMan.views.connect_to_node_view'), 
    4242    url(r'^connect_to_node/$', 'DomainMan.views.connect_to_node'), 
     43    url(r'^DomainMan/managers/(?P<floor>\d{1})/(?P<num>\d+)/(?P<user>.*)/(?P<password>.*)/$', 'DomainMan.views.manager_view'), 
     44    url(r'^DomainMan/startManager/$', 'DomainMan.views.startManager'), 
    4345    url(r'^xhr_test/$', 'DomainMan.views.xhr_test'), 
    4446    url(r'^ajax/$', 'DomainMan.views.ajax_example'),