def __init__(self, *args, **kwargs): super(RefMon, self).__init__(*args, **kwargs) # Used for REST API #wsgi = kwargs['wsgi'] #wsgi.register(FlowModReceiver, self) self.logger = util.log.getLogger('ReferenceMonitor') self.logger.info('refmon: start') # retrieve command line arguments CONF = cfg.CONF log_file_path = CONF['refmon']['log'] if log_file_path is not None: log_file = os.path.abspath(log_file_path) self.log = open(log_file, "w") else: self.log = None # configure flow mod logging log_file_path = CONF['refmon']['flowmodlog'] if log_file_path is not None: log_file = os.path.abspath(log_file_path) self.flow_mod_log = open(log_file, "w") else: self.flow_mod_log = None # load config from file self.logger.info('refmon: load config') try: config_file_path = CONF['refmon']['config'] config_file = os.path.abspath(config_file_path) self.config = Config(config_file) except InvalidConfigError as e: self.logger.info('refmon: invalid config ' + str(e)) self.config.always_ready = CONF['refmon']['always_ready'] # start controller if self.config.isMultiSwitchMode(): self.controller = MultiSwitchController(self.config) elif self.config.isMultiTableMode(): self.controller = MultiTableController(self.config) elif self.config.isOneSwitchMode(): self.controller = OneSwitchController(self.config) # this must be set before Server, which uses it. self.flow_mod_times = Queue() # start server receiving flowmod requests self.server = Server(self, self.config.server["IP"], self.config.server["Port"], self.config.server["key"]) self.server.start()