Ejemplo n.º 1
0
def launch ():
  from pox.log.level import launch
  launch(DEBUG=True)

  from pox.py import launch
  launch()
 
  from pox.openflow.of_01 import launch
  launch(6666)
 
  from pox.forwarding.l2_learning import launch
  launch(isMaster=-1)
Ejemplo n.º 2
0
def setup_logging(test_mode=False, log_file=None, log_folder=None, **kwargs):
    """
  Launch and set parameters for logging.

  :param test_mode: use test mode logging (default: False)
  :type test_mode: bool
  :param log_file: log file path
  :type log_file: str
  :return: None
  """
    global LOG_FOLDER
    if log_folder is not None:
        LOG_FOLDER = log_folder
    if not os.path.exists(LOG_FOLDER):
        os.makedirs(LOG_FOLDER)
    if log_file is None:
        log_file = os.path.join(LOG_FOLDER, "escape.log")
    # Enable logging in specific logging level
    level.launch(**kwargs)
    # Launch colorful logging
    color.launch()
    if test_mode:
        # Define logger for test mode
        pox.log.launch(format=TEST_LOGGER_FORMAT)
        log.debug("Setup Logger - formatter: %s, level: %s" %
                  (pox.log.launch.__module__,
                   logging.getLevelName(log.getEffectiveLevel())))
        # Set default log_file to log in file in test mode
    else:
        # Define default logger
        pox.log.launch(format=DEFAULT_LOGGER_FORMAT)
        log.debug("Setup logger - formatter: %s, level: %s" %
                  (setup_logging.__module__,
                   logging.getLevelName(log.getEffectiveLevel())))
    if log_file:
        # Define additional logger for logging to file
        pox.log.launch(format=FILE_LOGGER_FORMAT, file=log_file + ',w')
        log.debug("Setup Logger - formatter: %s, level: %s, file: %s" %
                  (pox.log.launch.__module__,
                   logging.getLevelName(log.getEffectiveLevel()), log_file))
Ejemplo n.º 3
0
def launch():
    def server_launch():
        webbrowser.open('http://localhost:%s/%s' % (PORT, FILE))
        server = SimpleHttpServer('127.0.0.1', int(PORT))
        print 'HTTP Server Running...........'
        server.start()
        server.waitForThread()

    thread.start_new(server_launch, ())
    from pox.log.level import launch
    launch(CRITICAL=True)
    from openflow.discovery import launch
    launch()
    from openflow.spanning_tree import launch
    launch('--no-flood --hold-down')
    core.registerNew(panorama)
    core.openflow.addListenerByName('ConnectionUp', _handle_ConnectionUp)
    core.openflow.addListenerByName('ConnectionDown', _handle_ConnectionDown)
    core.openflow.addListenerByName('PortStatsReceived',
                                    _handle_portstats_received)
    core.openflow.addListenerByName('AggregateFlowStatsReceived',
                                    _handle_aggregate_flowstats_received)
    core.openflow.addListenerByName('FlowStatsReceived',
                                    _handle_flowstats_received)
    core.openflow.addListenerByName('SwitchDescReceived',
                                    _handle_switchdesc_received)
    Timer(1, _timer_func, recurring=True)
Ejemplo n.º 4
0
def setup_logging(test_mode=False, log_file=None, **kw):
    """
  Launch and set parameters for logging.

  :param test_mode: use test mode logging (default: False)
  :type test_mode: bool
  :param log_file: log file path
  :type log_file: str
  :param kw: additional parameters for POX's logger
  :type kw: dict
  :return: None
  """
    # Enable logging in specific logging level
    level.launch(**kw)
    # Launch colorful logging
    color.launch()
    if test_mode:
        # Define logger for test mode
        pox.log.launch(format=TEST_LOGGER_FORMAT)
        log.info("Setup Logger - formatter: %s, level: %s" %
                 (pox.log.launch.__module__,
                  logging.getLevelName(log.getEffectiveLevel())))
        # Set default log_file to log in file in test mode
    else:
        # Define default logger
        pox.log.launch(format=DEFAULT_LOGGER_FORMAT)
        log.info("Setup logger - formatter: %s, level: %s" %
                 (setup_logging.__module__,
                  logging.getLevelName(log.getEffectiveLevel())))
    log_file = log_file if log_file is not None else LOG_FILE
    if log_file:
        # Define additional logger for logging to file
        pox.log.launch(format=FILE_LOGGER_FORMAT, file=log_file + ',w')
        log.info("Setup Logger - formatter: %s, level: %s, file: %s" %
                 (pox.log.launch.__module__,
                  logging.getLevelName(log.getEffectiveLevel()), log_file))
Ejemplo n.º 5
0
def launch (transparent=False, hold_down=_flood_delay):
  """
  Starts an L2 learning switch.
  """

  # Import and launch log, discovery and host_tracker
  from pox.log.level import launch
  launch(DEBUG=True)

  from openflow.discovery import launch
  launch()

  from pox.host_tracker import launch
  launch()
  
  from pox.lib.recoco import Timer

  core.openflow.addListenerByName("FlowStatsReceived", _handle_FlowStatsReceived)
  core.openflow.addListenerByName("PortStatsReceived", _handle_PortStatsReceived)
  
  try:
   global _flood_delay
   _flood_delay = int(str(hold_down), 10)
   assert _flood_delay >= 0
  except:
   raise RuntimeError("Expected hold-down to be a number")

  core.registerNew(l2_learning, str_to_bool(transparent))
  
  Timer(2, flowUpdate, recurring=True)


  ################################################################################
  #SAMS VOLATILE CODE BEYOND THIS POINT - No merge conflicts pls
  ################################################################################

  # Start up the web socket
  port = 9999
  # Get ip from eth0 interface
  ip = get_ip_address('eth0')
  log.debug("Starting websockets on port:" + str(port)+ ", ip:" + str(ip))

  global visual
  visual = VisualThread(ip, port)
  visual.daemon=True
  visual.start()
Ejemplo n.º 6
0
def launch (transparent=False, hold_down=_flood_delay):
  """
  Starts an L2 learning switch.
  """

  # Import and launch log, discovery and host_tracker
  from pox.log.level import launch
  launch(DEBUG=True)

  from openflow.discovery import launch
  launch()

  from pox.host_tracker import launch
  launch()
  
  from pox.lib.recoco import Timer

  core.openflow.addListenerByName("FlowStatsReceived", _handle_FlowStatsReceived)
  core.openflow.addListenerByName("PortStatsReceived", _handle_PortStatsReceived)
  
  try:
   global _flood_delay
   _flood_delay = int(str(hold_down), 10)
   assert _flood_delay >= 0
  except:
   raise RuntimeError("Expected hold-down to be a number")

  core.registerNew(l2_learning, str_to_bool(transparent))
  
  Timer(5, flowUpdate, recurring=True)
  ################################################################################
  #SAMS VOLATILE CODE BEYOND THIS POINT - No merge conflicts pls
  ################################################################################

  # Start up the web socket
  port = 9999
  log.debug("Starting websockets on port " + str(port))
  
  global visual
  visual = VisualThread("192.168.0.10", port)
  # TODO: NEED TO UN-HARDCODE THIS - DIFF USERS HAVE DIFF ADDR'S
  visual.daemon=True
  visual.start()
Ejemplo n.º 7
0
def launch ():
  """
  Starts an L2 learning switch.
  """

  # Import and launch dependencies
  from pox.log.level import launch
  launch(INFO=True)

  from openflow.discovery import launch
  launch(link_timeout=5)

  from pox.host_tracker import launch
  launch()
  
  from pox.lib.recoco import Timer

  # Add flow and port stat listeners - don't work if not by name?
  core.openflow.addListenerByName("FlowStatsReceived", _handle_FlowStatsReceived)
  core.openflow.addListenerByName("PortStatsReceived", _handle_PortStatsReceived)
  
  # Register new l2_multi switch with core
  core.registerNew(l2_multi)

  # Timers for l2_multi path expiry and stats packets
  timeout = min(max(PATH_SETUP_TIME, 5) * 2, 15) * 2
  Timer(timeout, WaitingPath.expire_waiting_paths, recurring=True)
  Timer(2, flowUpdate, recurring=True)
  
  # Start up the web socket
  port = 9999
  # Get ip from eth0 interface
  ip = get_ip_address('eth0')
  log.debug("Starting websockets on port:" + str(port)+ ", ip:" + str(ip))

  global visual
  visual = VisualThread(ip, port)
  visual.daemon=True
  visual.start()
Ejemplo n.º 8
0
def launch ():
  """
  Starts an L2 learning switch.
  """

  # Import and launch log, discovery and host_tracker
  from pox.log.level import launch
  launch(INFO=True)

  from openflow.discovery import launch
  launch(link_timeout=5)

  from pox.host_tracker import launch
  launch()
  
  from pox.lib.recoco import Timer

  core.openflow.addListenerByName("FlowStatsReceived", _handle_FlowStatsReceived)
  core.openflow.addListenerByName("PortStatsReceived", _handle_PortStatsReceived)

  core.registerNew(l2_multi)

  timeout = min(max(PATH_SETUP_TIME, 5) * 2, 15) * 2
  Timer(timeout, WaitingPath.expire_waiting_paths, recurring=True)
  Timer(2, flowUpdate, recurring=True)
  ################################################################################
  #SAMS VOLATILE CODE BEYOND THIS POINT - No merge conflicts pls
  ################################################################################

  # Start up the web socket
  port = 9999
  # Get ip from eth0 interface
  ip = get_ip_address('eth0')
  log.debug("Starting websockets on port:" + str(port)+ ", ip:" + str(ip))

  global visual
  visual = VisualThread(ip, port)
  visual.daemon=True
  visual.start()
Ejemplo n.º 9
0
def launch ():
  def server_launch():
    webbrowser.open('http://localhost:%s/%s' % (PORT, FILE))
    server = SimpleHttpServer('127.0.0.1', int(PORT))
    print 'HTTP Server Running...........'
    server.start()
    server.waitForThread()
  
  thread.start_new(server_launch, ())
  from pox.log.level import launch
  launch(CRITICAL=True)
  from openflow.discovery import launch
  launch()
  from openflow.spanning_tree import launch
  launch('--no-flood --hold-down')
  core.registerNew(panorama)
  core.openflow.addListenerByName('ConnectionUp', _handle_ConnectionUp)
  core.openflow.addListenerByName('ConnectionDown', _handle_ConnectionDown)
  core.openflow.addListenerByName('PortStatsReceived', _handle_portstats_received)
  core.openflow.addListenerByName('AggregateFlowStatsReceived', _handle_aggregate_flowstats_received)
  core.openflow.addListenerByName('FlowStatsReceived', _handle_flowstats_received)
  core.openflow.addListenerByName('SwitchDescReceived', _handle_switchdesc_received)
  Timer(1, _timer_func, recurring=True)
Ejemplo n.º 10
0
    def launch():
        from pox.log.level import launch
        launch(DEBUG=True)

        from pox.misc.firewall import launch
        launch()

        from pox.openflow.keepalive import launch
        launch(interval=300)

        from pox.forwarding.l3_learning import launch
        launch()

        from pox.proto.dhcpd import launch
        launch()

        from pox.proto.dns_spy import launch
        launch()

        from pox.host_tracker.host_tracker import launch
        launch()

        from pox.openflow.discovery import launch
        launch()  # 15 seconds

        from pox.forwarding.l2_pairs import launch
        launch()