use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class CzechLightDiscovery method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
NetconfSession session = getNetconfSession();
if (session == null) {
log.error("Cannot request NETCONF session for {}", data().deviceId());
return null;
}
DefaultAnnotations.Builder annotations = DefaultAnnotations.builder();
final var noDevice = new DefaultDeviceDescription(handler().data().deviceId().uri(), Device.Type.OTHER, null, null, null, null, null, annotations.build());
try {
Boolean isLineDegree = false, isAddDrop = false, isCoherentAddDrop = false, isInlineAmp = false;
var data = doGetXPath(getNetconfSession(), YANGLIB_XML_PREFIX, YANGLIB_XMLNS, YANGLIB_XPATH_FILTER);
if (!data.containsKey(YANGLIB_KEY_REVISION)) {
log.error("Not talking to a supported CzechLight device, is that a teapot?");
return noDevice;
}
final var revision = data.getString(YANGLIB_KEY_REVISION);
if (data.getString(YANGLIB_KEY_MODULE_NAME).equals(MOD_ROADM_DEVICE)) {
if (!revision.equals(MOD_ROADM_DEVICE_DATE)) {
log.error("Revision mismatch for YANG module {}: got {}", MOD_ROADM_DEVICE, revision);
return noDevice;
}
final var features = data.getStringArray(YANGLIB_PATH_QUERY_FEATURES);
isLineDegree = Arrays.stream(features).anyMatch(s -> s.equals(MOD_ROADM_FEATURE_LINE_DEGREE));
isAddDrop = Arrays.stream(features).anyMatch(s -> s.equals(MOD_ROADM_FEATURE_FLEX_ADD_DROP));
if (!isLineDegree && !isAddDrop) {
log.error("Device type not recognized, but {} YANG model is present. Reported YANG features: {}", MOD_ROADM_DEVICE, String.join(", ", features));
return noDevice;
}
} else if (data.getString(YANGLIB_KEY_MODULE_NAME).equals(MOD_COHERENT_A_D)) {
if (!revision.equals(MOD_COHERENT_A_D_DATE)) {
log.error("Revision mismatch for YANG module {}: got {}", MOD_COHERENT_A_D, revision);
return noDevice;
}
isCoherentAddDrop = true;
} else if (data.getString(YANGLIB_KEY_MODULE_NAME).equals(MOD_INLINE_AMP)) {
if (!revision.equals(MOD_INLINE_AMP_DATE)) {
log.error("Revision mismatch for YANG module {}: got {}", MOD_INLINE_AMP, revision);
return noDevice;
}
isInlineAmp = true;
}
if (isLineDegree) {
log.info("Talking to a Line/Degree ROADM node");
annotations.set(DEVICE_TYPE_ANNOTATION, DeviceType.LINE_DEGREE.toString());
} else if (isAddDrop) {
log.info("Talking to an Add/Drop ROADM node");
annotations.set(DEVICE_TYPE_ANNOTATION, DeviceType.ADD_DROP_FLEX.toString());
} else if (isCoherentAddDrop) {
log.info("Talking to a Coherent Add/Drop ROADM node");
annotations.set(DEVICE_TYPE_ANNOTATION, DeviceType.COHERENT_ADD_DROP.toString());
} else if (isInlineAmp) {
log.info("Talking to an inline ampifier, not a ROADM, but we will fake it as a ROADM for now");
annotations.set(DEVICE_TYPE_ANNOTATION, DeviceType.INLINE_AMP.toString());
} else {
log.error("Device type not recognized");
return noDevice;
}
} catch (NetconfException e) {
log.error("Cannot request ietf-yang-library data", e);
return noDevice;
}
// FIXME: initialize these
String vendor = "CzechLight";
String hwVersion = "n/a";
String swVersion = "n/a";
String serialNumber = "n/a";
ChassisId chassisId = null;
return new DefaultDeviceDescription(handler().data().deviceId().uri(), Device.Type.ROADM, vendor, hwVersion, swVersion, serialNumber, chassisId, annotations.build());
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class SimpleDeviceStoreTest method putDeviceAncillary.
private void putDeviceAncillary(DeviceId deviceId, String swVersion, SparseAnnotations... annotations) {
DeviceDescription description = new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, HW, swVersion, SN, CID, annotations);
deviceStore.createOrUpdateDevice(PIDA, deviceId, description);
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class DeviceDiscoveryJuniperImpl method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
DeviceId devId = handler().data().deviceId();
NetconfSession session = lookupNetconfSession(devId);
String sysInfo;
String chassisMacAddresses;
try {
sysInfo = session.get(requestBuilder(REQ_SYS_INFO));
chassisMacAddresses = session.get(requestBuilder(REQ_MAC_ADD_INFO));
} catch (NetconfException e) {
log.warn("Failed to retrieve device details for {}", devId);
return null;
}
log.trace("Device {} system-information {}", devId, sysInfo);
DeviceDescription description = JuniperUtils.parseJuniperDescription(devId, loadXmlString(sysInfo), chassisMacAddresses);
log.debug("Device {} description {}", devId, description);
return description;
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class LispDeviceProvider method connectDevice.
/**
* Adds a LISP router into device store.
*/
private void connectDevice(LispRouterId routerId) {
DeviceId deviceId = getDeviceId(routerId.id().toString());
Preconditions.checkNotNull(deviceId, IS_NULL_MSG);
// formulate LISP router object
ChassisId cid = new ChassisId();
String ipAddress = routerId.id().toString();
SparseAnnotations annotations = DefaultAnnotations.builder().set(IPADDRESS, ipAddress).set(AnnotationKeys.PROTOCOL, SCHEME_NAME.toUpperCase()).build();
DeviceDescription deviceDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.ROUTER, MANUFACTURER, HARDWARE_VERSION, SOFTWARE_VERSION, SERIAL_NUMBER, cid, false, annotations);
if (deviceService.getDevice(deviceId) == null) {
providerService.deviceConnected(deviceId, deviceDescription);
}
checkAndUpdateDevice(deviceId, deviceDescription);
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class DeviceManagerTest method connectDevice.
private void connectDevice(DeviceId deviceId, String swVersion) {
DeviceDescription description = new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, HW, swVersion, SN, CID);
providerService.deviceConnected(deviceId, description);
assertNotNull("device should be found", service.getDevice(DID1));
}
Aggregations