- Timestamp:
- 04/13/12 10:48:59 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/jsnyder/trunk/tools/cornetApps/DomainMan/views.py
r11096 r11098 12 12 13 13 """ 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 14 Checks if running locally or on the web by testing which Django settings are used 15 """ 16 def isOnWeb(): 17 if environ['DJANGO_SETTINGS_MODULE'] == 'cornetApps.settingsWeb': 18 return 1 19 if environ['DJANGO_SETTINGS_MODULE'] == 'cornetApps.settings': 20 return 0 21 20 22 """ 21 23 Connects to a server through a given ip, port and associated username and password … … 31 33 return client 32 34 35 """ 36 Connects to a node given its floor and number 37 Returns the SSHClient connected to the server 38 """ 39 def 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 33 53 ''' 34 54 Tests if nodebooter is running. … … 51 71 return 0 52 72 53 ''' 54 Starts nodeBooter at a given ip and port 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 82 ''' 83 Starts default nodeBooter at a given ip and port 55 84 @param ip: The ip address of the server for the nodes 56 85 @param port: The port, typically 22 … … 68 97 client.exec_command('cd /sdr ; nodeBooter -D -d dev/nodes/default_GPP_node/DeviceManager.dcd.xml') 69 98 runningNodebooter = nodeBooter_running(client) 99 client.close 70 100 return render_to_response('DomainMan/runningNodebooter.html', locals(), context_instance=RequestContext(request)) 71 101 … … 93 123 ip = node.ip 94 124 port = node.port 95 client = connect(ip, port, user, password) 125 client = connect(ip, port, user, password) 96 126 stdin, stdout, stderr = client.exec_command('killall nodeBooter && killall GPP') 97 127 runningNodebooter = nodeBooter_running(client) 128 client.close 98 129 return render_to_response('DomainMan/runningNodebooter.html', locals(), context_instance=RequestContext(request)) 99 130 … … 114 145 stdin, stdout, stderr = client.exec_command('cd /sdr; nodeBooter -D -d dev/nodes/default_GPP_node/DeviceManager.dcd.xml') 115 146 runningNodebooter = nodeBooter_running(client) 147 client.close 116 148 return render_to_response('DomainMan/console.html', locals(), context_instance=RequestContext(request)) 117 149 118 """ 119 Views the available nodeBooters to start 120 """ 121 def selectNodeboter(): 122 return 150 123 151 124 152 """ … … 137 165 client = connect(ip, port, user, password) 138 166 runningNodebooter = nodeBooter_running(client) 167 client.close 139 168 else: 140 169 message = 'Missing ssh connection parameters' … … 159 188 ip = node.ip 160 189 port = node.port 190 if isOnWeb(): 191 address = str(ip) + ":" + str(port) 192 else: 193 address = str(ip) 161 194 #index2(request, ip) 162 195 return render_to_response("DomainMan/nodes.html", locals(), context_instance=RequestContext(request))