Search in sources :

Example 51 with CoreService

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

the class OpenFlowControllerImplTest method setUp.

/**
 * Sets up switches to use as data, mocks and launches a controller instance.
 */
@Before
public void setUp() {
    try {
        switch1 = new OpenflowSwitchDriverAdapter();
        dpid1 = Dpid.dpid(new URI("of:0000000000000111"));
        switch2 = new OpenflowSwitchDriverAdapter();
        dpid2 = Dpid.dpid(new URI("of:0000000000000222"));
        switch3 = new OpenflowSwitchDriverAdapter();
        dpid3 = Dpid.dpid(new URI("of:0000000000000333"));
    } catch (URISyntaxException ex) {
        // Does not happen
        fail();
    }
    controller = new OpenFlowControllerImpl();
    agent = controller.agent;
    switchListener = new TestSwitchListener();
    controller.addListener(switchListener);
    CoreService mockCoreService = EasyMock.createMock(CoreService.class);
    controller.coreService = mockCoreService;
    OpenFlowService mockOpenFlowService = EasyMock.createMock(OpenFlowService.class);
    controller.openFlowManager = mockOpenFlowService;
    ComponentConfigService mockConfigService = EasyMock.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);
    NetworkConfigRegistry netConfigService = EasyMock.createMock(NetworkConfigRegistry.class);
    controller.netCfgService = netConfigService;
    ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put("openflowPorts", Integer.toString(EPHEMERAL_PORT));
    expect(mockContext.getProperties()).andReturn(properties);
    replay(mockContext);
    controller.activate(mockContext);
}
Also used : OpenFlowService(org.onosproject.openflow.controller.OpenFlowService) 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) OpenflowSwitchDriverAdapter(org.onosproject.openflow.OpenflowSwitchDriverAdapter) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) EasyMock.anyObject(org.easymock.EasyMock.anyObject) Before(org.junit.Before)

Example 52 with CoreService

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

the class VirtualNetworkMeterManagerTest method setUp.

@Before
public void setUp() throws Exception {
    virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
    CoreService coreService = new TestCoreService();
    TestStorageService storageService = new TestStorageService();
    TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
    TestUtils.setField(virtualNetworkManagerStore, "storageService", storageService);
    virtualNetworkManagerStore.activate();
    meterStore = new SimpleVirtualMeterStore();
    providerRegistryService = new VirtualProviderManager();
    providerRegistryService.registerProvider(provider);
    manager = new VirtualNetworkManager();
    manager.store = virtualNetworkManagerStore;
    TestUtils.setField(manager, "coreService", coreService);
    eventDeliveryService = new TestEventDispatcher();
    NetTestTools.injectEventDispatcher(manager, eventDeliveryService);
    // eventDeliveryService.addSink(VirtualEvent.class, listenerRegistryManager);
    appId = new TestApplicationId("MeterManagerTest");
    testDirectory = new TestServiceDirectory().add(VirtualNetworkStore.class, virtualNetworkManagerStore).add(CoreService.class, coreService).add(VirtualProviderRegistryService.class, providerRegistryService).add(EventDeliveryService.class, eventDeliveryService).add(StorageService.class, storageService).add(VirtualNetworkMeterStore.class, meterStore);
    TestUtils.setField(manager, "serviceDirectory", testDirectory);
    manager.activate();
    vnet1 = setupVirtualNetworkTopology(manager, TID1);
    vnet2 = setupVirtualNetworkTopology(manager, TID2);
    meterManager1 = new VirtualNetworkMeterManager(manager, vnet1.id());
    meterManager2 = new VirtualNetworkMeterManager(manager, vnet2.id());
    providerService1 = (VirtualMeterProviderService) providerRegistryService.getProviderService(vnet1.id(), VirtualMeterProvider.class);
    providerService2 = (VirtualMeterProviderService) providerRegistryService.getProviderService(vnet2.id(), VirtualMeterProvider.class);
    assertTrue("provider should be registered", providerRegistryService.getProviders().contains(provider.id()));
    setupMeterTestVariables();
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) TestStorageService(org.onosproject.store.service.TestStorageService) SimpleVirtualMeterStore(org.onosproject.incubator.net.virtual.store.impl.SimpleVirtualMeterStore) EventDeliveryService(org.onosproject.event.EventDeliveryService) CoreService(org.onosproject.core.CoreService) TestApplicationId(org.onosproject.TestApplicationId) DistributedVirtualNetworkStore(org.onosproject.incubator.net.virtual.store.impl.DistributedVirtualNetworkStore) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) VirtualNetworkMeterStore(org.onosproject.incubator.net.virtual.VirtualNetworkMeterStore) VirtualProviderManager(org.onosproject.incubator.net.virtual.impl.provider.VirtualProviderManager) Before(org.junit.Before)

Example 53 with CoreService

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

the class VirtualNetworkPacketManagerTest method setUp.

@Before
public void setUp() throws TestUtils.TestUtilsException {
    virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
    TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
    TestUtils.setField(virtualNetworkManagerStore, "storageService", storageService);
    virtualNetworkManagerStore.activate();
    manager = new VirtualNetworkManager();
    manager.store = virtualNetworkManagerStore;
    manager.coreService = coreService;
    NetTestTools.injectEventDispatcher(manager, new TestEventDispatcher());
    flowObjectiveStore = new SimpleVirtualFlowObjectiveStore();
    TestUtils.setField(flowObjectiveStore, "storageService", storageService);
    flowObjectiveStore.activate();
    flowRuleStore = new SimpleVirtualFlowRuleStore();
    flowRuleStore.activate();
    providerRegistryService = new VirtualProviderManager();
    providerRegistryService.registerProvider(provider);
    providerRegistryService.registerProvider(flowRuleProvider);
    testDirectory = new TestServiceDirectory().add(VirtualNetworkStore.class, virtualNetworkManagerStore).add(CoreService.class, coreService).add(VirtualProviderRegistryService.class, providerRegistryService).add(EventDeliveryService.class, eventDeliveryService).add(ClusterService.class, new ClusterServiceAdapter()).add(VirtualNetworkFlowRuleStore.class, flowRuleStore).add(VirtualNetworkFlowObjectiveStore.class, flowObjectiveStore).add(VirtualNetworkPacketStore.class, packetStore);
    TestUtils.setField(manager, "serviceDirectory", testDirectory);
    eventDeliveryService = new TestEventDispatcher();
    NetTestTools.injectEventDispatcher(manager, eventDeliveryService);
    manager.activate();
    vnet1 = VirtualNetworkTestUtil.setupVirtualNetworkTopology(manager, TID1);
    vnet2 = VirtualNetworkTestUtil.setupVirtualNetworkTopology(manager, TID2);
    packetManager1 = new VirtualNetworkPacketManager(manager, vnet1.id());
    packetManager2 = new VirtualNetworkPacketManager(manager, vnet2.id());
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) SimpleVirtualFlowRuleStore(org.onosproject.incubator.net.virtual.store.impl.SimpleVirtualFlowRuleStore) SimpleVirtualFlowObjectiveStore(org.onosproject.incubator.net.virtual.store.impl.SimpleVirtualFlowObjectiveStore) EventDeliveryService(org.onosproject.event.EventDeliveryService) CoreService(org.onosproject.core.CoreService) VirtualNetworkFlowRuleStore(org.onosproject.incubator.net.virtual.VirtualNetworkFlowRuleStore) DistributedVirtualNetworkStore(org.onosproject.incubator.net.virtual.store.impl.DistributedVirtualNetworkStore) ClusterServiceAdapter(org.onosproject.cluster.ClusterServiceAdapter) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) VirtualProviderManager(org.onosproject.incubator.net.virtual.impl.provider.VirtualProviderManager) VirtualNetworkPacketStore(org.onosproject.incubator.net.virtual.VirtualNetworkPacketStore) Before(org.junit.Before)

Example 54 with CoreService

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

the class ApplicationsWebResource method getAppIdByName.

/**
 * Gets applicationId entry by either id or name.
 *
 * @param id   id of application
 * @param name name of application
 * @return 200 OK; 404; 401
 * @onos.rsModel ApplicationId
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("ids/entry")
public Response getAppIdByName(@QueryParam("id") String id, @QueryParam("name") String name) {
    CoreService service = get(CoreService.class);
    ApplicationId appId = null;
    if (id != null) {
        appId = service.getAppId(Short.valueOf(id));
    } else if (name != null) {
        appId = service.getAppId(name);
    }
    return response(appId);
}
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 55 with CoreService

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

the class ApplicationsWebResource method registerAppId.

/**
 * Registers an on or off platform application.
 *
 * @param name application name
 * @return 200 OK; 404; 401
 * @onos.rsModel ApplicationId
 */
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("{name}/register")
public Response registerAppId(@PathParam("name") String name) {
    CoreService service = get(CoreService.class);
    ApplicationId appId = service.registerApplication(name);
    return response(appId);
}
Also used : CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

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