- Timestamp:
- Jan 21, 2013 11:49:03 AM (12 years ago)
- Branches:
- master
- Children:
- 06a2b49
- Parents:
- 2dc99e3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/desktop_access.py
r2dc99e3 r5dbcc93 276 276 'FreeBSD will not route based on src address') 277 277 elif gw is not None: 278 print >>script, ' sudoroute add %s %s' % (dest, gw)278 print >>script, 'route add %s %s' % (dest, gw) 279 279 elif sys.platform.startswith('linux'): 280 280 if src is not None and gw is not None: 281 print >>script, ' sudoip route add %s via %s src %s' % \281 print >>script, 'ip route add %s via %s src %s' % \ 282 282 (dest, gw, src) 283 283 elif src is not None: 284 print >>script, ' sudoip route add %s src %s' % \284 print >>script, 'ip route add %s src %s' % \ 285 285 (dest, src) 286 286 elif gw is not None: 287 print >>script, ' sudoip route add %s via %s' % (dest, gw)287 print >>script, 'ip route add %s via %s' % (dest, gw) 288 288 else: 289 289 raise service_error(service_error.internal, … … 293 293 rv = 0 294 294 if sys.platform.startswith('freebsd'): 295 print >>script, ' sudoroute delete %s' % dest295 print >>script, 'route delete %s' % dest 296 296 elif sys.platform.startswith('linux'): 297 print >>script, ' sudoip route delete %s' % dest297 print >>script, 'ip route delete %s' % dest 298 298 299 299 def find_a_peer(self, addr): … … 368 368 cscript = os.path.join(self.localdir, 'connect') 369 369 dscript = os.path.join(self.localdir, 'disconnect') 370 local_hosts = os.path.join(self.localdir, 'hosts') 370 371 try: 371 372 f = open(cscript, 'w') … … 379 380 print >>f,'while ! /usr/bin/scp -o "StrictHostKeyChecking no" -i %s %s:/usr/local/federation/etc/prep_done /dev/null; do' % (self.ssh_identity, peer) 380 381 print >>f, 'sleep 60; done' 381 print >>f, ('s udo ssh -w 0:0 -p %s -o "Tunnel ethernet" ' + \382 print >>f, ('ssh -w 0:0 -p %s -o "Tunnel ethernet" ' + \ 382 383 '-o "StrictHostKeyChecking no" -i %s %s perl -I/usr/local/federation/lib /usr/local/federation/bin/setup_bridge.pl --tapno=0 --addr=%s &') % \ 383 384 (port, self.ssh_identity, peer, my_addr) 384 385 # This should give the tap a a chance to come up 385 386 print >>f,'sleep 10' 386 # Assign its address and route connections through it. 387 print >>f, 'sudo ifconfig tap0 %s netmask 255.255.255.0 up' % \ 387 # Add experiment nodes to hosts 388 print >>f, 'cp /etc/hosts /etc/hosts.DETER.fedd.hold' 389 print >>f, 'echo "#--- BEGIN FEDD ADDITIONS ---" >> /etc/hosts' 390 print >>f, 'cat %s >> /etc/hosts' % local_hosts 391 print >>f, 'echo "#--- END FEDD ADDITIONS ---" >> /etc/hosts' 392 # Assign tap address and route experiment connections through it. 393 print >>f, 'ifconfig tap0 %s netmask 255.255.255.0 up' % \ 388 394 my_addr 389 395 self.set_route('10.0.0.0/8', f, exp_peer) … … 392 398 f = open(dscript, 'w') 393 399 print >>f, '#!/bin/sh' 394 print >>f, ' sudoifconfig tap0 destroy'400 print >>f, 'ifconfig tap0 destroy' 395 401 self.unset_route(peer, f) 396 402 self.unset_route('10.0.0.0/8', f) 403 print >>f, 'mv /etc/hosts.DETER.fedd.hold /etc/hosts' 397 404 f.close() 398 405 os.chmod(dscript, 0755) … … 400 407 raise service_error(service_error.internal, 401 408 'Cannot create connect %s: %s' % (e.filename, e.strerror)) 402 #subprocess.call(['/bin/sh', cscript]) 409 script_log = open('/tmp/connect.log', 'w') 410 subprocess.Popen(['sudo', '/bin/sh', cscript], stdout=script_log, stderr=script_log) 403 411 return True 404 412 … … 537 545 cscript = os.path.join(self.localdir, 'connect') 538 546 dscript = os.path.join(self.localdir, 'disconnect') 539 # XXX restore this540 #if os.path.exists(dscript):541 #self.log.debug('calling %s' % dscript)542 #rv = subprocess.call(['/bin/sh', dscript])543 #if rv != 0:544 #self.log.warning('%s had an error: %d' % (dscript, rv))545 #else:546 #self.log.warn('No disconnection script!?')547 # Do the work of disconnecting 548 if os.path.exists(dscript): 549 self.log.debug('calling %s' % dscript) 550 rv = subprocess.call(['sudo', '/bin/sh', dscript]) 551 if rv != 0: 552 self.log.warning('%s had an error: %d' % (dscript, rv)) 553 else: 554 self.log.warn('No disconnection script!?') 547 555 548 556 try:
Note: See TracChangeset
for help on using the changeset viewer.