Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.tom;
- import com.tailf.jnc.*;
- import java.io.IOException;
- public class Main {
- static void dumpNode(Element e, String pad) {
- Element n = e.getChild("name");
- if (n != null) {
- System.out.println(pad + n.value);
- Element s = e.getChild("section");
- if (s != null) {
- for (Element el2 : s.getChildren()) {
- dumpNode(el2, pad+ "--");
- }
- } else {
- Element v = e.getChild("value");
- if (v != null) {
- System.out.println(pad + "*" + v.value);
- }
- }
- }
- }
- public static void main(String[] args) {
- DeviceUser user = new DeviceUser("nc", "nc", "baracuda");
- Device device = new Device("t", user, "192.168.1.3", 22);
- try {
- device.connect("nc");
- device.newSession("abc");
- NodeSet ns = device.getSession("abc").getConfig(NetconfSession.RUNNING);
- for (Element el : ns) {
- for (Element el2 : el.getChildren()) {
- dumpNode(el2, "");
- }
- }
- System.out.println(ns);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (JNCException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment