use of org.onosproject.netconf.NetconfSession 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.netconf.NetconfSession in project onos by opennetworkinglab.
the class ZteDeviceDiscoveryImpl method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
DeviceId deviceId = handler().data().deviceId();
log.info("Discovering ZTE device {}", deviceId);
NetconfController controller = handler().get(NetconfController.class);
NetconfSession session = controller.getDevicesMap().get(deviceId).getSession();
String hwVersion = "ZTE hw";
String swVersion = "ZTE sw";
String serialNumber = "000000000000";
try {
String reply = session.requestSync(buildDeviceInfoRequest());
XMLConfiguration cfg = (XMLConfiguration) XmlConfigParser.loadXmlString(getDataOfRpcReply(reply));
hwVersion = cfg.getString("components.component.state.hardware-version");
swVersion = cfg.getString("components.component.state.software-version");
serialNumber = cfg.getString("components.component.state.serial-no");
} catch (NetconfException e) {
log.error("ZTE device discovery error.", e);
}
return new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTN, "ZTE", hwVersion, swVersion, serialNumber, new ChassisId(1));
}
use of org.onosproject.netconf.NetconfSession in project onos by opennetworkinglab.
the class ZtePortStatisticsDiscovery method discoverPortStatistics.
@Override
public Collection<PortStatistics> discoverPortStatistics() {
DeviceId deviceId = handler().data().deviceId();
LOG.debug("Discovering ZTE PortStatistics for device {}", deviceId);
NetconfController controller = handler().get(NetconfController.class);
if (null == controller) {
LOG.error("Cannot find NetconfController");
return null;
}
NetconfSession session = controller.getDevicesMap().get(deviceId).getSession();
if (null == session) {
LOG.error("No session available for device {}", deviceId);
return null;
}
DeviceService deviceService = this.handler().get(DeviceService.class);
List<Port> ports = deviceService.getPorts(deviceId);
Collection<PortStatistics> portStatistics = Lists.newArrayList();
ports.stream().filter(Port::isEnabled).filter(this::isClientPort).forEach(port -> portStatistics.add(discoverSpecifiedPortStatistics(session, deviceId, port)));
return portStatistics;
}
use of org.onosproject.netconf.NetconfSession in project onos by opennetworkinglab.
the class NetconfSessionMinaImpl method startSubscriptionStream.
@Beta
protected void startSubscriptionStream(String filterSchema) throws NetconfException {
boolean openNewSession = false;
if (!deviceCapabilities.contains(INTERLEAVE_CAPABILITY_STRING)) {
log.info("Device {} doesn't support interleave, creating child session", deviceInfo);
openNewSession = true;
} else if (subscriptionConnected && notificationFilterSchema != null && !Objects.equal(filterSchema, notificationFilterSchema)) {
// interleave supported and existing filter is NOT "no filtering"
// and was requested with different filtering schema
log.info("Cannot use existing session for subscription {} ({})", deviceInfo, filterSchema);
openNewSession = true;
}
if (openNewSession) {
log.info("Creating notification session to {} with filter {}", deviceInfo, filterSchema);
NetconfSession child = new NotificationSession(deviceInfo);
child.addDeviceOutputListener(new NotificationForwarder());
child.startSubscription(filterSchema);
children.add(child);
return;
}
// request to start interleaved notification session
String reply = sendRequest(createSubscriptionString(filterSchema));
if (!checkReply(reply)) {
throw new NetconfException("Subscription not successful with device " + deviceInfo + " with reply " + reply);
}
subscriptionConnected = true;
}
use of org.onosproject.netconf.NetconfSession in project onos by opennetworkinglab.
the class CienaWaveserverAiDeviceDescription method discoverPortDetails.
@Override
public List<PortDescription> discoverPortDetails() {
log.info("Adding ports for Waveserver Ai device");
List<PortDescription> ports = new ArrayList<>();
Device device = getDevice(handler().data().deviceId());
NetconfSession session = getNetconfSession();
try {
XPath xp = XPathFactory.newInstance().newXPath();
Node nodeListItem;
Node node = TEMPLATE_MANAGER.doRequest(session, "discoverPortDetails");
NodeList nodeList = (NodeList) xp.evaluate("waveserver-ports/ports", node, XPathConstants.NODESET);
int count = nodeList.getLength();
for (int i = 0; i < count; ++i) {
nodeListItem = nodeList.item(i);
DefaultAnnotations annotationPort = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, xp.evaluate("port-id/text()", nodeListItem)).set(AnnotationKeys.PROTOCOL, xp.evaluate("id/type/text()", nodeListItem)).build();
String port = xp.evaluate("port-id/text()", nodeListItem);
ports.add(DefaultPortDescription.builder().withPortNumber(PortNumber.portNumber(portIdConvert(port), port)).isEnabled(portStateConvert(xp.evaluate("state/operational-state/text()", nodeListItem))).portSpeed(portSpeedToLong(xp.evaluate("id/speed/text()", nodeListItem))).type(Port.Type.PACKET).annotations(annotationPort).build());
}
} catch (NetconfException | XPathExpressionException e) {
log.error("Unable to retrieve port information for device {}, {}", device.chassisId(), e);
}
return ImmutableList.copyOf(ports);
}
Aggregations