Search in sources :

Example 31 with CoreService

use of org.onosproject.core.CoreService in project onos by opennetworkinglab.

the class ApplicationsWebResource method getAppIds.

/**
 * Gets a collection of application ids.
 * Returns array of all registered application ids.
 *
 * @return 200 OK; 404; 401
 * @onos.rsModel ApplicationIds
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("ids")
public Response getAppIds() {
    CoreService service = get(CoreService.class);
    Set<ApplicationId> appIds = service.getAppIds();
    return ok(encodeArray(ApplicationId.class, "applicationIds", appIds)).build();
}
Also used : CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 32 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 33 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)

Example 34 with CoreService

use of org.onosproject.core.CoreService in project up4 by omec-project.

the class ConfigPscEncap method doExecute.

@Override
protected void doExecute() throws Exception {
    if (enable == null) {
        return;
    }
    NetworkConfigService netCfgService = get(NetworkConfigService.class);
    CoreService coreService = get(CoreService.class);
    ApplicationId appId = coreService.getAppId(APP_NAME);
    Up4Config config = netCfgService.getConfig(appId, Up4Config.class);
    if (config == null) {
        print("No UP4 netcfg has been pushed yet");
        return;
    }
    config.setPscEncap(enable);
    netCfgService.applyConfig(appId, Up4Config.class, config.node());
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId) Up4Config(org.omecproject.up4.config.Up4Config)

Example 35 with CoreService

use of org.onosproject.core.CoreService in project fabric-tna by stratum.

the class FabricIntProgrammableTest method setup.

@Before
public void setup() {
    FabricCapabilities capabilities = createMock(FabricCapabilities.class);
    expect(capabilities.isArchTna()).andReturn(!this.isArchV1model).anyTimes();
    expect(capabilities.isArchV1model()).andReturn(this.isArchV1model).anyTimes();
    expect(capabilities.hasHashedTable()).andReturn(true).anyTimes();
    expect(capabilities.supportDoubleVlanTerm()).andReturn(false).anyTimes();
    expect(capabilities.hwPipeCount()).andReturn(4).anyTimes();
    replay(capabilities);
    // Services mock
    flowRuleService = createMock(FlowRuleService.class);
    groupService = createMock(GroupService.class);
    netcfgService = createMock(NetworkConfigService.class);
    coreService = createMock(CoreService.class);
    hostService = createMock(HostService.class);
    expect(coreService.getAppId(anyString())).andReturn(APP_ID).anyTimes();
    expect(netcfgService.getConfig(LEAF_DEVICE_ID, SegmentRoutingDeviceConfig.class)).andReturn(getSrConfig(LEAF_DEVICE_ID, "/sr.json")).anyTimes();
    expect(netcfgService.getConfig(SPINE_DEVICE_ID, SegmentRoutingDeviceConfig.class)).andReturn(getSrConfig(SPINE_DEVICE_ID, "/sr-spine.json")).anyTimes();
    expect(hostService.getHostsByIp(COLLECTOR_IP)).andReturn(ImmutableSet.of(COLLECTOR_HOST)).anyTimes();
    replay(coreService, netcfgService, hostService);
    DriverHandler driverHandler = createMock(DriverHandler.class);
    expect(driverHandler.get(FlowRuleService.class)).andReturn(flowRuleService).anyTimes();
    expect(driverHandler.get(GroupService.class)).andReturn(groupService).anyTimes();
    expect(driverHandler.get(NetworkConfigService.class)).andReturn(netcfgService).anyTimes();
    expect(driverHandler.get(CoreService.class)).andReturn(coreService).anyTimes();
    expect(driverHandler.get(HostService.class)).andReturn(hostService).anyTimes();
    replay(driverHandler);
    driverData = createMock(DriverData.class);
    expect(driverData.deviceId()).andReturn(LEAF_DEVICE_ID).anyTimes();
    replay(driverData);
    intProgrammable = partialMockBuilder(FabricIntProgrammable.class).addMockedMethod("getFieldSize").createMock();
    expect(intProgrammable.getFieldSize(P4InfoConstants.FABRIC_EGRESS_INT_EGRESS_QUEUE_LATENCY_THRESHOLDS, P4InfoConstants.HDR_HOP_LATENCY_UPPER)).andReturn(16).anyTimes();
    expect(intProgrammable.getFieldSize(P4InfoConstants.FABRIC_EGRESS_INT_EGRESS_QUEUE_LATENCY_THRESHOLDS, P4InfoConstants.HDR_HOP_LATENCY_LOWER)).andReturn(16).anyTimes();
    replay(intProgrammable);
    TestUtils.setField(intProgrammable, "capabilities", capabilities);
    TestUtils.setField(intProgrammable, "handler", driverHandler);
    TestUtils.setField(intProgrammable, "data", driverData);
    TestUtils.setField(intProgrammable, "log", getLogger(""));
    testInit();
}
Also used : HostService(org.onosproject.net.host.HostService) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) DriverData(org.onosproject.net.driver.DriverData) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DriverHandler(org.onosproject.net.driver.DriverHandler) CoreService(org.onosproject.core.CoreService) FlowRuleService(org.onosproject.net.flow.FlowRuleService) GroupService(org.onosproject.net.group.GroupService) 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