use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class CfmMepManagerTest method testCreateMepBehaviorNotSupported.
@Test
public void testCreateMepBehaviorNotSupported() throws CfmConfigException {
final DeviceId deviceId3 = DeviceId.deviceId("netconf:3.2.3.4:830");
Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
Driver testDriver3 = new DefaultDriver(TEST_DRIVER_3, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_3, behaviours, new HashMap<>());
Device device3 = new DefaultDevice(ProviderId.NONE, deviceId3, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_3, TEST_SN, new ChassisId(2), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER_3).build());
expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1)).andReturn(Optional.ofNullable(ma1)).anyTimes();
replay(mdService);
expect(deviceService.getDevice(deviceId3)).andReturn(device3).anyTimes();
replay(deviceService);
expect(driverService.getDriver(deviceId3)).andReturn(testDriver3).anyTimes();
replay(driverService);
MepId mepId3 = MepId.valueOf((short) 3);
Mep mep3 = DefaultMep.builder(mepId3, deviceId3, PortNumber.portNumber(1), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
try {
mepManager.createMep(MDNAME1, MANAME1, mep3);
fail("Expecting CfmConfigException because driver does not support behavior");
} catch (CfmConfigException e) {
assertEquals("Device netconf:3.2.3.4:830 does not support " + "CfmMepProgrammable behaviour.", e.getMessage());
}
}
use of org.onosproject.net.driver.Driver in project onos by opennetworkinglab.
the class TopologyViewMessageHandlerBase method deviceMessage.
// Produces a device event message to the client.
protected ObjectNode deviceMessage(DeviceEvent event) {
Device device = event.subject();
String uiType = device.annotations().value(AnnotationKeys.UI_TYPE);
String driverName = device.annotations().value(DRIVER);
Driver driver = driverName == null ? null : services.driver().getDriver(driverName);
String devType = uiType != null ? uiType : (driver != null ? driver.getProperty(AnnotationKeys.UI_TYPE) : null);
if (devType == null) {
devType = device.type().toString().toLowerCase();
}
String name = device.annotations().value(AnnotationKeys.NAME);
name = isNullOrEmpty(name) ? device.id().toString() : name;
ObjectNode payload = objectNode().put("id", device.id().toString()).put("type", devType).put("online", services.device().isAvailable(device.id())).put("master", master(device.id()));
payload.set("labels", labels("", name, device.id().toString()));
payload.set("props", props(device.annotations()));
BasicDeviceConfig cfg = get(NetworkConfigService.class).getConfig(device.id(), BasicDeviceConfig.class);
if (!addLocation(cfg, payload)) {
addMetaUi(device.id().toString(), payload);
}
String type = DEVICE_EVENT.get(event.type());
return JsonUtils.envelope(type, payload);
}
Aggregations