| 112 | | ''' |
| 113 | | Kills all nodeBooter processes at a given ip and port |
| | 103 | """Choose a device manager from a populated list |
| | 104 | """ |
| | 105 | def getDomainManagerCommand(): |
| | 106 | return |
| | 107 | |
| | 108 | """Populate the list of device managers |
| | 109 | """ |
| | 110 | def 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 | """ |
| | 119 | def 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 | """ |
| | 134 | Start a device manager and a domain manager |
| | 135 | """ |
| | 136 | def 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 | """ |
| | 162 | Gets the parameters to run domain manager |
| | 163 | """ |
| | 164 | def 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 | """ |
| | 175 | Gets the device manager's xml file to run based on a given POST request |
| | 176 | """ |
| | 177 | def 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 | """ |
| | 190 | Sets up the domain manager ip address to run based on a given POST request |
| | 191 | """ |
| | 192 | def 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 |