Search in sources :

Example 41 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class KubevirtNodeWebResourceTest method setUpTest.

/**
 * Sets up the global values for all the tests.
 */
@Before
public void setUpTest() {
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    codecService.registerCodec(KubevirtNode.class, new KubevirtNodeCodec());
    ServiceDirectory testDirectory = new TestServiceDirectory().add(KubevirtNodeAdminService.class, mockKubevirtNodeAdminService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
    kubevirtNode = DefaultKubevirtNode.builder().hostname("worker-node").type(KubevirtNode.Type.WORKER).dataIp(IpAddress.valueOf("10.134.34.222")).managementIp(IpAddress.valueOf("10.134.231.30")).intgBridge(DeviceId.deviceId("of:00000000000000a1")).tunBridge(DeviceId.deviceId("of:00000000000000a2")).state(KubevirtNodeState.INIT).build();
}
Also used : KubevirtNodeCodec(org.onosproject.kubevirtnode.codec.KubevirtNodeCodec) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) KubevirtNodeAdminService(org.onosproject.kubevirtnode.api.KubevirtNodeAdminService) CodecManager(org.onosproject.codec.impl.CodecManager) Before(org.junit.Before)

Example 42 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class VirtualNetworkMastershipManagerTest method setUp.

@Before
public void setUp() throws Exception {
    virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
    CoreService coreService = new TestCoreService();
    TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
    TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
    virtualNetworkManagerStore.activate();
    manager = new VirtualNetworkManager();
    manager.store = virtualNetworkManagerStore;
    TestUtils.setField(manager, "coreService", coreService);
    eventDeliveryService = new TestEventDispatcher();
    NetTestTools.injectEventDispatcher(manager, eventDeliveryService);
    SimpleVirtualMastershipStore store = new SimpleVirtualMastershipStore();
    TestUtils.setField(store, "coreService", coreService);
    store.activate();
    testClusterService = new TestClusterService();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(VirtualNetworkStore.class, virtualNetworkManagerStore).add(CoreService.class, coreService).add(EventDeliveryService.class, eventDeliveryService).add(ClusterService.class, testClusterService).add(VirtualNetworkMastershipStore.class, store);
    TestUtils.setField(manager, "serviceDirectory", testDirectory);
    manager.activate();
    createVnets();
    mastershipMgr1 = new VirtualNetworkMastershipManager(manager, vnet1.id());
    mastershipMgr2 = new VirtualNetworkMastershipManager(manager, vnet2.id());
    service = mastershipMgr1;
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) SimpleVirtualMastershipStore(org.onosproject.incubator.net.virtual.store.impl.SimpleVirtualMastershipStore) DistributedVirtualNetworkStore(org.onosproject.incubator.net.virtual.store.impl.DistributedVirtualNetworkStore) ClusterService(org.onosproject.cluster.ClusterService) TestStorageService(org.onosproject.store.service.TestStorageService) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CoreService(org.onosproject.core.CoreService) Before(org.junit.Before)

Example 43 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class DecodeInstructionCodecHelper method decodeExtension.

/**
 * Decodes a extension instruction.
 *
 * @return extension treatment
 */
private Instruction decodeExtension() {
    ObjectNode node = (ObjectNode) json.get(InstructionCodec.EXTENSION);
    if (node != null) {
        DeviceId deviceId = getDeviceId();
        ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
        DeviceService deviceService = serviceDirectory.get(DeviceService.class);
        Device device = deviceService.getDevice(deviceId);
        if (device == null) {
            throw new IllegalArgumentException("Device not found");
        }
        if (device.is(ExtensionTreatmentCodec.class)) {
            ExtensionTreatmentCodec treatmentCodec = device.as(ExtensionTreatmentCodec.class);
            ExtensionTreatment treatment = treatmentCodec.decode(node, context);
            return Instructions.extension(treatment, deviceId);
        } else {
            throw new IllegalArgumentException("There is no codec to decode extension for device " + deviceId.toString());
        }
    }
    return null;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DeviceId(org.onosproject.net.DeviceId) ServiceDirectory(org.onlab.osgi.ServiceDirectory) DefaultServiceDirectory(org.onlab.osgi.DefaultServiceDirectory) Device(org.onosproject.net.Device) ExtensionTreatmentCodec(org.onosproject.net.flow.ExtensionTreatmentCodec) DeviceService(org.onosproject.net.device.DeviceService) DefaultServiceDirectory(org.onlab.osgi.DefaultServiceDirectory) ExtensionTreatment(org.onosproject.net.flow.instructions.ExtensionTreatment)

Example 44 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class DevicesResourceTest method setUpMocks.

/**
 * Initializes test mocks and environment.
 */
@Before
public void setUpMocks() {
    mockDeviceService = createMock(DeviceService.class);
    mockDriverService = createMock(DriverService.class);
    expect(mockDeviceService.isAvailable(isA(DeviceId.class))).andReturn(true).anyTimes();
    expect(mockDeviceService.getRole(isA(DeviceId.class))).andReturn(MastershipRole.MASTER).anyTimes();
    expect(mockDeviceService.getLastUpdatedInstant(isA(DeviceId.class))).andReturn(0L).anyTimes();
    expect(mockDeviceService.localStatus(isA(DeviceId.class))).andReturn("").anyTimes();
    // Register the services needed for the test
    CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(DeviceService.class, mockDeviceService).add(DriverService.class, mockDriverService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) DeviceService(org.onosproject.net.device.DeviceService) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) DriverService(org.onosproject.net.driver.DriverService) Before(org.junit.Before)

Example 45 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class HostResourceTest method setUpTest.

/**
 * Initializes test mocks and environment.
 */
@Before
public void setUpTest() {
    expect(mockHostService.getHosts()).andReturn(hosts).anyTimes();
    // Register the services needed for the test
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(HostService.class, mockHostService).add(HostAdminService.class, mockHostService).add(CodecService.class, codecService).add(HostProviderRegistry.class, mockHostProviderRegistry);
    setServiceDirectory(testDirectory);
}
Also used : HostService(org.onosproject.net.host.HostService) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecService(org.onosproject.codec.CodecService) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) Before(org.junit.Before)

Aggregations

ServiceDirectory (org.onlab.osgi.ServiceDirectory)54 Before (org.junit.Before)51 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)51 CodecManager (org.onosproject.codec.impl.CodecManager)30 DeviceService (org.onosproject.net.device.DeviceService)7 CfmCodecContext (org.onosproject.cfm.CfmCodecContext)5 CodecService (org.onosproject.codec.CodecService)5 CoreService (org.onosproject.core.CoreService)3 CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)3 OpenstackRouterAdminService (org.onosproject.openstacknetworking.api.OpenstackRouterAdminService)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 DefaultServiceDirectory (org.onlab.osgi.DefaultServiceDirectory)2 ClusterService (org.onosproject.cluster.ClusterService)2 SoamService (org.onosproject.incubator.net.l2monitoring.soam.SoamService)2 K8sNetworkAdminService (org.onosproject.k8snetworking.api.K8sNetworkAdminService)2 GroupService (org.onosproject.net.group.GroupService)2 OpenstackNetworkAdminService (org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService)2 OpenstackSecurityGroupAdminService (org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService)2 RemovalNotification (com.google.common.cache.RemovalNotification)1 MetricsService (org.onlab.metrics.MetricsService)1