use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class GossipDeviceStore method handleDeviceEvent.
private void handleDeviceEvent(InternalDeviceEvent event) {
ProviderId providerId = event.providerId();
DeviceId deviceId = event.deviceId();
Timestamped<DeviceDescription> deviceDescription = event.deviceDescription();
try {
notifyDelegateIfNotNull(createOrUpdateDeviceInternal(providerId, deviceId, deviceDescription));
} catch (Exception e) {
log.warn("Exception thrown handling device update", e);
}
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class DeviceDescriptions method putDeviceDesc.
/**
* Puts DeviceDescription, merging annotations as necessary.
*
* @param newDesc new DeviceDescription
*/
public void putDeviceDesc(Timestamped<DeviceDescription> newDesc) {
Timestamped<DeviceDescription> oldOne = deviceDesc;
Timestamped<DeviceDescription> newOne = newDesc;
if (oldOne != null) {
SparseAnnotations merged = union(oldOne.value().annotations(), newDesc.value().annotations());
newOne = new Timestamped<>(new DefaultDeviceDescription(newDesc.value(), merged), newDesc.timestamp());
}
deviceDesc = newOne;
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class GeneralDeviceProvider method getDeviceDescription.
private DeviceDescription getDeviceDescription(DeviceId deviceId, boolean defaultAvailable) {
// Get one from driver or forge.
final DeviceDescriptionDiscovery deviceDiscovery = getBehaviour(deviceId, DeviceDescriptionDiscovery.class);
if (deviceDiscovery == null) {
return forgeDeviceDescription(deviceId, defaultAvailable);
}
final DeviceDescription d = deviceDiscovery.discoverDeviceDetails();
if (d == null) {
return forgeDeviceDescription(deviceId, defaultAvailable);
}
// Enforce defaultAvailable flag over the one obtained from driver.
return new DefaultDeviceDescription(d, defaultAvailable, d.annotations());
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class OpenRoadmDeviceDescription method discoverDeviceDetails.
/**
* Returns a DeviceDescription with Device info.
*
* @return DeviceDescription or null
*/
@Override
public DeviceDescription discoverDeviceDetails() {
boolean defaultAvailable = true;
NetconfDevice ncDevice = getNetconfDevice();
if (ncDevice == null) {
log.error("ONOS Error: Device reachable, deviceID {} is not in Map", did());
return null;
}
DefaultAnnotations.Builder annotationsBuilder = DefaultAnnotations.builder();
// Some defaults
String vendor = "UNKNOWN";
String hwVersion = "2.2.0";
String swVersion = "2.2.0";
String serialNumber = "0x0000";
String chassisId = "0";
String nodeType = "rdm";
// Get the session, if null, at least we can use the defaults.
NetconfSession session = getNetconfSession(did());
if (session != null) {
try {
String reply = session.rpc(getDeviceDetailsBuilder()).get();
XMLConfiguration xconf = (XMLConfiguration) XmlConfigParser.loadXmlString(reply);
String nodeId = xconf.getString("data.org-openroadm-device.info.node-id", "");
if (nodeId.equals("")) {
log.error("[OPENROADM] {} org-openroadm-device node-id undefined, returning", did());
return null;
}
annotationsBuilder.set(AnnotationKeys.OPENROADM_NODEID, nodeId);
nodeType = xconf.getString("data.org-openroadm-device.info.node-type", "");
if (nodeType.equals("")) {
log.error("[OPENROADM] {} empty node-type", did());
return null;
}
vendor = xconf.getString("data.org-openroadm-device.info.vendor", vendor);
hwVersion = xconf.getString("data.org-openroadm-device.info.model", hwVersion);
swVersion = xconf.getString("data.org-openroadm-device.info.softwareVersion", swVersion);
serialNumber = xconf.getString("data.org-openroadm-device.info.serial-id", serialNumber);
chassisId = xconf.getString("data.org-openroadm-device.info.node-number", chassisId);
// GEOLOCATION
String longitudeStr = xconf.getString("data.org-openroadm-device.info.geoLocation.longitude");
String latitudeStr = xconf.getString("data.org-openroadm-device.info.geoLocation.latitude");
if (longitudeStr != null && latitudeStr != null) {
annotationsBuilder.set(org.onosproject.net.AnnotationKeys.LONGITUDE, longitudeStr).set(org.onosproject.net.AnnotationKeys.LATITUDE, latitudeStr);
}
} catch (NetconfException | InterruptedException | ExecutionException e) {
log.error("[OPENROADM] {} exception", did());
return null;
}
} else {
log.debug("[OPENROADM] - No session {}", did());
}
log.debug("[OPENROADM] {} - VENDOR {} HWVERSION {} SWVERSION {} SERIAL {} CHASSIS {}", did(), vendor, hwVersion, swVersion, serialNumber, chassisId);
ChassisId cid = new ChassisId(Long.valueOf(chassisId, 10));
/*
* OpenROADM defines multiple devices (node types). This driver has been tested with
* ROADMS, (node type, "rdm"). Other devices can also be discovered, and this code is here
* for future developments - untested - it is likely that the XML documents
* are model specific.
*/
org.onosproject.net.Device.Type type;
if (nodeType.equals("rdm")) {
type = org.onosproject.net.Device.Type.ROADM;
} else if (nodeType.equals("ila")) {
type = org.onosproject.net.Device.Type.OPTICAL_AMPLIFIER;
} else if (nodeType.equals("xpdr")) {
type = org.onosproject.net.Device.Type.TERMINAL_DEVICE;
} else if (nodeType.equals("extplug")) {
type = org.onosproject.net.Device.Type.OTHER;
} else {
log.error("[OPENROADM] {} unsupported node-type", did());
return null;
}
DeviceDescription desc = new DefaultDeviceDescription(did().uri(), type, vendor, hwVersion, swVersion, serialNumber, cid, defaultAvailable, annotationsBuilder.build());
return desc;
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class Tl1DeviceProvider method connectDevice.
// Register a device in the core and in the TL1 controller.
private void connectDevice(Tl1Device device) {
try {
// Add device to TL1 controller
DeviceId deviceId = DeviceId.deviceId(new URI(Tl1DeviceConfig.TL1, device.ip() + ":" + device.port(), null));
if (controller.addDevice(deviceId, device)) {
SparseAnnotations ann = DefaultAnnotations.builder().set(AnnotationKeys.PROTOCOL, Tl1DeviceConfig.TL1.toUpperCase()).build();
// Register device in the core with default parameters and mark it as unavailable
DeviceDescription dd = new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), false, ann);
providerService.deviceConnected(deviceId, dd);
}
} catch (URISyntaxException e) {
log.error("Skipping device {}", device, e);
}
}
Aggregations