use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class BgpSpeakersListCommand method doExecute.
@Override
protected void doExecute() {
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.getConfig(appId, BgpConfig.class);
if (config == null) {
print("No speakers configured");
return;
}
List<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Lists.newArrayList(config.bgpSpeakers());
Collections.sort(bgpSpeakers, SPEAKERS_COMPARATOR);
if (config.bgpSpeakers().isEmpty()) {
print("No speakers configured");
} else {
bgpSpeakers.forEach(s -> {
if (s.name().isPresent()) {
print(NAME_FORMAT, s.name().get(), s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
} else {
print(FORMAT, s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
}
});
}
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class ApplicationsResourceTest method setUpMocks.
/**
* Initializes test mocks and environment.
*/
@Before
public void setUpMocks() {
appService = createMock(ApplicationAdminService.class);
coreService = createMock(CoreService.class);
expect(appService.getId("one")).andReturn(id1).anyTimes();
expect(appService.getId("two")).andReturn(id2).anyTimes();
expect(appService.getId("three")).andReturn(id3).anyTimes();
expect(appService.getId("four")).andReturn(id4).anyTimes();
expect(appService.getApplication(id3)).andReturn(app3).anyTimes();
expect(appService.getState(isA(ApplicationId.class))).andReturn(ApplicationState.ACTIVE).anyTimes();
// Register the services needed for the test
CodecManager codecService = new CodecManager();
codecService.activate();
ServiceDirectory testDirectory = new TestServiceDirectory().add(ApplicationAdminService.class, appService).add(ApplicationService.class, appService).add(CoreService.class, coreService).add(CodecService.class, codecService);
setServiceDirectory(testDirectory);
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class SdnIpCommand method setEncap.
/**
* Sets the encapsulation type for SDN-IP.
*
* @param encap the encapsulation type
*/
private void setEncap(String encap) {
EncapsulationType encapType = EncapsulationType.enumFromString(encap);
if (encapType.equals(EncapsulationType.NONE) && !encapType.toString().equals(encap)) {
print(ENCAP_NOT_FOUND, encap);
return;
}
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(SdnIp.SDN_IP_APP);
SdnIpConfig config = configService.addConfig(appId, SdnIpConfig.class);
config.setEncap(encapType);
config.apply();
// configService.applyConfig(appId, SdnIpConfig.class, config.node());
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class NeighbourResolutionManagerTest method setUp.
@Before
public void setUp() throws Exception {
neighbourManager = new NeighbourResolutionManager();
packetService = createMock(PacketService.class);
packetService.requestPackets(anyObject(TrafficSelector.class), anyObject(PacketPriority.class), anyObject(ApplicationId.class));
expectLastCall().anyTimes();
packetService.addProcessor(anyObject(PacketProcessor.class), anyInt());
expectLastCall().andDelegateTo(new TestPacketService()).once();
packetService.cancelPackets(anyObject(TrafficSelector.class), anyObject(PacketPriority.class), anyObject(ApplicationId.class));
expectLastCall().anyTimes();
replay(packetService);
neighbourManager.packetService = packetService;
CoreService coreService = createNiceMock(CoreService.class);
replay(coreService);
neighbourManager.coreService = coreService;
neighbourManager.componentConfigService = new ComponentConfigAdapter();
neighbourManager.activate(new ComponentContextAdapter());
}
use of org.onosproject.core.CoreService 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