Changeset 11103
- Timestamp:
- 05/22/12 20:49:33 (13 months ago)
- Location:
- ossiedev/branches/jsnyder/trunk/tools/cornetApps
- Files:
-
- 6 modified
-
DomainMan/views.py (modified) (17 diffs)
-
LoginUser/views.py (modified) (1 diff)
-
cornetApps.db (modified) (previous)
-
settings.py (modified) (2 diffs)
-
settingsWeb.py (modified) (1 diff)
-
urls.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/jsnyder/trunk/tools/cornetApps/DomainMan/views.py
r11100 r11103 12 12 """ 13 13 14 """Checks if running locally or on the web by testing which Django settings are used 14 """ 15 Checks if running locally or on the web by testing which Django settings are used 15 16 """ 16 17 def isOnWeb(): … … 36 37 Connects to a node given its floor and number 37 38 Returns the SSHClient connected to the server 39 @param floor The floor of the node to connect to 40 @param num The number of the node to connect to 41 @param user The username to login with 42 @param password The password of the user to login with 43 @return The SSHClient connected to the server 38 44 """ 39 45 def connectViaNode(floor, num, user, password): … … 71 77 return 0 72 78 73 ''' 79 """ 74 80 Starts default nodeBooter at a given ip and port 75 81 @param ip: The ip address of the server for the nodes … … 77 83 @param user: The user's username with access to the node 78 84 @param password: The user's password 79 ''' 85 """ 80 86 def startNodebooter(request, floor, num, user, password): 81 87 floor = int(floor) … … 106 112 return 107 113 108 """Populate the list of device managers 114 """ 115 Populate the list of device managers from a given node 116 @param floor The floor of the node to connect to 117 @param num The number of the node to connect to 118 @param user The username to login with 119 @param password The password of the user to login with 120 @return An array of the list of device managers on the node 109 121 """ 110 122 def getDeviceManagers(floor, num, user, password): … … 115 127 return stdout.readlines() 116 128 117 """View for displaying device and domain managers 129 """ 130 View for displaying device and domain managers 131 @param request The Django request parameter for views 132 @param floor The floor of the node to connect to 133 @param num The number of the node to connect to 134 @param user The username to login with 135 @param password The password of the user to login with 136 @return HttpResponse object with template and local context dictionary or 137 Http404 if could not find user and password session variables 118 138 """ 119 139 def manager_view(request, floor, num, user, password): … … 122 142 request.session["user"] = user 123 143 request.session["password"] = password 124 print "user: "+user, password125 144 except: 126 145 raise Http404(u'Could not set user and password in session variables') … … 133 152 """ 134 153 Start a device manager and a domain manager 154 checks post and session variables. 155 execute command based domain and device manager options 156 @param request The Django request parameter for views 157 @return HttpResponse object with template and local context dictionary or 158 Http404 if could not find user and password session variables 135 159 """ 136 160 def startManager(request): … … 161 185 """ 162 186 Gets the parameters to run domain manager 187 @param request The Django request parameter for views 188 @return The correct command based on the domainLocation session variable 189 -D if the domain manager is located on the same node 190 nothing if the domain manager is located on a remote node 163 191 """ 164 192 def getDomain(request): … … 174 202 """ 175 203 Gets the device manager's xml file to run based on a given POST request 204 @param request The Django request parameter for views 205 @return The string command for the device manager xml file 206 returns Http404 if cannot find the device parameter in the post request 176 207 """ 177 208 def getDeviceXML(request): … … 189 220 """ 190 221 Sets up the domain manager ip address to run based on a given POST request 222 @param request The Django request parameter for views 223 @return The domain string options using the -ORBInitRef and ip address using corba 191 224 """ 192 225 def getDomainIP(request): … … 228 261 @param user: The user's username with access to the node 229 262 @param password: The user's password 263 @return HttpResponse with local variables as a context dictionary inserted into the console.html template 230 264 ''' 231 265 def nodeBooter_page(request, ip, port, user, password): … … 243 277 244 278 """ 245 Connect to a node through a form 279 Connect to a node through post variables 280 @param request Contains the post variables floor, number, user, and pass to connect to a node 281 @return The local variables as dictionary into the DomainMan/runningNodebooter.html template 282 If one of the post variables are not there, it will print a "Missing ssh connection parameters" string 246 283 """ 247 284 def connect_to_node(request): … … 265 302 """ 266 303 Raise exception if the inputs of the floor and node number are invalid 304 @param floor The given floor to check 305 @param num The given node number to check 306 @return Exception if the floor or node num is less than 1 or greater than 4 or 12, respectively 267 307 """ 268 308 def testValidInputs(floor, num): … … 273 313 274 314 #@login_required 315 """ 316 Loads the DomainMan/nodes.html template based on a logging into a specific node 317 @param floor_num The floor of the node to login to 318 @param node_num The node number of the node to login to 319 @return The HttpResponse object with the local variables added to the dictionary 320 """ 275 321 def loadNode(request, floor_num, node_num): 276 322 floor = int(floor_num) … … 289 335 """ 290 336 Returns connection form 337 @param selectFloor The floor of the node to login to 338 @param selectNum The node number of the node to login to 339 @return the HttpResponse object with the local variable dictionary in the DomainMan/connect.html template 291 340 """ 292 341 def connect_to_node_view(request, selectFloor, selectNum): … … 297 346 testValidInputs(selectedFloor, selectedNum) 298 347 return render_to_response('DomainMan/connect.html', locals(), RequestContext(request)) 299 300 def ajax_example(request):301 if not request.method == 'GET':302 name = "did not work"303 print request.GET304 return render_to_response('DomainMan/ajax_example.html', locals(), context_instance=RequestContext(request))305 response_dict = {}306 name = request.GET.get('name', False)307 total = request.GET.get('total', False)308 response_dict.update({'name': name, 'total': total})309 if total:310 try:311 total = int(total)312 except:313 total = False314 if name and total and int(total) == 10:315 response_dict.update({'success': True })316 else:317 response_dict.update({'errors': {}})318 if not name:319 response_dict['errors'].update({'name': 'This field is required'})320 if not total and total is not False:321 response_dict['errors'].update({'total': 'This field is required'})322 elif int(total) != 10:323 response_dict['errors'].update({'total': 'Incorrect total'})324 return render_to_response('DomainMan/ajax_example.html', response_dict, context_instance=RequestContext(request)) -
ossiedev/branches/jsnyder/trunk/tools/cornetApps/LoginUser/views.py
r11101 r11103 43 43 return render_to_response("HtmlPages/account_page.html", locals(), context_instance=RequestContext(request)) 44 44 45 ''' 45 """ 46 46 Redirects user to the main page. 47 ''' 47 """ 48 48 def logout_page(request): 49 49 logout(request) 50 50 return HttpResponseRedirect(url_on_web('/')) 51 51 52 ''' 52 """ 53 53 Create user account in registration page 54 54 Checks for posting form. 55 ''' 55 """ 56 56 def register_page(request): 57 57 if request.method == 'POST': -
ossiedev/branches/jsnyder/trunk/tools/cornetApps/settings.py
r11073 r11103 1 2 3 1 # Django settings for running cornetApps project *locally* 4 2 … … 15 13 'default': { 16 14 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 17 #'NAME': 'cornetApps.db', # Or path to database file if using sqlite3.18 15 'NAME': 'cornetApps.db', #webserver 19 16 'USER': '', # Not used with sqlite3. -
ossiedev/branches/jsnyder/trunk/tools/cornetApps/settingsWeb.py
r11073 r11103 13 13 'default': { 14 14 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 15 #'NAME': 'cornetApps.db', # Or path to database file if using sqlite3.16 'NAME': '/home/webdemo/cornetApps/cornetApps.db', # webserver15 #'NAME': 'cornetApps.db', # webserver 16 'NAME': '/home/webdemo/cornetApps/cornetApps.db', #Or path to database file if using sqlite3. 17 17 'USER': '', # Not used with sqlite3. 18 18 'PASSWORD': '', # Not used with sqlite3. -
ossiedev/branches/jsnyder/trunk/tools/cornetApps/urls.py
r11100 r11103 43 43 url(r'^DomainMan/managers/(?P<floor>\d{1})/(?P<num>\d+)/(?P<user>.*)/(?P<password>.*)/$', 'DomainMan.views.manager_view'), 44 44 url(r'^DomainMan/startManager/$', 'DomainMan.views.startManager'), 45 url(r'^xhr_test/$', 'DomainMan.views.xhr_test'),46 url(r'^ajax/$', 'DomainMan.views.ajax_example'),47 45 48 46 # url(r'^cornetApps/', include('cornetApps.foo.urls')),