use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class NetconfSessionUtility method getNetconfSession.
/**
* Returns the NetconfSession with the device for which the method was called.
*
* @param deviceId device identifier
* @param controller NetconfController
* @return The netconf session or null
*/
public static NetconfSession getNetconfSession(DeviceId deviceId, NetconfController controller) {
log.debug("Inside getNetconfSession () method for device : {}", deviceId);
NetconfDevice ncdev = controller.getDevicesMap().get(deviceId);
if (ncdev == null) {
log.trace("No netconf device, returning null session");
return null;
}
return ncdev.getSession();
}
use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class OpenRoadmNetconfHandlerBehaviour method getNetconfDevice.
/**
* Get the device instance for which the methods apply.
*
* @return The device instance
*/
protected NetconfDevice getNetconfDevice() {
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfDevice ncDevice = controller.getDevicesMap().get(did());
return ncDevice;
}
use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class FujitsuNetconfControllerMock method setUp.
/**
* Sets up initial test environment.
*
* @param listener listener to be added
* @return driver handler
* @throws NetconfException when there is a problem
*/
public FujitsuDriverHandlerAdapter setUp(FujitsuNetconfSessionListenerTest listener) throws NetconfException {
try {
NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo(VOLT_DEVICE_USERNAME, VOLT_DEVICE_PASSWORD, IpAddress.valueOf(VOLT_DEVICE_IP), VOLT_DEVICE_PORT);
NetconfDevice netconfDevice = connectDevice(deviceInfo.getDeviceId());
FujitsuNetconfSessionMock session = (FujitsuNetconfSessionMock) netconfDevice.getSession();
session.setListener(listener);
DeviceId deviceId = deviceInfo.getDeviceId();
DefaultDriver driver = new DefaultDriver(VOLT_DRIVER_NAME, new ArrayList<>(), "Fujitsu", "1.0", "1.0", ImmutableMap.of(), ImmutableMap.of());
DefaultDriverData driverData = new DefaultDriverData(driver, deviceId);
FujitsuDriverHandlerAdapter driverHandler;
driverHandler = new FujitsuDriverHandlerAdapter(driverData);
driverHandler.setUp(this);
return driverHandler;
} catch (NetconfException e) {
throw new NetconfException("Cannot create a device ", e);
}
}
use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class TerminalDevicePowerConfig method getNetconfSession.
/**
* Returns the NetconfSession with the device for which the method was called.
*
* @param deviceId device indetifier
* @param userName username to access the device
* @param passwd password to access the device
* @return The netconf session or null
*/
public NetconfSession getNetconfSession(DeviceId deviceId, String userName, String passwd) {
NetconfController controller = handler().get(NetconfController.class);
NetconfDevice ncdev = controller.getDevicesMap().get(deviceId);
if (ncdev == null) {
log.trace("No netconf device, returning null session");
return null;
}
return ncdev.getSession();
}
use of org.onosproject.netconf.NetconfDevice 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;
}
Aggregations