- Timestamp:
- 06/27/12 23:54:57 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
etherws/trunk/etherws.py
r166 r167 95 95 96 96 class FDB(DebugMixIn): 97 def __init__(self, ageout =300, debug=False):97 def __init__(self, ageout, debug=False): 98 98 self._ageout = ageout 99 99 self._debug = debug … … 427 427 raise ValueError('invalid port: %s' % args.port) 428 428 429 if args.ageout <= 0: 430 raise ValueError('invalid ageout: %s' % args.ageout) 431 432 ioloop = tornado.ioloop.IOLoop.instance() 433 fdb = FDB(ageout=args.ageout, debug=args.debug) 434 switch = SwitchingHub(fdb, debug=args.debug) 435 taps = [TapHandler(switch, dev, debug=args.debug) for dev in args.device] 436 429 437 handler = wrap_basic_auth(EtherWebSocketHandler, 430 438 load_htpasswd(args.htpasswd)) 431 432 fdb = FDB(debug=args.debug)433 switch = SwitchingHub(fdb, debug=args.debug)434 tap = TapHandler(switch, args.device, debug=args.debug)435 439 app = tornado.web.Application([ 436 440 (args.path, handler, {'switch': switch, 'debug': args.debug}), 437 441 ]) 438 442 server = tornado.httpserver.HTTPServer(app, ssl_options=ssl_options) 439 440 tap.open()441 443 server.listen(args.port, address=args.address) 442 444 443 ioloop = tornado.ioloop.IOLoop.instance() 444 ioloop.add_handler(tap.fileno(), tap, ioloop.READ) 445 for tap in taps: 446 tap.open() 447 ioloop.add_handler(tap.fileno(), tap, ioloop.READ) 445 448 446 449 if not args.foreground: … … 464 467 args.passwd = getpass.getpass() 465 468 466 fdb = FDB(debug=args.debug) 469 if args.ageout <= 0: 470 raise ValueError('invalid ageout: %s' % args.ageout) 471 472 ioloop = tornado.ioloop.IOLoop.instance() 473 fdb = FDB(ageout=args.ageout, debug=args.debug) 467 474 switch = SwitchingHub(fdb, debug=args.debug) 468 tap = TapHandler(switch, args.device, debug=args.debug) 475 taps = [TapHandler(switch, dev, debug=args.debug) for dev in args.device] 476 469 477 client = EtherWebSocketClient(switch, args.uri, 470 478 args.user, args.passwd, args.debug) 471 472 tap.open()473 479 client.open() 474 475 ioloop = tornado.ioloop.IOLoop.instance()476 ioloop.add_handler(tap.fileno(), tap, ioloop.READ)477 480 ioloop.add_handler(client.fileno(), client, ioloop.READ) 481 482 for tap in taps: 483 tap.open() 484 ioloop.add_handler(tap.fileno(), tap, ioloop.READ) 478 485 479 486 if not args.foreground: … … 485 492 def main(): 486 493 parser = argparse.ArgumentParser() 487 parser.add_argument('--device', action='store', default='ethws%d') 494 parser.add_argument('--device', action='append', default=[]) 495 parser.add_argument('--ageout', action='store', type=int, default=300) 488 496 parser.add_argument('--foreground', action='store_true', default=False) 489 497 parser.add_argument('--debug', action='store_true', default=False)
Note: See TracChangeset
for help on using the changeset viewer.