@Override public void init(FloodlightModuleContext context) throws FloodlightModuleException { // This has to be done here since we don't know what order the // startUp methods will be called this.restlets = new ArrayList<RestletRoutable>(); this.fmlContext = context; // read our config options Map<String, String> configOptions = context.getConfigParams(this); restHost = configOptions.get("host"); if (restHost == null) { Map<String, String> providerConfigOptions = context.getConfigParams( FloodlightProvider.class); restHost = providerConfigOptions.get("openflowhost"); } if (restHost != null) { logger.debug("REST host set to {}", restHost); } String port = configOptions.get("port"); if (port != null) { restPort = Integer.parseInt(port); } logger.debug("REST port set to {}", restPort); }
@Override public void setUp() throws Exception { super.setUp(); FloodlightModuleContext fmc = new FloodlightModuleContext(); FloodlightProvider cm = new FloodlightProvider(); controller = (Controller)cm.getServiceImpls().get(IFloodlightProviderService.class); fmc.addService(IFloodlightProviderService.class, controller); MemoryStorageSource memstorage = new MemoryStorageSource(); fmc.addService(IStorageSourceService.class, memstorage); RestApiServer restApi = new RestApiServer(); fmc.addService(IRestApiService.class, restApi); CounterStore cs = new CounterStore(); fmc.addService(ICounterStoreService.class, cs); PktInProcessingTime ppt = new PktInProcessingTime(); fmc.addService(IPktInProcessingTimeService.class, ppt); tp = new MockThreadPoolService(); fmc.addService(IThreadPoolService.class, tp); ppt.init(fmc); restApi.init(fmc); memstorage.init(fmc); cm.init(fmc); tp.init(fmc); ppt.startUp(fmc); restApi.startUp(fmc); memstorage.startUp(fmc); cm.startUp(fmc); tp.startUp(fmc); }
@Override @Before public void setUp() throws Exception { super.setUp(); FloodlightModuleContext fmc = new FloodlightModuleContext(); FloodlightProvider floodlightProvider = new FloodlightProvider(); controller = (Controller) floodlightProvider.getServiceImpls().get( IFloodlightProviderService.class); fmc.addService(IFloodlightProviderService.class, controller); RestApiServer restApi = new RestApiServer(); fmc.addService(IRestApiService.class, restApi); DebugCounter counterService = new DebugCounter(); fmc.addService(IDebugCounterService.class, counterService); threadPool = new MockThreadPoolService(); fmc.addService(IThreadPoolService.class, threadPool); IControllerRegistryService registry = createMock(IControllerRegistryService.class); fmc.addService(IControllerRegistryService.class, registry); LinkDiscoveryManager linkDiscovery = new LinkDiscoveryManager(); fmc.addService(ILinkDiscoveryService.class, linkDiscovery); restApi.init(fmc); floodlightProvider.init(fmc); threadPool.init(fmc); linkDiscovery.init(fmc); restApi.startUp(fmc); floodlightProvider.startUp(fmc); threadPool.startUp(fmc); }
@Override public void startUp(FloodlightModuleContext context) { Map<String, Object> locals = new HashMap<String, Object>(); // add all existing module references to the debug server for (Class<? extends IFloodlightService> s : context.getAllServices()) { // Put only the last part of the name String[] bits = s.getCanonicalName().split("\\."); String name = bits[bits.length-1]; locals.put(name, context.getServiceImpl(s)); } // read our config options Map<String, String> configOptions = context.getConfigParams(this); jythonHost = configOptions.get("host"); if (jythonHost == null) { Map<String, String> providerConfigOptions = context.getConfigParams( FloodlightProvider.class); jythonHost = providerConfigOptions.get("openflowhost"); } if (jythonHost != null) { log.debug("Jython host set to {}", jythonHost); } String port = configOptions.get("port"); if (port != null) { jythonPort = Integer.parseInt(port); } log.debug("Jython port set to {}", jythonPort); JythonServer debug_server = new JythonServer(jythonHost, jythonPort, locals); debug_server.start(); }