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);
}
}
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();
}
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);
}
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);
}
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);
}
Aggregations