Search in sources :

Example 1 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class OpenstackConfigArpModeCommand method configArpMode.

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);
    }
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService)

Example 2 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class OpenstackManagementWebResource method configArpMode.

/**
 * 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();
        // 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();
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class ComponentNameCompleter method complete.

@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);
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter)

Example 4 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class LispControllerImplTest method setUp.

/**
 * Sets up routers to use as data, mocks and launches a controller instance.
 */
@Before
public void setUp() {
    try {
        router1 = new LispRouterAdapter();
        routerId1 = LispRouterId.routerId(new URI("lisp:10.1.1.1"));
        router2 = new LispRouterAdapter();
        routerId2 = LispRouterId.routerId(new URI("lisp:10.1.1.2"));
        router3 = new LispRouterAdapter();
        routerId3 = LispRouterId.routerId(new URI("lisp:10.1.1.3"));
    } catch (URISyntaxException e) {
        // this will never happen...
        fail();
    }
    controller = new LispControllerImpl();
    agent = controller.agent;
    routerListener = new TestRouterListener();
    controller.addRouterListener(routerListener);
    messageListener = new TestMessageListener();
    controller.addMessageListener(messageListener);
    controller.coreService = createMock(CoreService.class);
    ComponentConfigService mockConfigService = createMock(ComponentConfigService.class);
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mockConfigService.registerProperties(controller.getClass());
    expectLastCall();
    mockConfigService.unregisterProperties(controller.getClass(), false);
    expectLastCall();
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    controller.cfgService = mockConfigService;
    replay(mockConfigService);
    ComponentContext mockContext = createMock(ComponentContext.class);
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put("lispAuthKey", "onos");
    properties.put("lispAuthKeyId", 1);
    expect(mockContext.getProperties()).andReturn(properties);
    replay(mockContext);
    LispControllerBootstrap bootstrap = createMock(LispControllerBootstrap.class);
    bootstrap.start();
    expectLastCall();
    controller.bootstrap = bootstrap;
    replay(bootstrap);
    controller.activate(mockContext);
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) ComponentContext(org.osgi.service.component.ComponentContext) Hashtable(java.util.Hashtable) CoreService(org.onosproject.core.CoreService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) EasyMock.anyObject(org.easymock.EasyMock.anyObject) LispRouterAdapter(org.onosproject.lisp.ctl.LispRouterAdapter) Before(org.junit.Before)

Example 5 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class XmppControllerImplTest method setUp.

/**
 * 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("agent1@testxmpp.org"));
    device2 = new XmppDeviceAdapter();
    jid2 = new XmppDeviceId(new JID("agent2@testxmpp.org"));
    device3 = new XmppDeviceAdapter();
    jid3 = new XmppDeviceId(new JID("agent3@testxmpp.org"));
    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);
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) JID(org.xmpp.packet.JID) ComponentContext(org.osgi.service.component.ComponentContext) Hashtable(java.util.Hashtable) CoreService(org.onosproject.core.CoreService) XmppDeviceId(org.onosproject.xmpp.core.XmppDeviceId) Before(org.junit.Before)

Aggregations

ComponentConfigService (org.onosproject.cfg.ComponentConfigService)27 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)8 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)7 GET (javax.ws.rs.GET)7 Before (org.junit.Before)5 CoreService (org.onosproject.core.CoreService)4 Hashtable (java.util.Hashtable)3 Consumes (javax.ws.rs.Consumes)3 ComponentContext (org.osgi.service.component.ComponentContext)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 POST (javax.ws.rs.POST)2 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)2 EasyMock.anyObject (org.easymock.EasyMock.anyObject)2 ConfigProperty (org.onosproject.cfg.ConfigProperty)2 NullProviders (org.onosproject.provider.nil.NullProviders)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DELETE (javax.ws.rs.DELETE)1