- Timestamp:
- 04/05/12 01:00:48 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/jsnyder/trunk/tools/cornetApps/DomainMan/views.py
r11092 r11093 58 58 @param password: The user's password 59 59 ''' 60 def startNodebooter(request, ip, port, user, password): 60 def startNodebooter(request, floor, num, user, password): 61 floor = int(floor) 62 num = int(num) 63 node = Node(floor, num) 64 ip = node.ip 65 port = node.port 61 66 client = connect(ip, port, user, password) 62 67 #stdin, stdout, stderr = client.exec_command('cd /sdr; nodeBooter -D -d dev/nodes/default_GPP_node/DeviceManager.dcd.xml') … … 82 87 @param password: The user's password 83 88 ''' 84 def stopNodebooter(request, ip, port, user, password): 89 def stopNodebooter(request, floor, num, user, password): 90 floor = int(floor) 91 num = int(num) 92 node = Node(floor, num) 93 ip = node.ip 94 port = node.port 85 95 client = connect(ip, port, user, password) 86 96 stdin, stdout, stderr = client.exec_command('killall nodeBooter && killall GPP') … … 106 116 return render_to_response('DomainMan/console.html', locals(), context_instance=RequestContext(request)) 107 117 108 """Connect to a nodebooter through a form 118 """ 119 Connect to a node through a form 109 120 """ 110 121 def connect_to_node(request): 111 122 if 'floor' in request.POST and 'number' in request.POST and 'user' in request.POST and 'pass' in request.POST: 112 postFloor = int(request.POST['floor'])113 postNum = int(request.POST['number'])123 floor = int(request.POST['floor']) 124 num = int(request.POST['number']) 114 125 user = str(request.POST['user']) 115 126 password = str(request.POST['pass']) 116 127 117 thisNode = Node(postFloor, postNum) 118 ip = thisNode.ip 119 port = thisNode.port 120 #thisNode.save() 121 #thisNode.setClient(user, password) 122 #node = Node.objects.get(floor=4, num=1) 128 node = Node(floor, num) 129 ip = node.ip 130 port = node.port 123 131 client = connect(ip, port, user, password) 124 #stdin, stdout, stderr = client.exec_command('ls')125 print 'calling runningNodebooter'126 132 runningNodebooter = nodeBooter_running(client) 127 133 else: … … 130 136 return render_to_response('DomainMan/runningNodebooter.html', locals(), context_instance=RequestContext(request)) 131 137 138 """ 139 Raise exception if the inputs of the floor and node number are invalid 140 """ 141 def testValidInputs(floor, num): 142 if floor < 1 or floor > 4: 143 raise Exception("Floor must be between 1 and 4") 144 if num < 1 or num > 12: 145 raise Exception("Node must be between 1 and 12") 146 132 147 #@login_required 133 148 def loadNode(request, floor_num, node_num): 134 149 floor = int(floor_num) 135 150 num = int(node_num) 136 if floor < 1 or floor > 4: 137 raise Exception("Floor must be between 1 and 4") 138 if num < 1 or num > 12: 139 raise Exception("Node must be between 1 and 12") 151 testValidInputs(floor, num) 140 152 node = Node(floor, num) 141 153 ip = node.ip 142 154 port = node.port 143 index2(request, ip) 155 address = str(ip)+":"+str(port) 156 index2(request, address) 144 157 return render_to_response("DomainMan/nodes.html", locals(), context_instance=RequestContext(request)) 145 158 146 """Returns connection form147 159 """ 148 def connect_to_node_view(request): 160 Returns connection form 161 """ 162 def connect_to_node_view(request, selectFloor, selectNum): 149 163 number_of_floors = range(1,5) 150 164 number_of_nodes = range(1,13) 165 selectedFloor=int(selectFloor) 166 selectedNum=int(selectNum) 167 testValidInputs(selectedFloor, selectedNum) 151 168 return render_to_response('DomainMan/connect.html', locals(), RequestContext(request)) 152 169