def setUp(self): host = config["controller_host"] self.controllers = [ controller.Controller(host=host,port=6633), controller.Controller(host=host,port=6634) ] self.dataplane = oftest.dataplane_instance self.dataplane.flush()
def setUp(self): logging = get_logger() #This is almost same as setUp in SimpleProtocol except that intial hello is set to false self.controller = controller.Controller( host=config["controller_host"], port=config["controller_port"]) time_out = config["controller_timeout"] # clean_shutdown should be set to False to force quit app self.clean_shutdown = True #set initial hello to False self.controller.initial_hello=False self.controller.start() self.controller.connect(timeout=time_out) # By default, respond to echo requests self.controller.keep_alive = True if not self.controller.active: raise Exception("Controller startup failed") if self.controller.switch_addr is None: raise Exception("Controller startup failed (no switch addr)") logging.info("Connected " + str(self.controller.switch_addr)) logging.info("Sending Hello message with incorrect version..") request = message.hello() logging.info("Change hello message version to 0 and send it to control plane") request.header.version=0 rv = self.controller.message_send(request)
def controllerSetup(self, host, port): self.controller = controller.Controller(host=host, port=port) # clean_shutdown should be set to False to force quit app self.clean_shutdown = True self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=10) self.assertTrue(self.controller.active, "Controller startup failed, not active") self.assertTrue(self.controller.switch_addr is not None, "Controller startup failed, no switch addr") request = message.features_request() reply, pkt = self.controller.transact(request, timeout=20) self.assertTrue(reply is not None, "Did not complete features_request for handshake") serial_failover_logger.info("Connected " + str(self.controller.switch_addr)) # send echo request and wait for reply request = message.echo_request() response, pkt = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ECHO_REPLY, 'response is not echo_reply') self.assertEqual(request.header.xid, response.header.xid, 'response xid != request xid') self.assertEqual(len(response.data), 0, 'response data non-empty')
def setUp(self): BaseTest.setUp(self) self.controller = controller.Controller(switch=config["switch_ip"], host=config["controller_host"], port=config["controller_port"]) self.controller.start() try: #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=20) # By default, respond to echo requests self.controller.keep_alive = True if self.controller.active == False: raise Exception("Controller startup failed") if self.controller.switch_addr is None: raise Exception("Controller startup failed (no switch addr)") logging.info("Connected " + str(self.controller.switch_addr)) request = ofp.message.features_request() reply, pkt = self.controller.transact(request) self.assertTrue(reply is not None, "Did not complete features_request for handshake") if reply.version == 1: self.supported_actions = reply.actions logging.info("Supported actions: " + hex(self.supported_actions)) except: self.controller.kill() del self.controller raise
def setUp(self): oflog.start_logging(self) logging.info("** START TEST CASE " + str(self)) self.controller = controller.Controller(host=config["controller_host"], port=config["controller_port"]) # clean_shutdown should be set to False to force quit app self.clean_shutdown = True self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? time_out = config["controller_timeout"] self.controller.connect(timeout=time_out) # By default, respond to echo requests self.controller.keep_alive = True if not self.controller.active: raise Exception("Controller startup failed") if self.controller.switch_addr is None: self.controller.shutdown() raise Exception("Controller startup failed (no switch addr)") logging.info("Connected " + str(self.controller.switch_addr)) request = message.features_request() reply, pkt = self.controller.transact(request) self.assertTrue(reply is not None, "Did not complete features_request for handshake") self.supported_actions = reply.actions logging.info("Supported actions: " + hex(self.supported_actions))
def setUp(self): base_tests.BaseTest.setUp(self) self.controller = controller.Controller(switch=config["switch_ip"], host=config["controller_host"], port=config["controller_port"]) self.controller.initial_hello = False
def controllerSetup(self, host, port): con = controller.Controller(host=host, port=port) # clean_shutdown should be set to False to force quit app self.clean_shutdown = True # disable initial hello so hello is under control of test con.initial_hello = False con.start() self.controllers.append(con)
def setUp(self): base_tests.BaseTest.setUp(self) self.controller = controller.Controller(switch=config["switch_ip"], host=config["controller_host"], port=config["controller_port"]) self.controller.initial_hello = False #self.controller.start() #self.controller.connect(timeout=120) #self.controller.keep_alive = True """
def controllerSetup(self, host, port): self.controller = controller.Controller(host=host, port=port) # clean_shutdown should be set to False to force quit app self.clean_shutdown = True # disable initial hello so hello is under control of test self.controller.initial_hello = False self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=10) self.assertTrue(self.controller.active, "Controller startup failed, not active") self.assertTrue(self.controller.switch_addr is not None, "Controller startup failed, no switch addr")
class SimpleProtocol(unittest.TestCase): """ Root class for setting up the controller """ def sig_handler(self, v1, v2): basic_logger.critical("Received interrupt signal; exiting") print "Received interrupt signal; exiting" self.clean_shutdown = False self.tearDown() raise KeyboardInterrupt def setUp(self): self.logger = basic_logger self.config = basic_config #@todo Test cases shouldn't monkey with signals; move SIGINT handler # to top-level oft try: signal.signal(signal.SIGINT, self.sig_handler) except ValueError, e: basic_logger.info("Could not set SIGINT handler: %s" % e) basic_logger.info("** START TEST CASE " + str(self)) self.controller = controller.Controller( host=basic_config["controller_host"], port=basic_config["controller_port"]) # clean_shutdown should be set to False to force quit app self.clean_shutdown = True self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=20) # By default, respond to echo requests self.controller.keep_alive = True if not self.controller.active: raise Exception("Controller startup failed") if self.controller.switch_addr is None: raise Exception("Controller startup failed (no switch addr)") basic_logger.info("Connected " + str(self.controller.switch_addr)) request = message.features_request() reply, pkt = self.controller.transact(request, timeout=10) self.assertTrue(reply is not None, "Did not complete features_request for handshake") self.supported_actions = reply.actions basic_logger.info("Supported actions: " + hex(self.supported_actions))
def setUp(self): self.logger = basic_logger self.config = basic_config #signal.signal(signal.SIGINT, self.sig_handler) basic_logger.info("** START TEST CASE " + str(self)) self.controller = controller.Controller( host=basic_config["controller_host"], port=basic_config["controller_port"]) # clean_shutdown should be set to False to force quit app self.clean_shutdown = True self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=20) if not self.controller.active: print "Controller startup failed; exiting" sys.exit(1) basic_logger.info("Connected " + str(self.controller.switch_addr))
def setUp(self): # This is almost same as setUp in SimpleProtocol except that intial hello is set to false start_logging(self) self.controller = controller.Controller(host=config["controller_host"], port=config["controller_port"]) time_out = config["controller_timeout"] # clean_shutdown should be set to False to force quit app self.clean_shutdown = True #set initial hello to False self.controller.initial_hello = False self.controller.start() self.controller.connect(timeout=time_out) # By default, respond to echo requests self.controller.keep_alive = True if not self.controller.active: raise Exception("Controller startup failed") if self.controller.switch_addr is None: raise Exception("Controller startup failed (no switch addr)") logging.info("Connected " + str(self.controller.switch_addr))
def setUp(self): BaseTest.setUp(self) if config["keyfile"] is None: raise Exception("TLS keyfile path was not specified.") elif not os.path.isfile(config["keyfile"]): raise Exception("TLS keyfile path does not exist.") if config["certfile"] is None: raise Exception("TLS certfile path was not specified.") elif not os.path.isfile(config["certfile"]): raise Exception("TLS certfile path does not exist.") self.controller = controller.Controller(switch=config["switch_ip"], host=config["controller_host"], port=config["controller_port"], keyfile=config["keyfile"], certfile=config["certfile"]) self.controller.start() try: self.controller.connect(timeout=20) self.controller.keep_alive = True if not self.controller.active: raise Exception("Controller startup failed") if self.controller.switch_addr is None: raise Exception("Controller startup failed (no switch addr)") logging.info("Connected " + str(self.controller.switch_addr)) request = ofp.message.features_request() reply, pkt = self.controller.transact(request) self.assertTrue(reply is not None, "Did not complete features_request for handshake") if reply.version == 1: self.supported_actions = reply.actions logging.info("Supported actions: " + hex(self.supported_actions)) except: self.controller.kill() del self.controller raise
def setUp(self): # This is almost same as setUp in SimpleProtcocol except that Echo response is set to false start_logging(self) self.controller = controller.Controller(host=config["controller_host"], port=config["controller_port"]) time_out = config["controller_timeout"] # clean_shutdown should be set to False to force quit app self.clean_shutdown = False self.controller.initial_hello = True self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=time_out) # Here, Echo response is set to False, this would trigger connection to drop and hence switch will # start sending Hello messages to start a new connection self.controller.keep_alive = False if not self.controller.active: raise Exception("Controller startup failed") if self.controller.switch_addr is None: raise Exception("Controller startup failed (no switch addr)") logging.info("Connected " + str(self.controller.switch_addr))
def setUp(self): #This is almost same as setUp in SimpleProtcocol except that intial hello is set to false self.controller = controller.Controller( host=config["controller_host"], # clean_shutdown should be set to False to force quit app port=config["controller_port"]) time_out = config["controller_timeout"] self.clean_shutdown = True #set initial hello to False self.controller.initial_hello = False self.controller.start() #@todo Add an option to wait for a pkt transaction to ensure version # compatibilty? self.controller.connect(timeout=time_out) # By default, respond to echo requests self.controller.keep_alive = True if not self.controller.active: raise Exception("Controller startup failed") if self.controller.switch_addr is None: raise Exception("Controller startup failed (no switch addr)")
def setUp(self): host = config["controller_host"] self.controllers = [ controller.Controller(host=host,port=6653), controller.Controller(host=host,port=6753) ]