use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class SoamManagerTest method testCreateDmNoBehavior.
@Test
public void testCreateDmNoBehavior() throws CfmConfigException, SoamConfigException {
final DeviceId deviceId3 = DeviceId.deviceId("netconf:3.2.3.4:830");
final MepId mepId3 = MepId.valueOf((short) 3);
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(deviceService.getDevice(deviceId3)).andReturn(device3).anyTimes();
replay(deviceService);
MepEntry mep3 = DefaultMepEntry.builder(mepId3, deviceId3, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).buildEntry();
expect(mepService.getMep(MDNAME1, MANAME1, mepId3)).andReturn(mep3).anyTimes();
replay(mepService);
expect(driverService.getDriver(deviceId3)).andReturn(testDriver3).anyTimes();
replay(driverService);
DelayMeasurementCreate dmCreate1 = DefaultDelayMeasurementCreate.builder(DelayMeasurementCreate.DmType.DM1DMTX, DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 11), Mep.Priority.PRIO3).binsPerFdInterval((short) 4).binsPerFdrInterval((short) 5).binsPerIfdvInterval((short) 6).build();
try {
soamManager.createDm(MDNAME1, MANAME1, mepId3, dmCreate1);
fail("Expecting exception since device does not support behavior");
} catch (CfmConfigException e) {
assertEquals("Device netconf:3.2.3.4:830 from MEP :md-1/" + "ma-1-1/3 does not implement SoamDmProgrammable", e.getMessage());
}
}
use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class IntentsDiagnosisCommand method getDeviceString.
private String getDeviceString(Device dev) {
StringBuilder buf = new StringBuilder();
if (dev != null) {
buf.append(String.format("Device: %s, ", dev.id()));
buf.append(String.format("%s, ", dev.type()));
buf.append(String.format("%s, ", dev.manufacturer()));
buf.append(String.format("%s, ", dev.hwVersion()));
buf.append(String.format("%s, ", dev.swVersion()));
if (dev instanceof DefaultDevice) {
DefaultDevice dfltDev = (DefaultDevice) dev;
if (dfltDev.driver() != null) {
buf.append(String.format("%s, ", dfltDev.driver().name()));
}
String channelId = dfltDev.annotations().value("channelId");
if (channelId != null) {
buf.append(String.format("%s, ", channelId));
}
}
}
return buf.toString();
}
use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class ECDeviceStore method composeDevice.
/**
* Returns a Device, merging descriptions from multiple Providers.
*
* @param deviceId device identifier
* @return Device instance
*/
private Device composeDevice(DeviceId deviceId) {
ProviderId primaryProviderId = getPrimaryProviderId(deviceId);
DeviceDescription primaryDeviceDescription = deviceDescriptions.get(new DeviceKey(primaryProviderId, deviceId));
Type type = primaryDeviceDescription.type();
String manufacturer = primaryDeviceDescription.manufacturer();
String hwVersion = primaryDeviceDescription.hwVersion();
String swVersion = primaryDeviceDescription.swVersion();
String serialNumber = primaryDeviceDescription.serialNumber();
ChassisId chassisId = primaryDeviceDescription.chassisId();
DefaultAnnotations annotations = mergeAnnotations(deviceId);
return new DefaultDevice(primaryProviderId, deviceId, type, manufacturer, hwVersion, swVersion, serialNumber, chassisId, annotations);
}
use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class LinkDiscoveryCiscoImpl method findRemoteDeviceByChassisId.
private Device findRemoteDeviceByChassisId(DeviceService deviceService, String remoteChassisIdString) {
String forMacTmp = remoteChassisIdString.replace(".", "").replaceAll("(.{2})", "$1:").trim().substring(0, 17);
MacAddress mac = MacAddress.valueOf(forMacTmp);
ChassisId remoteChassisId = new ChassisId(mac.toLong());
Optional<Device> remoteDeviceOptional;
Supplier<Stream<Device>> deviceStream = () -> StreamSupport.stream(deviceService.getAvailableDevices().spliterator(), false);
remoteDeviceOptional = deviceStream.get().filter(device -> device.chassisId() != null && MacAddress.valueOf(device.chassisId().value()).equals(mac)).findAny();
if (remoteDeviceOptional.isPresent()) {
return remoteDeviceOptional.get();
} else {
remoteDeviceOptional = deviceStream.get().filter(device -> Tools.stream(deviceService.getPorts(device.id())).anyMatch(port -> port.annotations().keys().contains(AnnotationKeys.PORT_MAC) && MacAddress.valueOf(port.annotations().value(AnnotationKeys.PORT_MAC)).equals(mac))).findAny();
if (remoteDeviceOptional.isPresent()) {
return remoteDeviceOptional.get();
} else {
log.debug("remote device not found. remoteChassisId value: {}", remoteChassisId);
return new DefaultDevice(ProviderId.NONE, DeviceId.deviceId(LLDP + mac.toString()), Device.Type.SWITCH, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, remoteChassisId, DefaultAnnotations.EMPTY);
}
}
}
use of org.onosproject.net.DefaultDevice in project onos by opennetworkinglab.
the class HostLocationProviderTest method removeHostByDevicePortDown.
@Test
public void removeHostByDevicePortDown() {
provider.modified(CTX_FOR_REMOVE);
testProcessor.process(new TestArpPacketContext(DEV1));
testProcessor.process(new TestArpPacketContext(DEV4));
Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
assertEquals("incorrect remove count", 1, providerService.locationRemoveCount);
device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
assertEquals("incorrect remove count", 2, providerService.locationRemoveCount);
}
Aggregations