Search in sources :

Example 16 with CoreService

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());
            }
        });
    }
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 17 with CoreService

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);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CoreService(org.onosproject.core.CoreService) CodecManager(org.onosproject.codec.impl.CodecManager) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) Before(org.junit.Before)

Example 18 with CoreService

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());
}
Also used : EncapsulationType(org.onosproject.net.EncapsulationType) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) SdnIpConfig(org.onosproject.sdnip.config.SdnIpConfig) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 19 with CoreService

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());
}
Also used : PacketPriority(org.onosproject.net.packet.PacketPriority) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) ComponentContextAdapter(org.onlab.osgi.ComponentContextAdapter) PacketProcessor(org.onosproject.net.packet.PacketProcessor) PacketService(org.onosproject.net.packet.PacketService) TrafficSelector(org.onosproject.net.flow.TrafficSelector) CoreService(org.onosproject.core.CoreService) TestApplicationId(org.onosproject.TestApplicationId) ApplicationId(org.onosproject.core.ApplicationId) Before(org.junit.Before)

Example 20 with CoreService

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

CoreService (org.onosproject.core.CoreService)71 Before (org.junit.Before)31 ApplicationId (org.onosproject.core.ApplicationId)30 FlowRuleService (org.onosproject.net.flow.FlowRuleService)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 ComponentConfigAdapter (org.onosproject.cfg.ComponentConfigAdapter)12 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)12 TrafficSelector (org.onosproject.net.flow.TrafficSelector)11 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)11 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 DeviceId (org.onosproject.net.DeviceId)10 IntentExtensionService (org.onosproject.net.intent.IntentExtensionService)10 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)9 MockResourceService (org.onosproject.net.resource.MockResourceService)9 TestEventDispatcher (org.onosproject.common.event.impl.TestEventDispatcher)8 DistributedVirtualNetworkStore (org.onosproject.incubator.net.virtual.store.impl.DistributedVirtualNetworkStore)8 DeviceService (org.onosproject.net.device.DeviceService)8 TestStorageService (org.onosproject.store.service.TestStorageService)8 ArrayList (java.util.ArrayList)7 DomainService (org.onosproject.net.domain.DomainService)6