org.onosproject.cfg.ComponentConfigService Java Examples
The following examples show how to use
org.onosproject.cfg.ComponentConfigService.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InOrderFlowObjectiveManagerTest.java From onos with Apache License 2.0 | 6 votes |
private void internalSetup(int objTimeoutMs) { mgr = new InOrderFlowObjectiveManager(); mgr.objTimeoutMs = objTimeoutMs; mgr.pipeliners.put(DEV1, pipeliner); mgr.installerExecutor = newFixedThreadPool(4, groupedThreads("foo", "bar")); mgr.cfgService = createMock(ComponentConfigService.class); mgr.deviceService = createMock(DeviceService.class); mgr.driverService = createMock(DriverService.class); mgr.flowObjectiveStore = createMock(FlowObjectiveStore.class); mgr.activate(null); reset(mgr.flowObjectiveStore); offset = DEFAULT_OFFSET; bound = DEFAULT_BOUND; actualObjs.clear(); }
Example #2
Source File: LinksWebResource.java From onos with Apache License 2.0 | 6 votes |
/** * Get useStaleLinkAge active status. * Returns current status of the VanishedStaleLink. * * @onos.rsModel VanishedLink * @return 200 ok with the VanishedStaleLink status. */ @GET @Path("{usestalelinkage}") @Produces(MediaType.APPLICATION_JSON) public Response getVanishStaleLink() { ObjectNode root = mapper().createObjectNode(); ComponentConfigService useStaleLink = get(ComponentConfigService.class); for (ConfigProperty prop : useStaleLink.getProperties("org.onosproject.provider.lldp.impl.LldpLinkProvider")) { if (prop.name().equals("useStaleLinkAge")) { root.put("active", Boolean.valueOf(prop.value())); break; } } return ok(root).build(); }
Example #3
Source File: LinksWebResource.java From onos with Apache License 2.0 | 6 votes |
/** * Set useStaleLinkAge status. * * @onos.rsModel VanishedLink * @param stream input JSON * @return 200 ok. * BAD_REQUEST if the JSON is invalid */ @POST @Path("{usestalelinkage}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response setVanishStaleLink(InputStream stream) { try { // Parse the input stream ObjectNode root = (ObjectNode) mapper().readTree(stream); if (root.has("active")) { ComponentConfigService useStaleLink = get(ComponentConfigService.class); useStaleLink.setProperty("org.onosproject.provider.lldp.impl.LldpLinkProvider", "useStaleLinkAge", String.valueOf(root.get("active"))); } } catch (IOException ex) { throw new IllegalArgumentException(ex); } return Response .ok() .build(); }
Example #4
Source File: OpenstackManagementWebResource.java From onos with Apache License 2.0 | 6 votes |
/** * Configures the security group (enable | disable). * * @param securityGroup security group activation flag * @return 200 OK with config result, 404 not found */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("config/securityGroup/{securityGroup}") public Response configSecurityGroup(@PathParam("securityGroup") String securityGroup) { String securityGroupStr = nullIsIllegal(securityGroup, SECURITY_GROUP_FLAG_REQUIRED); boolean flag = checkActivationFlag(securityGroupStr); ComponentConfigService service = get(ComponentConfigService.class); String securityGroupComponent = OpenstackSecurityGroupHandler.class.getName(); service.setProperty(securityGroupComponent, USE_SECURITY_GROUP_NAME, String.valueOf(flag)); return ok(mapper().createObjectNode()).build(); }
Example #5
Source File: ComponentConfigCommand.java From onos with Apache License 2.0 | 6 votes |
@Override protected void doExecute() { service = get(ComponentConfigService.class); try { if (isNullOrEmpty(command)) { listComponents(); } else if (command.equals(GET) && isNullOrEmpty(component)) { listAllComponentsProperties(); } else if (command.equals(GET) && isNullOrEmpty(name)) { listComponentProperties(component); } else if (command.equals(GET)) { listComponentProperty(component, name); } else if (command.equals(SET) && isNullOrEmpty(value)) { service.unsetProperty(component, name); } else if (command.equals(SET)) { service.setProperty(component, name, value); } else if (command.equals(PRESET)) { service.preSetProperty(component, name, value); } else { error("Illegal usage"); } } catch (IllegalArgumentException e) { error(e.getMessage()); } }
Example #6
Source File: ComponentPropertyNameCompleter.java From onos with Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { // Delegate string completer StringsCompleter delegate = new StringsCompleter(); // Component name is the previous argument. String componentName = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 1]; ComponentConfigService service = get(ComponentConfigService.class); SortedSet<String> strings = delegate.getStrings(); Set<ConfigProperty> properties = service.getProperties(componentName); if (properties != null) { properties.forEach(property -> strings.add(property.name())); } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example #7
Source File: OpenstackConfigStatefulSnatCommand.java From onos with Apache License 2.0 | 6 votes |
@Override protected void doExecute() { configSnatMode(statefulSnat); ComponentConfigService service = get(ComponentConfigService.class); String snatComponent = OpenstackRoutingSnatHandler.class.getName(); while (true) { boolean snatValue = getPropertyValueAsBoolean( service.getProperties(snatComponent), USE_STATEFUL_SNAT); if (statefulSnat == snatValue) { break; } } purgeRules(); syncRules(); }
Example #8
Source File: NullControlCommand.java From onos with Apache License 2.0 | 6 votes |
@Override protected void doExecute() { ComponentConfigService service = get(ComponentConfigService.class); // If there is an existing topology; make sure it's stopped before restarting if (cmd.equals(START)) { NullProviders npService = get(NullProviders.class); TopologySimulator simulator = npService.currentSimulator(); if (simulator != null) { simulator.tearDownTopology(); } } if (topoShape != null) { service.setProperty(NullProviders.class.getName(), "topoShape", topoShape); } service.setProperty(NullProviders.class.getName(), "enabled", cmd.equals(START) ? "true" : "false"); }
Example #9
Source File: OpenstackConfigArpModeCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { if (checkArpMode(arpMode)) { configArpMode(arpMode); ComponentConfigService service = get(ComponentConfigService.class); String switchingComponent = OpenstackSwitchingArpHandler.class.getName(); String routingComponent = OpenstackRoutingArpHandler.class.getName(); // we check the arpMode configured in each component, and purge and // reinstall all rules only if the arpMode is changed to the configured one while (true) { String switchingValue = getPropertyValue( service.getProperties(switchingComponent), ARP_MODE_NAME); String routingValue = getPropertyValue( service.getProperties(routingComponent), ARP_MODE_NAME); if (arpMode.equals(switchingValue) && arpMode.equals(routingValue)) { break; } } purgeRules(); syncRules(); } }
Example #10
Source File: OpenstackManagementWebResource.java From onos with Apache License 2.0 | 5 votes |
/** * Configures the ARP mode (proxy | broadcast). * * @param arpmode ARP mode * @return 200 OK with config result, 404 not found */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("config/arpmode/{arpmode}") public Response configArpMode(@PathParam("arpmode") String arpmode) { String arpModeStr = nullIsIllegal(arpmode, ARP_MODE_REQUIRED); if (checkArpMode(arpModeStr)) { configArpModeBase(arpModeStr); ComponentConfigService service = get(ComponentConfigService.class); String switchingComponent = OpenstackSwitchingArpHandler.class.getName(); String routingComponent = OpenstackRoutingArpHandler.class.getName(); // we check the arpMode configured in each component, and purge and // reinstall all rules only if the arpMode is changed to the configured one while (true) { String switchingValue = getPropertyValue(service.getProperties(switchingComponent), ARP_MODE_NAME); String routingValue = getPropertyValue(service.getProperties(routingComponent), ARP_MODE_NAME); if (arpModeStr.equals(switchingValue) && arpModeStr.equals(routingValue)) { break; } } purgeRulesBase(); syncRulesBase(); } else { throw new IllegalArgumentException("The ARP mode is not valid"); } return ok(mapper().createObjectNode()).build(); }
Example #11
Source File: OpenstackManagementWebResource.java From onos with Apache License 2.0 | 5 votes |
/** * Configures the stateful SNAT flag (enable | disable). * * @param statefulSnat stateful SNAT flag * @return 200 OK with config result, 404 not found */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("config/statefulSnat/{statefulSnat}") public Response configStatefulSnat(@PathParam("statefulSnat") String statefulSnat) { String statefulSnatStr = nullIsIllegal(statefulSnat, STATEFUL_SNAT_REQUIRED); boolean flag = checkActivationFlag(statefulSnatStr); configStatefulSnatBase(flag); ComponentConfigService service = get(ComponentConfigService.class); String snatComponent = OpenstackRoutingSnatHandler.class.getName(); while (true) { boolean snatValue = getPropertyValueAsBoolean( service.getProperties(snatComponent), USE_STATEFUL_SNAT_NAME); if (flag == snatValue) { break; } } purgeRulesBase(); syncRulesBase(); return ok(mapper().createObjectNode()).build(); }
Example #12
Source File: OpenstackManagementWebResource.java From onos with Apache License 2.0 | 5 votes |
private void configArpModeBase(String arpMode) { ComponentConfigService service = get(ComponentConfigService.class); String switchingComponent = OpenstackSwitchingArpHandler.class.getName(); String routingComponent = OpenstackRoutingArpHandler.class.getName(); service.setProperty(switchingComponent, ARP_MODE_NAME, arpMode); service.setProperty(routingComponent, ARP_MODE_NAME, arpMode); }
Example #13
Source File: ComponentConfigWebResource.java From onos with Apache License 2.0 | 5 votes |
/** * Gets configuration of the specified component. * * @param component component name * @return 200 OK with a collection of component configurations */ @GET @Path("{component}") @Produces(MediaType.APPLICATION_JSON) public Response getComponentConfigs(@PathParam("component") String component) { ComponentConfigService service = get(ComponentConfigService.class); ObjectNode root = mapper().createObjectNode(); encodeConfigs(component, nullIsNotFound(service.getProperties(component), "No such component"), root); return ok(root).build(); }
Example #14
Source File: OpenstackConfigArpModeCommand.java From onos with Apache License 2.0 | 5 votes |
private void configArpMode(String arpMode) { ComponentConfigService service = get(ComponentConfigService.class); String switchingComponent = OpenstackSwitchingArpHandler.class.getName(); String routingComponent = OpenstackRoutingArpHandler.class.getName(); if (!isNullOrEmpty(arpMode)) { service.setProperty(switchingComponent, ARP_MODE_NAME, arpMode); service.setProperty(routingComponent, ARP_MODE_NAME, arpMode); } }
Example #15
Source File: CreateRoutes.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { ComponentConfigService service = get(ComponentConfigService.class); service.setProperty("org.onosproject.routescale.ScaleTestManager", "routeCount", String.valueOf(routeCount)); }
Example #16
Source File: MastershipManagerTest.java From onos with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { mgr = new MastershipManager(); service = mgr; injectEventDispatcher(mgr, new TestEventDispatcher()); testClusterService = new TestClusterService(); mgr.clusterService = testClusterService; mgr.upgradeService = new UpgradeServiceAdapter(); mgr.store = new TestSimpleMastershipStore(mgr.clusterService); regionStore = new DistributedRegionStore(); TestUtils.setField(regionStore, "storageService", new TestStorageService()); TestUtils.callMethod(regionStore, "activate", new Class<?>[] {}); regionManager = new TestRegionManager(); TestUtils.setField(regionManager, "store", regionStore); regionManager.activate(); mgr.regionService = regionManager; ComponentConfigService mockConfigService = EasyMock.createMock(ComponentConfigService.class); expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of()); mockConfigService.registerProperties(mgr.getClass()); expectLastCall(); mockConfigService.unregisterProperties(mgr.getClass(), false); expectLastCall(); expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of()); mgr.cfgService = mockConfigService; replay(mockConfigService); mgr.activate(); }
Example #17
Source File: FlowRuleIntentInstallerTest.java From onos with Apache License 2.0 | 5 votes |
@Before public void setup() { super.setup(); flowRuleService = new TestFlowRuleService(); installer = new FlowRuleIntentInstaller(); installer.flowRuleService = flowRuleService; installer.store = new SimpleIntentStore(); installer.intentExtensionService = intentExtensionService; installer.intentInstallCoordinator = intentInstallCoordinator; installer.trackerService = trackerService; installer.configService = mock(ComponentConfigService.class); installer.activate(); }
Example #18
Source File: IntentManagerTest.java From onos with Apache License 2.0 | 5 votes |
@Before public void setUp() { manager = new IntentManager(); flowRuleService = new MockFlowRuleService(); manager.store = new SimpleIntentStore(); injectEventDispatcher(manager, new TestEventDispatcher()); manager.trackerService = trackerService; manager.flowRuleService = flowRuleService; manager.coreService = new TestCoreManager(); manager.configService = mock(ComponentConfigService.class); service = manager; extensionService = manager; intentInstallCoordinator = manager; manager.activate(); service.addListener(listener); extensionService.registerCompiler(MockIntent.class, compiler); installer = new TestIntentInstaller(extensionService, trackerService, intentInstallCoordinator, flowRuleService); extensionService.registerInstaller(MockInstallableIntent.class, installer); assertTrue("store should be empty", Sets.newHashSet(service.getIntents()).isEmpty()); assertEquals(0L, flowRuleService.getFlowRuleCount()); }
Example #19
Source File: OpticalCircuitIntentCompilerTest.java From onos with Apache License 2.0 | 5 votes |
@Before public void setUp() { sut = new OpticalCircuitIntentCompiler(); coreService = createMock(CoreService.class); expect(coreService.registerApplication("org.onosproject.net.intent")) .andReturn(appId); sut.coreService = coreService; sut.deviceService = new MockDeviceService(); sut.resourceService = new MockResourceService(); sut.intentService = new TestIntentService(); sut.intentSetMultimap = new MockIntentSetMultimap(); super.setUp(); intentExtensionService = createMock(IntentExtensionService.class); intentExtensionService.registerCompiler(OpticalCircuitIntent.class, sut); intentExtensionService.unregisterCompiler(OpticalCircuitIntent.class); sut.intentManager = intentExtensionService; replay(coreService, intentExtensionService); // mocking ComponentConfigService ComponentConfigService mockConfigService = EasyMock.createMock(ComponentConfigService.class); expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of()); mockConfigService.registerProperties(sut.getClass()); expectLastCall(); mockConfigService.unregisterProperties(sut.getClass(), false); expectLastCall(); expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of()); sut.cfgService = mockConfigService; replay(mockConfigService); }
Example #20
Source File: FibInstallerTest.java From onos with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { sSfibInstaller = new FibInstaller(); sSfibInstaller.componentConfigService = createNiceMock(ComponentConfigService.class); ComponentContext mockContext = createNiceMock(ComponentContext.class); routerConfig = new TestRouterConfig(); interfaceService = createMock(InterfaceService.class); networkConfigService = createMock(NetworkConfigService.class); networkConfigService.addListener(anyObject(NetworkConfigListener.class)); expectLastCall().anyTimes(); networkConfigRegistry = createMock(NetworkConfigRegistry.class); flowObjectiveService = createMock(FlowObjectiveService.class); applicationService = createNiceMock(ApplicationService.class); replay(applicationService); deviceService = new TestDeviceService(); CoreService coreService = createNiceMock(CoreService.class); expect(coreService.registerApplication(anyString())).andReturn(APPID).anyTimes(); replay(coreService); sSfibInstaller.networkConfigService = networkConfigService; sSfibInstaller.networkConfigRegistry = networkConfigRegistry; sSfibInstaller.interfaceService = interfaceService; sSfibInstaller.flowObjectiveService = flowObjectiveService; sSfibInstaller.applicationService = applicationService; sSfibInstaller.coreService = coreService; sSfibInstaller.routeService = new TestRouteService(); sSfibInstaller.deviceService = deviceService; setUpNetworkConfigService(); setUpInterfaceService(); sSfibInstaller.activate(mockContext); }
Example #21
Source File: ComponentNameCompleter.java From onos with Apache License 2.0 | 5 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { // Delegate string completer StringsCompleter delegate = new StringsCompleter(); // Fetch our service and feed it's offerings to the string completer ComponentConfigService service = AbstractShellCommand.get(ComponentConfigService.class); SortedSet<String> strings = delegate.getStrings(); service.getComponentNames().forEach(strings::add); // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Example #22
Source File: SettingsViewMessageHandler.java From onos with Apache License 2.0 | 5 votes |
@Override protected void populateTable(TableModel tm, ObjectNode payload) { ComponentConfigService ccs = get(ComponentConfigService.class); for (String component : ccs.getComponentNames()) { for (ConfigProperty prop : ccs.getProperties(component)) { populateRow(tm.addRow(), component, prop); } } }
Example #23
Source File: ComponentConfigWebResourceTest.java From onos with Apache License 2.0 | 5 votes |
@Before public void setUpMock() { service = new TestConfigManager(); ServiceDirectory testDirectory = new TestServiceDirectory() .add(ComponentConfigService.class, service); setServiceDirectory(testDirectory); }
Example #24
Source File: ComponentConfigWebResource.java From onos with Apache License 2.0 | 5 votes |
/** * Gets specified value of a specified component and variable. * * @param component component name * @param attribute attribute name * @return 200 OK with a collection of component configurations */ @GET @Path("{component}/{attribute}") @Produces(MediaType.APPLICATION_JSON) public Response getComponentConfig(@PathParam("component") String component, @PathParam("attribute") String attribute) { ComponentConfigService service = get(ComponentConfigService.class); ObjectNode root = mapper().createObjectNode(); encodeConfigs(component, attribute, nullIsNotFound(service.getProperty(component, attribute), (service.getProperties(component) == null) ? "No such component" : (service.getProperty(component, attribute) == null) ? ("No such attribute in " + component) : "No such attribute and component"), root); return ok(root).build(); }
Example #25
Source File: ComponentConfigWebResource.java From onos with Apache License 2.0 | 5 votes |
/** * Selectively clears configuration properties. * Clears only the properties present in the JSON request. * * @param component component name * @param request JSON configuration * @return 204 NO CONTENT * @throws IOException to signify bad request */ @DELETE @Consumes(MediaType.APPLICATION_JSON) @Path("{component}") public Response unsetConfigs(@PathParam("component") String component, InputStream request) throws IOException { ComponentConfigService service = get(ComponentConfigService.class); ObjectNode props = readTreeFromStream(mapper(), request); props.fieldNames().forEachRemaining(k -> service.unsetProperty(component, k)); return Response.noContent().build(); }
Example #26
Source File: ComponentConfigWebResource.java From onos with Apache License 2.0 | 5 votes |
/** * Gets all component configurations. * Returns collection of all registered component configurations. * * @return 200 OK with a collection of component configurations */ @GET @Produces(MediaType.APPLICATION_JSON) public Response getComponentConfigs() { ComponentConfigService service = get(ComponentConfigService.class); Set<String> components = service.getComponentNames(); ObjectNode root = mapper().createObjectNode(); components.forEach(c -> encodeConfigs(c, service.getProperties(c), root)); return ok(root).build(); }
Example #27
Source File: DhcpRelayManagerTest.java From onos with Apache License 2.0 | 4 votes |
@Before public void setup() { manager = new DhcpRelayManager(); manager.cfgService = createNiceMock(NetworkConfigRegistry.class); expect(manager.cfgService.getConfig(APP_ID, DefaultDhcpRelayConfig.class)) .andReturn(CONFIG) .anyTimes(); expect(manager.cfgService.getConfig(APP_ID, IndirectDhcpRelayConfig.class)) .andReturn(CONFIG_INDIRECT) .anyTimes(); manager.coreService = createNiceMock(CoreService.class); expect(manager.coreService.registerApplication(anyString())) .andReturn(APP_ID).anyTimes(); manager.hostService = createNiceMock(HostService.class); expect(manager.hostService.getHostsByIp(OUTER_RELAY_IP_V6)) .andReturn(ImmutableSet.of(OUTER_RELAY_HOST)).anyTimes(); expect(manager.hostService.getHostsByIp(SERVER_IP)) .andReturn(ImmutableSet.of(SERVER_HOST)).anyTimes(); expect(manager.hostService.getHostsByIp(SERVER_IP_V6)) .andReturn(ImmutableSet.of(SERVER_HOST)).anyTimes(); expect(manager.hostService.getHostsByIp(GATEWAY_IP)) .andReturn(ImmutableSet.of(SERVER_HOST)).anyTimes(); expect(manager.hostService.getHostsByIp(GATEWAY_IP_V6)) .andReturn(ImmutableSet.of(SERVER_HOST)).anyTimes(); expect(manager.hostService.getHostsByIp(CLIENT_LL_IP_V6)) .andReturn(ImmutableSet.of(EXISTS_HOST)).anyTimes(); expect(manager.hostService.getHost(OUTER_RELAY_HOST_ID)).andReturn(OUTER_RELAY_HOST).anyTimes(); packetService = new MockPacketService(); manager.packetService = packetService; manager.compCfgService = createNiceMock(ComponentConfigService.class); deviceService = createNiceMock(DeviceService.class); Device device = createNiceMock(Device.class); expect(device.is(Pipeliner.class)).andReturn(true).anyTimes(); expect(deviceService.getDevice(DEV_1_ID)).andReturn(device).anyTimes(); expect(deviceService.getDevice(DEV_2_ID)).andReturn(device).anyTimes(); replay(deviceService, device); mockRouteStore = new MockRouteStore(); mockDhcpRelayStore = new MockDhcpRelayStore(); mockDhcpRelayCountersStore = new MockDhcpRelayCountersStore(); manager.dhcpRelayStore = mockDhcpRelayStore; manager.deviceService = deviceService; manager.interfaceService = new MockInterfaceService(); flowObjectiveService = EasyMock.niceMock(FlowObjectiveService.class); mockHostProviderService = createNiceMock(HostProviderService.class); v4Handler = new Dhcp4HandlerImpl(); v4Handler.providerService = mockHostProviderService; v4Handler.dhcpRelayStore = mockDhcpRelayStore; v4Handler.hostService = manager.hostService; v4Handler.interfaceService = manager.interfaceService; v4Handler.packetService = manager.packetService; v4Handler.routeStore = mockRouteStore; v4Handler.coreService = createNiceMock(CoreService.class); v4Handler.flowObjectiveService = flowObjectiveService; v4Handler.appId = TestApplicationId.create(Dhcp4HandlerImpl.DHCP_V4_RELAY_APP); v4Handler.deviceService = deviceService; manager.v4Handler = v4Handler; v6Handler = new Dhcp6HandlerImpl(); v6Handler.dhcpRelayStore = mockDhcpRelayStore; v6Handler.dhcpRelayCountersStore = mockDhcpRelayCountersStore; v6Handler.hostService = manager.hostService; v6Handler.interfaceService = manager.interfaceService; v6Handler.packetService = manager.packetService; v6Handler.routeStore = mockRouteStore; v6Handler.providerService = mockHostProviderService; v6Handler.coreService = createNiceMock(CoreService.class); v6Handler.flowObjectiveService = flowObjectiveService; v6Handler.appId = TestApplicationId.create(Dhcp6HandlerImpl.DHCP_V6_RELAY_APP); v6Handler.deviceService = deviceService; manager.v6Handler = v6Handler; // properties Dictionary<String, Object> dictionary = createNiceMock(Dictionary.class); expect(dictionary.get("arpEnabled")).andReturn(true).anyTimes(); expect(dictionary.get("dhcpPollInterval")).andReturn(120).anyTimes(); ComponentContext context = createNiceMock(ComponentContext.class); expect(context.getProperties()).andReturn(dictionary).anyTimes(); replay(manager.cfgService, manager.coreService, manager.hostService, manager.compCfgService, dictionary, context); manager.activate(context); }
Example #28
Source File: OpenstackManagementWebResource.java From onos with Apache License 2.0 | 4 votes |
private void configStatefulSnatBase(boolean snatFlag) { ComponentConfigService service = get(ComponentConfigService.class); String snatComponent = OpenstackRoutingSnatHandler.class.getName(); service.setProperty(snatComponent, USE_STATEFUL_SNAT_NAME, String.valueOf(snatFlag)); }
Example #29
Source File: XmppControllerImplTest.java From onos with Apache License 2.0 | 4 votes |
/** * Sets up devices to use as data, mocks and launches a controller instance. */ @Before public void setUp() { device1 = new XmppDeviceAdapter(); jid1 = new XmppDeviceId(new JID("[email protected]")); device2 = new XmppDeviceAdapter(); jid2 = new XmppDeviceId(new JID("[email protected]")); device3 = new XmppDeviceAdapter(); jid3 = new XmppDeviceId(new JID("[email protected]")); controller = new XmppControllerImpl(); agent = controller.agent; testXmppDeviceListener = new TestXmppDeviceListener(); controller.addXmppDeviceListener(testXmppDeviceListener); testXmppIqListener = new TestXmppIqListener(); controller.addXmppIqListener(testXmppIqListener, testNamespace); testXmppMessageListener = new TestXmppMessageListener(); controller.addXmppMessageListener(testXmppMessageListener); testXmppPresenceListener = new TestXmppPresenceListener(); controller.addXmppPresenceListener(testXmppPresenceListener); CoreService mockCoreService = EasyMock.createMock(CoreService.class); controller.coreService = mockCoreService; ComponentConfigService mockCfgService = EasyMock.createMock(ComponentConfigService.class); expect(mockCfgService.getProperties(anyObject())).andReturn(ImmutableSet.of()); mockCfgService.registerProperties(controller.getClass()); expectLastCall(); mockCfgService.unregisterProperties(controller.getClass(), false); expectLastCall(); expect(mockCfgService.getProperties(anyObject())).andReturn(ImmutableSet.of()); controller.cfgService = mockCfgService; replay(mockCfgService); ComponentContext mockContext = EasyMock.createMock(ComponentContext.class); Dictionary<String, Object> properties = new Hashtable<>(); properties.put("xmppPort", "5269"); expect(mockContext.getProperties()).andReturn(properties); replay(mockContext); controller.activate(mockContext); }
Example #30
Source File: OpenstackConfigStatefulSnatCommand.java From onos with Apache License 2.0 | 4 votes |
private void configSnatMode(boolean snatMode) { ComponentConfigService service = get(ComponentConfigService.class); String snatComponent = OpenstackRoutingSnatHandler.class.getName(); service.setProperty(snatComponent, USE_STATEFUL_SNAT, String.valueOf(snatMode)); }