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