Git Product home page Git Product logo

tail-f-systems / jnc Goto Github PK

View Code? Open in Web Editor NEW
74.0 31.0 85.0 10.15 MB

JNC (Java NETCONF Client) is the name of a Java library for communicating with NETCONF agents, and a plugin for pyang (http://code.google.com/p/pyang/) to generate Java classes from YANG models, to be used by the JNC library.

License: Other

Makefile 1.58% Java 79.69% Python 17.14% HTML 0.11% Groovy 0.21% Awk 0.02% C 1.24%

jnc's Introduction

JNC

Java NETCONF Client.

Overview

JNC (Java NETCONF Client) consists of two parts:

  • Java library for NETCONF client (JNC library)
  • pyang plugin for Java class hierarchies generation.

Together with the JNC library, these generated Java classes may be used as the foundation for a NETCONF client (AKA manager) written in Java.

JNC's Java library code uses SSHJ to communicate with NETCONF servers/agents.

Getting started

Typical use-case of JNC consists of three "standalone" areas - Java library for NETCONF clients, pyang plugin for YANG hierarchy class generation, and finally complete Java application connecting everything into combined client application.

JNC Java library

JNC's Java library uses Gradle as its build system.

If your gradle is outdated or is not installed at all, you can use Gradle Wrapper. To use Gradle Wrapper you replace gradle command with ./gradlew in the following steps/commands to be executed. Wrapper automatically downloads & caches the correct Gradle version, and uses it to invoke Gradle commands.

You build the JNC Java library with following command:

gradle build

resp.

gradlew build

when using the wrapper...

This will download dependencies (if needed), build JNC library, run tests and create corresponding JAR files (library, Javadoc and sources) in the build/libs directory.

Alternative to building the JNC library locally is to utilize online Maven based repository. See codebase of JNC examples/ for details on the inclusion of Java lib for building your NETCONF client application.

Installing JNC Pyang plugin

The easiest way to use the pyang plugin is to install it into your environment using pip (or pip3) like pip install pyang-jnc. This makes sure that pyang is installed too and that jnc is registered as a Pyang plugin.

Another option is to use the plugin source that is part of this repository. For that, you need an installation of pyang - get it here or use pip3 install pyang. Then, add the JNC plugin to your existing pyang installation. This may be done in one of the following three ways:

  1. Add jnc.py to pyang/plugins in your pyang installation directory,
  2. Add the location of jnc.py to the $PYANG_PLUGINPATH environment variable, or
  3. Use the --plugindir option of pyang each time you want to use JNC

Note! If more than one of these approaches is used, you will end up with optparse library conflicts, so please choose one and stick with it. From here on, we will assume that you went for (1), but using (2) or (3) should be analogous.

Generating Java classes

JNC plugin can be used to generate Java classes from a YANG file of your choice.

There is a collection of yang files in the examples/yang directory.

To generate classes for a YANG file, open a terminal, change directory to where you want the classes to be generated, launch pyang with the "jnc" format, specifying the output folder and the yang model file.

For example, to generate the classes for simple.yang file included in our examples directory with base package name gen.simple, type:

 $ pyang -f jnc --jnc-output src/gen/simple yang/simple.yang

There should now be a newly generated "src" folder in the current directory, containing a directory structure with the generated classes. Note that "src" is special treated so that it does not become part of the package names of the generated classes.

To get more detailed information on how the generation proceeds the --jnc-debug or --jnc-verbose options can be used. Re-running JNC silently overwrites any old classes in the output directory.

JNC Java application

To actually use the generated classes, you need to compile Java client code with the JNC library (JAR file). The examples of JNC application can be found in the examples directory.

Gradle is used to build application. It also shows how to use JNC pyang plugin with Gradle task.

See the example's README file for details.

pyang generated files - high level description

There are different types of filed generated by pyang plugin:

Class name Description
Root class This class has the name of the prefix of the YANG module, and contains fields with the prefix and namespace as well as methods that enables the JNC library to use the other generated classes when interacting with a NETCONF server.
YangElement Each YangElement corresponds to a container or a list in the YANG model.
They represent tree nodes of a configuration and provides methods to modify the configuration in accordance with the YANG model that they were generated from.
The top-level containers or lists in the YANG model will have their corresponding YangElement classes generated in the output directory together with the root class.
Their respective sub-containers and sub-lists are generated in sub-packages with names corresponding to the name of the parent container or list.
YangTypes For each derived type in the YANG model, a class is generated to the root of the output directory. The derived type may either extend another derived type class, or the JNC type class corresponding to a built-in YANG type.
PackageInfo For each package in the generated Java class hierarchy, a package-info.java file is generated, which can be useful when generating Javadoc for the hierarchy.
Schema file If enabled, an XML file containing structured information about the generated Java classes is generated. It contains tag-paths, namespace, primitive-type and other useful meta-information.

The typical use case for these classes is as part of a JAVA network management system, to enable retrieval and/or storing of configurations on NETCONF agents/servers with specific capabilities.

License

Copyright 2012-2022 Tail-f Systems AB

See License File.

jnc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jnc's Issues

How to delete XPATH capabilities from JNC hello message

We are using JNC along with Ganymed to communicate with HP 5900 switches which does not support XPATH. HPN support is asking us to delete the XPATH capability form client hello message.
5900 server capabilities -


urn:ietf:params:netconf:base:1.0
urn:ietf:params:netconf:capability:writable-running:1.0
urn:ietf:params:netconf:capability:notification:1.0
urn:ietf:params:netconf:capability:validate:1.0
urn:ietf:params:netconf:capability:interleave:1.0
urn:ietf:params:netconf:capability:rollback-on-error:1.0
urn:hp:params:netconf:capability:hp-netconf-ext:1.0
urn:hp:params:netconf:capability:hp-save-point::1.0

We are newbies for JNC and don't know how JNC is sending hello message to server and how to remove XPATH capabilities from hello message? Ideally, they should auto - negotiate hello messages :(

Any help would be great for us to move forward and better understanding. Also, looks like, all JNC examples are heavily dependent on XPATH.

Issue with Cisco Routers

Hello,
I'm using your library to develop a NetConf client. The code is working fine with Juniper routers, but I' facing issue with cisco routers.

# Stack trace is as follows:
Exception in thread "main" java.io.IOException: Session closed
at com.tailf.jnc.SSHSession.readOne(Unknown Source)
at com.tailf.jnc.NetconfSession.recv_rpc_reply(Unknown Source)
at com.tailf.jnc.NetconfSession.recv_rpc_reply_data(Unknown Source)
at com.tailf.jnc.NetconfSession.getConfig(Unknown Source)
at netconf.Netconf.getConfig(Netconf.java:76)
at netconf.Netconf.getConfig(Netconf.java:82)
at netconf.Netconf.main(Netconf.java:112)

# My code:
`package netconf;

import java.io.IOException;

import com.tailf.jnc.Device;
import com.tailf.jnc.DeviceUser;
import com.tailf.jnc.Element;
import com.tailf.jnc.JNCException;
import com.tailf.jnc.NetconfSession;
import com.tailf.jnc.NodeSet;

public class Netconf {

public Netconf(){
    init();		
}

private Device dev;
private DeviceUser duser;


private void init() {
	
	String localUsername = "root";
    String remoteUsername = "root";
    String password="barc123";
    duser = new DeviceUser(localUsername, remoteUsername, password);
    dev = new Device("mydevicename", duser, "10.21.34.243", 22);

    try {
        dev.connect(localUsername);
        dev.newSession("cfg");
    } catch (IOException e0) {
        System.err.println("Can't connect"+e0);
        System.exit(1);
    } catch (JNCException e1) {
        System.err.println("Can't authenticate" + e1);
        System.exit(1);
    }
}
    



void getDetails(NodeSet configs,int level){
	for (Element elem : configs) {
		
		if(elem.hasChildren()){
			for(int i=level;i>0;i--)
				System.out.print("\t");
			System.out.println("<"+elem.name+">");
        	NodeSet child = elem.getChildren();
        	
        	getDetails(child, level+1);
		}    		
		for(int i=level;i>0;i--)
			System.out.print("\t");
		try{    				
    		if(!elem.hasChildren())
    			System.out.println("<"+elem.name+">"+elem.value.toString().trim()+"</"+elem.name+">");
    		else
    			System.out.println("</"+elem.name+">");
		}
		catch(NullPointerException e){
			System.out.println(e);
		}
	}
}


private NodeSet getConfig(Device d) throws IOException, JNCException{
    NetconfSession session = d.getSession("cfg");
    NodeSet reply = session.getConfig(NetconfSession.RUNNING);
    return reply;
}

public NodeSet getConfig() throws IOException,JNCException{
    return getConfig(dev);
}


public static Element getConfig(NodeSet configs, String name) {
    Element config = configs.first();
    if (!config.name.equals(name)) {
        config = null;
        for (Element elem : configs) {
            if (elem.name.equals(name)) {
                config = elem;
            }
        }
    }
    return config;
}





public static void main(String[] args) throws IOException, JNCException {
	
	Netconf client = new Netconf();
    NodeSet configs = client.getConfig();              
    
          
    for (Element elem : configs) {       	
    	NodeSet child = elem.getChildren();
		System.out.println("<"+elem.name+" xmlns=\""+elem.namespace+"\" xmlns:nc=\""+ Element.NETCONF_NAMESPACE+"\"> ");
    	client.getDetails(child,1);
		System.out.println("</"+elem.name+">");
    }             
    client.dev.close();

}

}
`

Thanx,
Surya Pratap.

pyang issue with ietf-netconf-acm

There seems to be problem with using jnc.py against ieft-netconf-acm.yang. See below.

damianoneill 3-bti]$ export PYANG_PLUGINPATH=../../; ant
Buildfile: /Users/damianoneill/Downloads/JNC-master/examples/3-bti/build.xml

generate:
[exec] <jnc.JNCPlugin object at 0x10e341790>
[exec] ietf-netconf-acm contains errors

BUILD FAILED
/Users/damianoneill/Downloads/JNC-master/examples/3-bti/build.xml:21: exec returned: 1

Total time: 1 second
[damianoneill 3-bti]$

Emil I will send you a zip with the build including what I am trying to compile up, which includes more than this standard yang file.

YangEnumerationTest failing

    try {
        one = new YangEnumeration("hej", null);
        fail("Expected YangException");
    } catch (YangException e) {
        assertTrue(e.opaqueData instanceof NullPointerException);
    }

will not fail as value is "hej"

See from YangEnumeration

if (value.isEmpty()) {
YangException.throwException(true, "empty string in enum value");
}

Self closing tags should be use for empty-element tag

The OpenYuma Netconf server implementation replies rpc-ok instead of rpc-error if the request contains start/end tag for empty tag and not a self closing tag. And that is a huge problem!
My actual problem:
Request:
<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:message-id="1"><cancel-toast xmlns="http://netconfcentral.org/ns/toaster"></cancel-toast>
</nc:rpc>]]>]]>
Reply:
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>]]>]]>

And the good formats in a C imlementation:
Request:
<?xml version="1.0" encoding="UTF-8"?>
<rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<cancel-toast xmlns="http://netconfcentral.org/ns/toaster"/>
</rpc>

Reply:
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:ncx="http://netconfcentral.org/ns/yuma-ncx" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<rpc-error>
<error-type>protocol</error-type>
<error-tag>operation-failed</error-tag>
<error-severity>error</error-severity>
<error-app-tag>general-error</error-app-tag>
<error-message xml:lang="en">operation failed</error-message>
<error-info>
<error-number xmlns="http://netconfcentral.org/ns/yuma-ncx">274</error-number>
</error-info>
</rpc-error>
</rpc-reply>]]>]]>

According to this document: https://tools.ietf.org/html/rfc6241#section-4.1 the self-closing tags woud be the appropriate and expected behavior.

SNMP Yang fails generation

The Yang included in ConfD as for SNMP Target Mib produces code which cannot be compiled due to conflicting class names and package names.

When adding SNMP-TARGET-MIB.yang, and required dependencies, the resultant package and class names clash causing the code to not compile.

Clean Build

On a clean build the ant command fails.

classes.dir doesn't exist on clean checkout, so you get

BUILD FAILED
/Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/jnc/build.xml:10: Directory does not exist: /Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/jnc/bin

You should either refactor target or set failonerror on the delete task to false.

Increase timeout on NetconfSession

I'm creating a netconf session in the following way:

    final DeviceUser user = new DeviceUser(netconfConfiguration.getUsername(), netconfConfiguration.getUsername(), netconfConfiguration.getPassword());
    final Device netconfDevice = new Device(ipAddress, user, ipAddress, netconfConfiguration.getPort());

    netconfDevice.connect(netconfConfiguration.getUsername());
    netconfDevice.newSession(new LoggingIOSubscriber(sessionName), sessionName);
    return netconfDevice.getSession(sessionName);

...but am sometimes getting connection timeouts:

java.io.IOException: There was a problem while connecting to :2022
at ch.ethz.ssh2.Connection.connect(Connection.java:753)
at com.tailf.jnc.SSHConnection.(SSHConnection.java:59)
at com.tailf.jnc.Device.connect(Device.java:372)
at com.tailf.jnc.Device.connect(Device.java:348)

Could you provide the best way to create a NetconfSession similar to above where the timeout can be increased? What's the default value for this?

Thanks

loading schemas

Schema files are references by path eg: parser.readFile("src/gen/atlas/Atl.schema", h);

We will be jar-ing up the generated code so the file path isn't an option for loading the schemas.

A classpath based lookup would be preferable here.

Not able to perform getConfig()

Hi
We have a netconf enabled router and I am able to perform get/get-config operations using Mg-Soft client browser. This is the output of getConfig() -

REQ:

<nc:get-config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
  <nc:source>
    <nc:running/>
  </nc:source>
</nc:get-config>

RESP:

<?xml version="1.0" encoding="utf-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf">
    <qos>
      <sap-ingress>
      .....
</data>

But I am unable to perform the same operation using tailf Netconf client.
Here is my code -

public class Client {
    public static void main(String args[]) throws JNCException, 
            ParserConfigurationException, SAXException, IOException {

        DeviceUser deviceUser;
        String deviceUserName = "user";
        deviceUser = new DeviceUser(deviceUserName, "admin", "admin");
        Device device = new Device("simulator", deviceUser, "10.135.16.13", 830);
        device.connect(deviceUserName);
        device.newSession(new Subscriber("simulator"), "mySession");
        NetconfSession session = device.getSession("mySession");

        NodeSet config = session.getConfig(NetconfSession.RUNNING);
        String xmlString = config.toXMLString();
        session.closeSession();
        System.out.println(xmlString);
    }
}

class Subscriber extends IOSubscriber {
    String devName;
    public static boolean rawMode = false;
    Subscriber(String devName) {
        super(rawMode);
        this.devName = devName;
    }
    public void input(String data) {
        System.out.println("RECV: " + data);
    }

    public void output(String data) {
        System.out.println("SEND: " + data);
    }
}

I am getting the following in the eclipse console -

SEND: <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <capabilities>
    <capability>urn:ietf:params:netconf:base:1.0</capability>
  </capabilities>
</hello>

RECV: <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <capabilities>
    <capability>urn:ietf:params:netconf:base:1.0</capability>
    <capability>urn:ietf:params:netconf:base:1.1</capability>
    <capability>urn:ietf:params:netconf:capability:writable-running:1.0</capability>
    <capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>
    <capability>urn:ietf:params:netconf:capability:validate:1.0</capability>
    <capability>urn:ietf:params:netconf:capability:validate:1.1</capability>
    <capability>urn:ietf:params:netconf:capability:startup:1.0</capability>
    <capability>urn:ietf:params:netconf:capability:url:1.0?scheme=ftp,tftp,file</capability>
    <capability>urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=trim&amp;also-supported=report-all</capability>
    <capability>urn:ietf:params:xml:ns:netconf:base:1.0?module=ietf-netconf&amp;revision=2011-06-01&amp;features=writable-running,validate,startup,url&amp;deviations=alu-netconf-deviations-r13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:netconf-deviations-r13?module=alu-netconf-deviations-r13&amp;revision=2015-01-23</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:cli-content-layer-r13?module=alu-cli-content-layer-r13&amp;revision=2015-01-23</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-r13?module=alu-conf-r13&amp;revision=2016-06-24</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-aaa-r13?module=alu-conf-aaa-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-aa-r13?module=alu-conf-aa-r13&amp;revision=2016-06-23</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-calltrace-r13?module=alu-conf-calltrace-r13&amp;revision=2016-04-27</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-card-r13?module=alu-conf-card-r13&amp;revision=2015-10-30</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-cflowd-r13?module=alu-conf-cflowd-r13&amp;revision=2015-01-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-conn-prof-r13?module=alu-conf-conn-prof-r13&amp;revision=2015-11-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-con-profvlan-r13?module=alu-conf-con-profvlan-r13&amp;revision=2015-08-28</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-eth-cfm-r13?module=alu-conf-eth-cfm-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-eth-ring-r13?module=alu-conf-eth-ring-r13&amp;revision=2014-10-17</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-eth-tunnel-r13?module=alu-conf-eth-tunnel-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-filter-r13?module=alu-conf-filter-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-gmpls-tunnel-r13?module=alu-conf-gmpls-tunnel-r13&amp;revision=2014-12-09</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-ifgrphandler-r13?module=alu-conf-ifgrphandler-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-isa-r13?module=alu-conf-isa-r13&amp;revision=2016-02-29</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-lag-r13?module=alu-conf-lag-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-li-r13?module=alu-conf-li-r13&amp;revision=2016-04-21</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-log-r13?module=alu-conf-log-r13&amp;revision=2016-06-01</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-mcastmgmt-r13?module=alu-conf-mcastmgmt-r13&amp;revision=2015-03-12</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-mirror-r13?module=alu-conf-mirror-r13&amp;revision=2016-01-08</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-oam-pm-r13?module=alu-conf-oam-pm-r13&amp;revision=2015-11-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-open-flow-r13?module=alu-conf-open-flow-r13&amp;revision=2015-11-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-r13?module=alu-conf-port-r13&amp;revision=2015-08-27</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-access-r13?module=alu-conf-port-access-r13&amp;revision=2014-10-31</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-aps-r13?module=alu-conf-port-aps-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-ethernet-r13?module=alu-conf-port-ethernet-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-mbundle-r13?module=alu-conf-port-mbundle-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-network-r13?module=alu-conf-port-network-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-sonetsdh-r13?module=alu-conf-port-sonetsdh-r13&amp;revision=2015-06-11</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-r13?module=alu-conf-port-tdm-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-ds1-r13?module=alu-conf-port-tdm-ds1-r13&amp;revision=2014-12-15</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-ds3-r13?module=alu-conf-port-tdm-ds3-r13&amp;revision=2014-12-15</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-e1-r13?module=alu-conf-port-tdm-e1-r13&amp;revision=2014-12-15</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-e3-r13?module=alu-conf-port-tdm-e3-r13&amp;revision=2014-12-15</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-policy-r13?module=alu-conf-port-policy-r13&amp;revision=2015-12-09</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-pxc-r13?module=alu-conf-pxc-r13&amp;revision=2015-04-24</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-python-r13?module=alu-conf-python-r13&amp;revision=2016-06-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-qos-r13?module=alu-conf-qos-r13&amp;revision=2016-04-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-redundancy-r13?module=alu-conf-redundancy-r13&amp;revision=2016-03-25</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-r13?module=alu-conf-router-r13&amp;revision=2016-05-09</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-bgp-r13?module=alu-conf-router-bgp-r13&amp;revision=2016-06-06</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-dhcps-r13?module=alu-conf-router-dhcps-r13&amp;revision=2015-09-21</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-dhcp6-r13?module=alu-conf-router-dhcp6-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-fspec-r13?module=alu-conf-router-fspec-r13&amp;revision=2015-12-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-gmpls-r13?module=alu-conf-router-gmpls-r13&amp;revision=2015-11-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-igmp-r13?module=alu-conf-router-igmp-r13&amp;revision=2015-11-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-if-r13?module=alu-conf-router-if-r13&amp;revision=2016-04-29</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-isis-r13?module=alu-conf-router-isis-r13&amp;revision=2016-02-18</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-l2tp-r13?module=alu-conf-router-l2tp-r13&amp;revision=2016-05-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-ldp-r13?module=alu-conf-router-ldp-r13&amp;revision=2016-05-02</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-lmp-r13?module=alu-conf-router-lmp-r13&amp;revision=2015-09-08</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-mccacpl-r13?module=alu-conf-router-mccacpl-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-mld-r13?module=alu-conf-router-mld-r13&amp;revision=2015-09-22</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-mpls-r13?module=alu-conf-router-mpls-r13&amp;revision=2016-04-28</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-mpls-tp-r13?module=alu-conf-router-mpls-tp-r13&amp;revision=2015-11-09</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-nat-r13?module=alu-conf-router-nat-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-ogvalid-r13?module=alu-conf-router-ogvalid-r13&amp;revision=2015-11-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-ospf-r13?module=alu-conf-router-ospf-r13&amp;revision=2016-06-22</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-ospf3-r13?module=alu-conf-router-ospf3-r13&amp;revision=2016-06-22</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-pcep-r13?module=alu-conf-router-pcep-r13&amp;revision=2016-03-07</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-pim-r13?module=alu-conf-router-pim-r13&amp;revision=2016-06-07</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-policy-r13?module=alu-conf-router-policy-r13&amp;revision=2016-05-19</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-radprox-r13?module=alu-conf-router-radprox-r13&amp;revision=2015-11-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-rip-r13?module=alu-conf-router-rip-r13&amp;revision=2015-06-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-nhroute-r13?module=alu-conf-router-nhroute-r13&amp;revision=2014-09-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-radvert-r13?module=alu-conf-router-radvert-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-rsvp-r13?module=alu-conf-router-rsvp-r13&amp;revision=2015-06-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-wlan-r13?module=alu-conf-router-wlan-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-wpp-r13?module=alu-conf-router-wpp-r13&amp;revision=2015-03-04</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-saa-r13?module=alu-conf-saa-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-service-r13?module=alu-conf-service-r13&amp;revision=2016-03-23</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-apipe-r13?module=alu-conf-svc-apipe-r13&amp;revision=2016-02-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-cpipe-r13?module=alu-conf-svc-cpipe-r13&amp;revision=2016-02-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-cust-r13?module=alu-conf-svc-cust-r13&amp;revision=2015-09-23</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-dynsrv-r13?module=alu-conf-svc-dynsrv-r13&amp;revision=2015-09-11</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-egrmcgroup-r13?module=alu-conf-svc-egrmcgroup-r13&amp;revision=2015-09-11</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-epipe-r13?module=alu-conf-svc-epipe-r13&amp;revision=2016-06-27</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-fpipe-r13?module=alu-conf-svc-fpipe-r13&amp;revision=2016-02-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ies-r13?module=alu-conf-svc-ies-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ies-if-r13?module=alu-conf-svc-ies-if-r13&amp;revision=2016-06-27</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ies-subif-r13?module=alu-conf-svc-ies-subif-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ipfix-r13?module=alu-conf-svc-ipfix-r13&amp;revision=2014-09-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ipipe-r13?module=alu-conf-svc-ipipe-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-nat-r13?module=alu-conf-svc-nat-r13&amp;revision=2016-04-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-sdp-r13?module=alu-conf-svc-sdp-r13&amp;revision=2016-05-09</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-template-r13?module=alu-conf-svc-template-r13&amp;revision=2016-04-06</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-upnp-r13?module=alu-conf-svc-upnp-r13&amp;revision=2015-09-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-r13?module=alu-conf-svc-vpls-r13&amp;revision=2016-06-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-igmp-r13?module=alu-conf-svc-vpls-igmp-r13&amp;revision=2014-09-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-macmo-r13?module=alu-conf-svc-vpls-macmo-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-macpr-r13?module=alu-conf-svc-vpls-macpr-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-meshs-r13?module=alu-conf-svc-vpls-meshs-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-mld-r13?module=alu-conf-svc-vpls-mld-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-pim-r13?module=alu-conf-svc-vpls-pim-r13&amp;revision=2015-07-07</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-sap-r13?module=alu-conf-svc-vpls-sap-r13&amp;revision=2016-06-27</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-split-r13?module=alu-conf-svc-vpls-split-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-spoke-r13?module=alu-conf-svc-vpls-spoke-r13&amp;revision=2016-06-13</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-spb-r13?module=alu-conf-svc-vpls-spb-r13&amp;revision=2016-02-04</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-stp-r13?module=alu-conf-svc-vpls-stp-r13&amp;revision=2014-09-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-r13?module=alu-conf-svc-vprn-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-bgp-r13?module=alu-conf-svc-vprn-bgp-r13&amp;revision=2016-05-04</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-dhcps-r13?module=alu-conf-svc-vprn-dhcps-r13&amp;revision=2015-09-21</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-dhcp6-r13?module=alu-conf-svc-vprn-dhcp6-r13&amp;revision=2016-06-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-fspec-r13?module=alu-conf-svc-vprn-fspec-r13&amp;revision=2016-02-11</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-igmp-r13?module=alu-conf-svc-vprn-igmp-r13&amp;revision=2015-11-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-if-r13?module=alu-conf-svc-vprn-if-r13&amp;revision=2016-06-27</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-isis-r13?module=alu-conf-svc-vprn-isis-r13&amp;revision=2016-02-18</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-l2tp-r13?module=alu-conf-svc-vprn-l2tp-r13&amp;revision=2016-05-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-mld-r13?module=alu-conf-svc-vprn-mld-r13&amp;revision=2015-10-14</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-nat-r13?module=alu-conf-svc-vprn-nat-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-nwif-r13?module=alu-conf-svc-vprn-nwif-r13&amp;revision=2016-04-29</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svs-vprn-ntp-r13?module=alu-conf-svs-vprn-ntp-r13&amp;revision=2015-05-05</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-ospf-r13?module=alu-conf-svc-vprn-ospf-r13&amp;revision=2016-06-22</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-ospf3-r13?module=alu-conf-svc-vprn-ospf3-r13&amp;revision=2016-06-22</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-pim-r13?module=alu-conf-svc-vprn-pim-r13&amp;revision=2015-08-17</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-ptp-r13?module=alu-conf-svc-vprn-ptp-r13&amp;revision=2015-05-22</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-vprn-radprox-r13?module=alu-conf-vprn-radprox-r13&amp;revision=2015-06-23</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-rip-r13?module=alu-conf-svc-vprn-rip-r13&amp;revision=2015-06-03</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-ripng-r13?module=alu-conf-svc-vprn-ripng-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-radv-r13?module=alu-conf-svc-vprn-radv-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-srcad-r13?module=alu-conf-svc-vprn-srcad-r13&amp;revision=2015-01-27</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-spoke-r13?module=alu-conf-svc-vprn-spoke-r13&amp;revision=2015-12-17</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-subif-r13?module=alu-conf-svc-vprn-subif-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-wlan-r13?module=alu-conf-svc-vprn-wlan-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-wpp-r13?module=alu-conf-svc-vprn-wpp-r13&amp;revision=2015-03-04</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sflow-r13?module=alu-conf-sflow-r13&amp;revision=2014-09-26</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sfm-r13?module=alu-conf-sfm-r13&amp;revision=2014-10-20</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-subscrmgmt-r13?module=alu-conf-subscrmgmt-r13&amp;revision=2016-06-27</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-submgmt-ludb-r13?module=alu-conf-submgmt-ludb-r13&amp;revision=2016-06-14</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-submgmt-wlangw-r13?module=alu-conf-submgmt-wlangw-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-system-r13?module=alu-conf-system-r13&amp;revision=2016-06-08</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sys-pwrmgmt-r13?module=alu-conf-sys-pwrmgmt-r13&amp;revision=2015-05-25</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sys-ptp-r13?module=alu-conf-sys-ptp-r13&amp;revision=2015-06-25</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sys-sec-r13?module=alu-conf-sys-sec-r13&amp;revision=2016-06-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-vrrp-r13?module=alu-conf-vrrp-r13&amp;revision=2015-10-14</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:conf-vsm-r13?module=alu-conf-vsm-r13&amp;revision=2015-09-16</capability>
    <capability>urn:alcatel-lucent.com:sros:ns:yang:types?module=alu-types&amp;revision=2015-01-19</capability>
    <capability>urn:nokia.com:sros:ns:yang:sr:conf?module=nokia-conf&amp;revision=2016-01-01</capability>
    <capability>urn:nokia.com:sros:ns:yang:sr:sros-yang-extensions?module=nokia-sros-yang-extensions&amp;revision=2016-01-01</capability>
    <capability>urn:nokia.com:sros:ns:yang:sr:types-filter?module=nokia-types-filter&amp;revision=2016-01-01</capability>
    <capability>urn:nokia.com:sros:ns:yang:sr:types-qos?module=nokia-types-qos&amp;revision=2016-01-01</capability>
    <capability>urn:nokia.com:sros:ns:yang:sr:types-services?module=nokia-types-services&amp;revision=2016-01-01</capability>
    <capability>urn:nokia.com:sros:ns:yang:sr:types-sros?module=nokia-types-sros&amp;revision=2016-01-01</capability>
    <capability>urn:nokia.com:sros:ns:yang:sr:major-release-14</capability>
  </capabilities>
  <session-id>52</session-id>
</hello>

SEND: <nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:message-id="1">
  <nc:get-config>
    <nc:source>
      <nc:running/>    </nc:source>
  </nc:get-config>
</nc:rpc>

RECV: <?xml version="1.0" encoding="UTF-8"?>
<rpc-reply urn:ietf:params:xml:ns:netconf:base:1.0:message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <rpc-error>
        <error-type>rpc</error-type>
        <error-tag>missing-attribute</error-tag>
        <error-severity>error</error-severity>
        <error-info>
            <bad-element>message-id</bad-element>
            <bad-element>rpc</bad-element>
        </error-info>
        <error-message>
            Check that message-id attribute is present and less than 4096 characters
        </error-message>
    </rpc-error>
</rpc-reply>

[Fatal Error] :2:20: Attribute name "urn:ietf" associated with an element type "rpc-reply" must be followed by the ' = ' character.
[Fatal Error] :2:20: Attribute name "urn:ietf" associated with an element type "rpc-reply" must be followed by the ' = ' character.
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 20; Attribute name "urn:ietf" associated with an element type "rpc-reply" must be followed by the ' = ' character.
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1239)
    at com.tailf.jnc.YangXMLParser.parse(YangXMLParser.java:50)
    at com.tailf.jnc.XMLParser.parse(XMLParser.java:154)
    at com.tailf.jnc.NetconfSession.recv_rpc_reply(NetconfSession.java:1495)
    at com.tailf.jnc.NetconfSession.recv_rpc_reply_data(NetconfSession.java:1472)
    at com.tailf.jnc.NetconfSession.getConfig(NetconfSession.java:443)
    at client.Client.main(Client.java:51)
Exception in thread "main" Parse error: parse error: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 20; Attribute name "urn:ietf" associated with an element type "rpc-reply" must be followed by the ' = ' character.
    at com.tailf.jnc.YangXMLParser.parse(YangXMLParser.java:54)
    at com.tailf.jnc.XMLParser.parse(XMLParser.java:154)
    at com.tailf.jnc.NetconfSession.recv_rpc_reply(NetconfSession.java:1495)
    at com.tailf.jnc.NetconfSession.recv_rpc_reply_data(NetconfSession.java:1472)
    at com.tailf.jnc.NetconfSession.getConfig(NetconfSession.java:443)
    at client.Client.main(Client.java:51)

I have been debugging this issue for a long time, but I am unable to fix it. Can you please help me out? I will be really indebted to you.

Thanks and regards...

confdc fails to generate the XSD file in example 0-intro.

Hi,
I met the error when trying to 'make' at step 4.1 in the example 0-intro README.

 $ LANG=C make all
 cp /home/ncs/ncs/netsim/confd/etc/confd/ietf-inet-types.fxs ietf-inet-types.fxs
 /home/ncs/ncs/netsim/confd/bin/confdc --java-package com.example.test -c ../../yang/hosts.yang
 /home/ncs/ncs/netsim/confd/bin/confdc -f /home/ncs/ncs/netsim/confd/etc/confd/ietf-inet-types.fxs \
--emit-xsd hosts.xsd hosts.fxs
 Internal error
 make: *** [hosts.xsd] Error 1

How do I see the details of the error?
The version is NCS 3.4.1 and confd-5.4.1.

Thanks.

Saved XML isn't well formed

When saving a NodeSet with .toXMLString the resulting XML isn't 'well formed' and cannot be parsed by the XMLParser. This makes it difficult to load XML which has been previously saved.

    NodeSet all = session.getConfig();
    new XMLParser().parse(all.toXMLString());

results in:

[Fatal Error] :261:2: The markup in the document following the root element must be well-formed.
Exception in thread "main" Parse error: parse error: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.

When adding dummy tags around the whole thing, eg ..... the types cannot be cast to our own model.

Error while generating classes from yang file

I am trying to run example 02-junos and getting following error while generating classes from yang file.

TypeError: unsupported operand type(s) for +: 'JNCPlugin' and 'str'

Full Error Trace:

configuration-15.1.yang:6: warning: unexpected modulename "configuration" in configuration-15.1.yang, should be configuration-15.1
configuration-15.1.yang:9: error: module "junos-extension" not found in search path
configuration-15.1.yang:196 (at configuration-15.1.yang:4830): warning: default value for a key leaf is ignored
configuration-15.1.yang:196 (at configuration-15.1.yang:7494): warning: default value for a key leaf is ignored
configuration-15.1.yang:196 (at configuration-15.1.yang:9451): warning: default value for a key leaf is ignored
configuration-15.1.yang:196 (at configuration-15.1.yang:44948): warning: default value for a key leaf is ignored
configuration-15.1.yang:196 (at configuration-15.1.yang:47842): warning: default value for a key leaf is ignored
configuration-15.1.yang:196 (at configuration-15.1.yang:79904): warning: default value for a key leaf is ignored
configuration-15.1.yang:196 (at configuration-15.1.yang:117364): warning: default value for a key leaf is ignored
configuration-15.1.yang:196 (at configuration-15.1.yang:228181): warning: default value for a key leaf is ignored
WARNING: wbad_module_name, aborting.Traceback (most recent call last):
File "/opt/python-2.7.3/bin/pyang", line 5, in
pkg_resources.run_script('pyang==1.6', 'pyang')
File "/opt/python-2.7.3/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 489, in run_script
File "/opt/python-2.7.3/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1207, in run_script
File "/opt/python-2.7.3/lib/python2.7/site-packages/pyang-1.6-py2.7.egg/EGG-INFO/scripts/pyang", line 425, in
run()
File "/opt/python-2.7.3/lib/python2.7/site-packages/pyang-1.6-py2.7.egg/EGG-INFO/scripts/pyang", line 402, in run
sys.stderr.write(e.msg + '\n')
TypeError: unsupported operand type(s) for +: 'JNCPlugin' and 'str'

Regards,
Raviraj

Actions not being generated

Action elements in the Yang are not being generated into Java objects. I would expect an object for the Action input so these can be created and passed to session.action() and one for the output which this method would return.

The Yang looks like:

tailf:action backup {
tailf:info " Backs up Config database";
tailf:exec "/opt/database" {
tailf:args "-c $(context) -p $(path)";
}
input {
leaf to {
type inet:uri;
mandatory true;
description "Destination to which db backup file is sent";
tailf:info "Destination URL";
}
}
output {
list dbbackup {
tailf:cli-drop-node-name;
leaf response {
type string;
description "Response";
}
}
}
}

Implement equals in Element

Element currently checks only name, namespace and value in equals(). For generated YangElements it would be better to implement a deeper equals(). This would certainly allow for easier unit testing. Whenever two Elements come from different sources it is difficult to test for equality without resorting to using toXMLString() on each. The following results in a false positive test pass:

configureTest();
instance.doSomethingResultingInEdit();
final ArgumentCaptor<Element> editConfigArg = ArgumentCaptor.forClass(Element.class);
verify(netconfSession).editConfig(editConfigArg.capture());
verify(netconfSession).closeSession();
Assert.assertEquals(expectedElement, editConfigArg.getValue());

Whereas this results correctly in a fail:

Assert.assertEquals(expectedElement.toXMLString(), editConfigArg.getValue().toXMLString());

whenever the captured argument is not exactly the same as expectedElement. Compare() also results in a false positive. Come back to me if you need further information.

overlapping augments get overwritten

We have an issue when different YANG modules augments a leaf with the
same name into the same container in a third YANG module.

For example,

$ pyang -p ~/work/trunk/pyang/modules -f jnc --jnc-debug --jnc-output src a.yang

a.yang looks like this:

augment "/simple:hosts/simple:host" {
leaf primary-port {
type testType;
default 2012;
tailf:java-class-name bajs;
}
}

and src/hosts/hosts/Host.java is generated.

Then I do:

$ pyang -p ~/work/trunk/pyang/modules -f jnc --jnc-debug --jnc-output src b.yang

b.yang looks like this:

augment "/simple:hosts/simple:host" {
leaf primary-port {
type inet:port-number;
default 2013;
}
leaf secondary-port {
type inet:port-number;
default 2014;
}
}

src/hosts/hosts/Host.java is regenerated.

In the end the methods to handle the primary-port leaf methods in
Host.java overwrites each other.

This is bad. We need to think on this and come up with a better
strategy.

It may be that I misunderstand something as well. This has been known
to happen. :)

I'm looking for a solution.

/Jocke

NetConf session create Subscription is not working for filter type=xpath

The createSubscription() creates a Malformed rpc request xml if filter argument is present.
[Found in JNC1.2 release]

`int encode_createSubscription(Transport out, String stream,
String filter, String startTime, String stopTime) {
final String prefix = Element.defaultPrefixes
.nsToPrefix(Capabilities.NS_NOTIFICATION);
final String ncn = mk_prefix_colon(prefix);
final String xmlnsAttr = mk_xmlns_attr(prefix,
Capabilities.NS_NOTIFICATION);

    final int mid = encode_rpc_begin(out);
    out.println("<" + ncn + "create-subscription " + xmlnsAttr + ">");
    if (stream != null) {
        out.print("<" + ncn + STREAM_GT);
        out.print(stream);
        out.println("</" + ncn + STREAM_GT);
    }
    **if (filter != null) {
        out.print("<" + ncn + FILTER + ncn + "type='xpath'>");
        out.print(filter);
        out.println("</" + ncn + FILTER_GT);
    }**
    if (startTime != null) {
        out.print("<" + ncn + START_TIME_GT);
        out.print(startTime);
        out.println("</" + ncn + START_TIME_GT);
    }
    if (stopTime != null) {
        out.print("<" + ncn + STOP_TIME_GT);
        out.print(stopTime);
        out.println("</" + ncn + STOP_TIME_GT);
    }
    out.println("</" + ncn + "create-subscription>");
    encode_rpc_end(out);
    return mid;
}`

Highlighted code snippet shows that if filter type is xpath then the 'filter' string should be used as value for 'select' attribute within element, which is missing here

Static Code Analysis

Feature Request: Tied to Issue No 1.

Move to Maven facilitates easier integration of build phase static analysis. Will allow for source code analysis using:

  • Findbugs
  • PMD
  • Checkstyle

Interfaces-1

Hi Emil, seems to be a problem with the pyang example in 1-Interfaces, I havent tried the other examples so cant say if same issues exists.

[damianoneill 1-interfaces]$ export PYANG_PLUGINPATH=../..; ant
Buildfile: /Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/examples/1-interfaces/build.xml

clean:
[delete] Deleting directory /Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/examples/1-interfaces/src

generate:
[mkdir] Created dir: /Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/examples/1-interfaces/src

compile:
[mkdir] Created dir: /Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/examples/1-interfaces/build/classes
[javac] Compiling 27 source files to /Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/examples/1-interfaces/build/classes
[javac] /Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/examples/1-interfaces/src/ianaIfType/IanaIfType.java:9: expected
[javac] package .ianaIfType;
[javac] ^
[javac] /Users/damianoneill/Downloads/tail-f-systems-JNC-47b597a/examples/1-interfaces/src/ianaIfType/IanaIfType.java:11: '.' expected
[javac] import YangException;

Separately for the Maven build I've been looking at this and have noticed that --jnc-output is creating the valid directory but the package name is missing the first character. I assume that you have logic in jnc.py that is parsing command opts using character parsing?

trace replacement

Feature Request

Replacement of System.err local calls with a logging framework. http://www.slf4j.org/ should be used to provide flexibility around which logging framework can be used.

module "tailf-common" not found in search path

Not able to compile JNC example 0-Intro .

Using Python-2.7/pyang 1.7. Below is the error trace,

fails at below line in build.xml

pyang -f jnc --verbose --jnc-output src/gen/com/example/test ../yang/hosts.yang.

Please let me know if i am missing something

../yang/hosts.yang:5: error: module "tailf-common" not found in search path
../yang/hosts.yang:8: error: module "ietf-inet-types" not found in search path
Traceback (most recent call last):
File "D:\Python27\Scripts\pyang", line 4, in
import('pkg_resources').run_script('pyang==1.7', 'pyang')
File "D:\Python27\lib\site-packages\pkg_resources__init__.py", line 729, in r
un_script
self.require(requires)[0].run_script(script_name, ns)
File "D:\Python27\lib\site-packages\pkg_resources__init__.py", line 1642, in
run_script
exec(code, namespace, namespace)
File "d:\python27\lib\site-packages\pyang-1.7-py2.7.egg\EGG-INFO\scripts\pyang
", line 434, in
run()
File "d:\python27\lib\site-packages\pyang-1.7-py2.7.egg\EGG-INFO\scripts\pyang
", line 411, in run
sys.stderr.write(e.msg + '\n')
TypeError: unsupported operand type(s) for +: 'JNCPlugin' and 'str'

Import statements and schema is not properly converted from yang model.

Hi,
I tried to convert yang file in java using your suggested way, but in java file import statements are not proper so i manually changed import statement and schema file.
But i think there is something missing in java file b'coz request message differs while executing same yang file from CLI using netconf-console and from JAVA.

Equals between YangString and String fails

YangString.equals(String) fails due to missing code in YangString.canEquals(obj) method

When xml tree is loaded using schema String value will be mapped to YangString but when loaded without schema, String values are mapped to Java String.

Failure to negotiate netconf hello with Cisco CSR1000V - missing xml version

I'm trying to negotiate a trivial hello with a Cisco CSR1000V. I can do this by manually pasting things to the SSH command line, so I know the router is working.

The cisco is running:

Cisco IOS XE Software, Version 03.12.00.S - Standard Support Release
Cisco IOS Software, CSR1000V Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 15.4(2)S, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2014 by Cisco Systems, Inc.
Compiled Wed 26-Mar-14 21:09 by mcpre

Here's my program:

public class TestNetconf {

    public static void main(String[] args) throws IOException, JNCException {

        Element.setDebugLevel(99);

        String emsUserName = "bobby";
        String ip = "localhost";
        DeviceUser duser = new DeviceUser(emsUserName, "[removed]", "[removed]");
        Device dev = new Device("mydev", duser, "10.10.10.10", 22);

        try {
            dev.connect(emsUserName);
            dev.newSession("cfg");
        } catch (IOException e) {
            System.err.println(e);
            System.exit(1);
        } catch (JNCException e) {
            System.err.println("Can't authenticate " + e);
            System.exit(1);
        }
    }    
}

Debug output looks like this:

*NetconfSession: hello: 
*Path: tokenize() -> TokenList[ATOM(self),COLONCOLON,ATOM(hello),SLASH,ATOM(capabilities)]
*Path: parse(): TokenList[ATOM(self),COLONCOLON,ATOM(hello),SLASH,ATOM(capabilities)]
*Path: parsePredicates(): TokenList[SLASH,ATOM(capabilities)]
*Path: parse(): TokenList[ATOM(capabilities)]
*Path: parsePredicates(): TokenList[]
*Path: parse() -> [LocationStep{AXIS_SELF,name=hello}, LocationStep{AXIS_CHILD,name=capabilities}]
*Path: eval(): Path[LocationStep{AXIS_SELF,name=hello}LocationStep{AXIS_CHILD,name=capabilities}]
*NetconfSession: capabilities: 
<capabilities>
  <capability>urn:ietf:params:netconf:base:1.0</capability>
  <capability>urn:ietf:params:netconf:capability:writeable-running:1.0</capability>
  <capability>urn:ietf:params:netconf:capability:startup:1.0</capability>
  <capability>urn:ietf:params:netconf:capability:url:1.0</capability>
  <capability>urn:cisco:params:netconf:capability:pi-data-model:1.0</capability>
  <capability>urn:cisco:params:netconf:capability:notification:1.0</capability>
</capabilities>

*Path: tokenize() -> TokenList[ATOM(capability)]
*Path: parse(): TokenList[ATOM(capability)]
*Path: parsePredicates(): TokenList[]
*Path: parse() -> [LocationStep{AXIS_CHILD,name=capability}]
*Path: eval(): Path[LocationStep{AXIS_CHILD,name=capability}]
*Path: tokenize() -> TokenList[ATOM(self),COLONCOLON,ATOM(hello),SLASH,ATOM(session-id)]
*Path: parse(): TokenList[ATOM(self),COLONCOLON,ATOM(hello),SLASH,ATOM(session-id)]
*Path: parsePredicates(): TokenList[SLASH,ATOM(session-id)]
*Path: parse(): TokenList[ATOM(session-id)]
*Path: parsePredicates(): TokenList[]
*Path: parse() -> [LocationStep{AXIS_SELF,name=hello}, LocationStep{AXIS_CHILD,name=session-id}]
*Path: eval(): Path[LocationStep{AXIS_SELF,name=hello}LocationStep{AXIS_CHILD,name=session-id}]
*NetconfSession: sessionId = 1398563696

What I see on the Cisco with all debugging turned on is:

*Nov 16 18:11:23.701: GSI: netconf app _s_ssh.[0x7F19AC2DBE70]: new ssh connection from 10.1.17.78
*Nov 16 18:11:23.703: NETCONF: ns_clone.sess=0x7F19535C6670
*Nov 16 18:11:23.704: NETCONF: naap_accept.clone=0x7F19535C6670
*Nov 16 18:11:23.704: NETCONF: _nssd.33.snd.now<?xml version="1.0" encoding="UTF-8"?><hello><capabilities><capability>urn:ietf:params:netconf:base:1.0</capability><capability>urn:ietf:params:netconf:capability:writeable-running:1.0</capability><capability>urn:ietf:params:netconf:capability:startup:1.0</capability><capability>urn:ietf:params:netconf:capability:url:1.0</capability><capability>urn:cisco:params:netconf:capability:pi-data-model:1.0</capability><capability>urn:cisco:params:netconf:capability:notification:1.0</capability></capabilities><session-id>1398564464</session-id></hello>
*Nov 16 18:11:23.704: NETCONF: _nssd.33.snd.don=7F19535C6670 msg=7F19535C7E70
*Nov 16 18:11:23.704: NETCONF: ne_send.sess=0x7F19535C6670
*Nov 16 18:11:23.792: GSI: netconf app _s_ssh.[0x7F19598F5EA8]: <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><capabilities><capability>urn:ietf:params:netconf:base:1.0</capability>
</capabilities>
</hello>
*Nov 16 18:11:23.792: NETCONF: _namn.30.mlc.don=7F1953518790
*Nov 16 18:11:23.792: NETCONF: _narc.30.rcv.ok=7F19535C6670
*Nov 16 18:11:23.792: NETCONF: netconf_xml_interpret.30.msg_len=151 bytes
*Nov 16 18:11:23.792: NETCONF: netconf_xml_interpret.30.failure<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><capabilities><capability>urn:ietf:params:netconf:base:1.0</capability>
</capabilities>
</hello>
*Nov 16 18:11:23.792: NETCONF-ERROR: parse error before hello seen
*Nov 16 18:11:23.792: NETCONF: ns_stop.gsi_destroy.delayed
*Nov 16 18:11:23.792: NETCONF: netconf_execute_message.30.nre_type=2
*Nov 16 18:11:23.792: NETCONF: _nmfr.30.now=7F1953358EF0
*Nov 16 18:11:23.792: NETCONF: _nefrp.now=7F1953358EF0
*Nov 16 18:11:24.149: NETCONF: ns_destroy.sess=0x7F19535C6670

The line starting:

Nov 16 18:11:23.792: GSI: netconf app _s_ssh.[0x7F19598F5EA8]: <hello

is the hello JNC is sending to the Cisco. It doesn't like it for some reason. Formatted, the hello that JNC is sending (retrieved from the debug logs and formatted) looks like:

<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <capabilities>
    <capability>urn:ietf:params:netconf:base:1.0</capability>
  </capabilities>
</hello>

If I send the above hello (manually via command line ssh using ssh -s 10.10.10.10 netconf), I get the same error.

If, however, I send the following hello manually (with an additional xml version statement), it appears to connect and I can do other things like list the config.

<?xml version="1.0"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <capabilities>
    <capability>urn:ietf:params:netconf:base:1.0</capability>
  </capabilities>
</hello>

It would thus appear the Cisco is expecting, but not receiving, the xml version line.

Any ideas?

How to receive notification from multiple NetConf devices?

The receiveNotification() method in NetconfSession.java is to receive notification from one device using the NetconfSession. The thread which executes this method will be blocked till the notification is received from the device. So I need a separate thread for each device to receive the notification from them. I cannot afford to have one dedicated thread for each device. I would like to receive notification from multiple devices and those notifications from multiple devices should be handled by a single thread instead of one thread per device. Please let me know how to achieve this use case.

Roll back

Hi klacke,

Is it possible to do a roll back of an editConfig after commit has been performed on the data stores? Does JNC has any api to support this? I have looked it up, but could not find one. I appreciate your response.

Thanks,
Aruna.

Question: NETCONF server crashes using the NetconfSession.get("path")

Following code makes the NETCONF server crash -

    DeviceUser duser = new DeviceUser("bobby", "admin", "admin");
        Device dev = new Device("mydev", duser, "localhost", 2022);

        try {
            dev.connect("bobby");
            dev.newSession("cfg");
            System.out.println(dev.getSession("cfg").get("/devices/device").toXMLString());
        }
        catch (Throwable e) {
            e.printStackTrace();
        }
        finally {
            dev.closeSession("cfg");
            dev.close();
        }

The question is - Is this a problem on the NETCONF server implementation or there is something in the client code that may be problematic here ?

Note that calls like these succeed without crashing the server -

dev.getSession("cfg").getConfig(NetconfSession.RUNNING, "/devices/device").toXMLString()

Getting name from Attribute.java

Hi,

I have an issue to figure out what is the attribute name from Attribute object. I see that there is a getValue() method, but there is no getName(). How do I get the name of the attribute.

Thanks,

Missing File?

I would appreciate it if you could upload notif.xml, I think it should be in tests/11-test-notification/".

Question: Design of an subscriber based service using JNC

Hi,
I am very new to JNC (a couple of days) and have been given the task to design a client which subscribes to a NetConf server and then gets back stream of data Asynchronously (Whenever the server has it ready). It would be great if someone could give me an overview of how can this be done.
Thanks,
Anuja.

Build System

Feature Request to move from Ant to Maven Multiproject.

Will allow support out of the box:

  • All IDE configuration files, Eclipse, IDEAJ, etc.
  • Publishing of Milestone releases (versioning)
  • Easier integration of 3rd party dependencies
  • Std project layout

Not sure what netconf version is used by JNC

I am not sure what version of netconf is used by JNC. My server talks only Netconf 1.0.
I do not get any response from the server; not even for the hello message.
I skimmed through the code to find what version does JNC uses, but couldn't find any.

I need to know how I could instruct JNC to use netconf 1.0 only. I do not want it to use 1.1 internally.

If I connect another vendor's (MG-SOFT) client using "Auto-select" version I see the same behavior as that of JNC. However, if I specifically select version 1.0 in MG-Soft product I do get hello reply with a valid session-id.

Both JNC and MG-Soft are using Ganymed SSH2.

How do we get notifications in JNC?

This is not an issue but a question.

How do we get notifications in JNC? Is it through createSubcription() and receiveNotification() in NetconfSession class? Is there a code sample which shows how to do this? Thanks.

Autogen of nested yang files

Hi Emil, I believe that if the following exists.

Yang A imports Yang B which imports Yang C ...

This will fail on the compile stage as Yang C will not get generated.

This can be demonstrated with Yang files I supplied previously as Atlas depends on ietfinterfaces which in turn depends on ianaIfType.

I can manually get round this, though not ideal, as I am not responsible for dependency management, by explicitly generating ianaIfType in advance.

Cannot cast String to YangString

Our model has a method like getFOOBar which returns a string. With the latest changes this method is now getFooBar (lower case letters), and when getting the value a class cast exception is thrown:

java.lang.ClassCastException: java.lang.String cannot be cast to com.tailf.jnc.YangString

JNC fails to generate Java codes from Cisco IOS yang file

Hi,
I met the error when I tried to generate Java codes from Cisco IOS yang file.

$ python -V
Python 2.7.5
$ $NCS_DIR/bin/pyang -v
pyang 1.5
$ sha1sum $NCS_DIR/lib/pyang/pyang/plugins/jnc.py
6b638501be25215b4edfe444f7931005ce83eeeb  /home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py
$ sha1sum $NCS_DIR/packages/neds/cisco-ios/src/yang/tailf-ned-cisco-ios.yang 
a35881ee4b415e7deb338c7e78a4508e26ef76a3  /home/ncs/ncs/packages/neds/cisco-ios/src/yang/tailf-ned-cisco-ios.yang
$
$ cd ./test
$ $NCS_DIR/bin/pyang -f jnc -d . $NCS_DIR/packages/neds/cisco-ios/src/yang/tailf-ned-cisco-ios.yang --jnc-debug --jnc-verbose 2>&1 | tail -35
Writing file to: /home/ncs/jnc/test/src/gen/tailfNedCiscoIos/router/bgp/bgp/nexthop/Trigger.java
pkg gen.tailfNedCiscoIos.router.bgp.bgp.nexthop generated
Generating "Nexthop.java"...
Writing file to: /home/ncs/jnc/test/src/gen/tailfNedCiscoIos/router/bgp/bgp/Nexthop.java
Generating "Regexp.java"...
Writing file to: /home/ncs/jnc/test/src/gen/tailfNedCiscoIos/router/bgp/bgp/Regexp.java
pkg gen.tailfNedCiscoIos.router.bgp.bgp generated
Generating "Bgp.java"...
Writing file to: /home/ncs/jnc/test/src/gen/tailfNedCiscoIos/router/bgp/Bgp.java
Traceback (most recent call last):
  File "/home/ncs/ncs/lib/pyang/bin/pyang", line 411, in <module>
    run()
  File "/home/ncs/ncs/lib/pyang/bin/pyang", line 383, in run
    emit_obj.emit(ctx, modules, fd)
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 213, in emit
    self.generate_from(module)
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 250, in generate_from
    generator.generate()
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 995, in generate
    self.generate_classes()
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 1093, in generate_classes
    child_generator.generate()
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 997, in generate
    self.generate_class()
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 1190, in generate_class
    field = self.generate_child(ch)
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 1274, in generate_child
    child_generator.generate()
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 997, in generate
    self.generate_class()
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 1190, in generate_class
    field = self.generate_child(ch)
  File "/home/ncs/ncs/lib/pyang/pyang/plugins/jnc.py", line 1293, in generate_child
    access_method.modifiers = [f(x) for x in access_method.modifiers]
AttributeError: 'list' object has no attribute 'modifiers'

How do i address the error?

Thanks.

Can we use simple TCP connection in place of SSH?

Can we use simple TCP connection to connect with confd server in place of SSH, if yes then which library i need to use to establish a plane connection, so that i can easily see the request data.

Message-id is not added to the trace.

Hi klacke,

For NETCONF operations, the code does not seem to log the message-id used for the operation. However, in the response it is included. When we enable the debug level for JNC code, currently we do not have a way to correlate the response to request as message-id is missing in the request trace log. Can we get a fix for this?

public void editConfig(int datastore, Element configTree)
throws JNCException, IOException {
trace("editConfig: target=" + datastoreToString(datastore) + "\n"
+ configTree.toXMLString());

final int mid = encode_editConfig(out, encode_datastore(datastore),
configTree);
out.flush();
recv_rpc_reply_ok(mid);
}

Thanks,
Aruna.

NPE in NodeSet

Seeing a NPE in the NodeSet code.

java.lang.NullPointerException
at com.tailf.jnc.NodeSet.removeMember(NodeSet.java:120)

The method below is throwing this at if(e.equals(x)).

public boolean removeMember(Element x) {
    for (int i = 0; i < size(); i++) {
        final Element e = getElement(i);
        if (e.equals(x)) {
            remove(i);
            return true;
        }
    }
    return false;
}

It seems the size and actual elements are out of sync somehow.

Fails on imported module with tailf:symlink extension leaf

Fails to generate classes whenever an imported module is used via symlink extensions:

<test.yang>
...
import SNMPv2-MIB {
prefix mib2;
}
...
tailf:symlink contact {
tailf:path "/mib2:SNMPv2-MIB/mib2:system/mib2:sysContact";
}
</test.yang>

<tailf-common.yang>
...
extension symlink {
argument name {
tailf:arg-type {
type tailf:identifier;
}
}
...
</tailf-common.yang>

'ant jar' results in:
...
generate:
[mkdir] Created dir: /home/mark/YangGen/src/gen
[exec] yang/test.yang:27: warning: imported module SNMPv2-MIB not used
[exec] WARNING: unused_import, aborting.e.msg
[exec] atlas-system contains errors
...

I've opened an issue with pyang concerning the 'imported module not used' error message.

XPath error for re-match

When re-match is used inside a 'when' the generation fails with an error:

error: XPath function "re-match" is not defined in the XPath context

the 'when' line is similar to:

when "not( re-match( current()/name, 'foo' ) )";

Element toXMLString() fails to output namespace correctly

Guys - I've come across an issue where a valid netconf XML configuration is output (via toXMLString) incorrectly.

The yang model contains a simple leaf-list augmentation to ietf-system but the augmentation is defined in a different namespace. The toXMLString output is producing XML with the next element (in this case dns) shown as the wrong namespace (as well as repeating this incorrect namespace value once for every instance of the augmentation).

Yang Augmentation:

    augment "/ietf-sys:system/ietf-sys:ntp" {
         /*
          * Alternate (simpler) NTP model.  This replaces the standard one in
          * the ietf model and follows the same style as the DNS servers.
          */
         leaf-list server {
            type inet:ip-address;
            ordered-by user;
            description
               "Addresses of the NTP servers to use for system clock
                synchronization.

                Implementations MAY limit the number of entries in this
                leaf list.";
         }
    }

Sample netconf XML input sent to YangXMLParser (output from toXMLString expected to be equivalent):

    <system xmlns="urn:ietf:params:xml:ns:yang:ietf-system">
    <ntp>
      <server xmlns="http://domain.com/ns/test">1.1.1.1</server>
      <server xmlns="http://domain.com/ns/test">2.2.2.2</server>
      <server xmlns="http://domain.com/ns/test">3.3.3.3</server>
    </ntp>
    <dns>
      <server>172.16.1.1</server>
    </dns>
    <radius>
      <server>
        <address>172.16.1.2</address>
        <shared-secret>password</shared-secret>
      </server>
    </radius>
    </system>

Actual Element.toXMLString() output:

<system xmlns="urn:ietf:params:xml:ns:yang:ietf-system">
  <ntp>
    <unknown:server>1.1.1.1</unknown:server>
    <unknown:server>2.2.2.2</unknown:server>
    <unknown:server>3.3.3.3</unknown:server>
  </ntp>
  <dns xmlns="http://domain.com/ns/test" xmlns="http://domain.com/ns/test" xmlns="http://domain.com/ns/test">
    <server>172.16.1.1</server>
  </dns>
  <radius>
    <server>
      <address>172.16.1.2</address>
      <shared-secret>password</shared-secret>
    </server>
  </radius>
</system>

Analysis of the elements before printing using toXMLString() - this shows the namespace of each of the children appear to be correct, leading me to the assumption its a defect in toXMLString():

2013-07-16 12:46:08 >>> Element name system --- Element namespace urn:ietf:params:xml:ns:yang:ietf-system
2013-07-16 12:46:08 >>> Element is of class type: gen.ietfSystem.System 

2013-07-16 12:46:08 >>>>>> Element name ntp --- Element namespace urn:ietf:params:xml:ns:yang:ietf-system
2013-07-16 12:46:08 >>>>>> Element is of class type: gen.ietfSystem.system.Ntp 

2013-07-16 12:46:08 >>>>>>>>> Element name server --- Element namespace http://domain.com/ns/test
2013-07-16 12:46:08 >>>>>>>>> Element is of class type: com.tailf.jnc.Leaf 

2013-07-16 12:46:08 >>>>>>>>> Element name server --- Element namespace http://domain.com/ns/test
2013-07-16 12:46:08 >>>>>>>>> Element is of class type: com.tailf.jnc.Leaf 

2013-07-16 12:46:08 >>>>>>>>> Element name server --- Element namespace http://domain.com/ns/test
2013-07-16 12:46:08 >>>>>>>>> Element is of class type: com.tailf.jnc.Leaf 

2013-07-16 12:46:08 >>>>>> Element name dns --- Element namespace urn:ietf:params:xml:ns:yang:ietf-system
2013-07-16 12:46:08 >>>>>> Element is of class type: gen.ietfSystem.system.Dns 

2013-07-16 12:46:08 >>>>>>>>> Element name server --- Element namespace urn:ietf:params:xml:ns:yang:ietf-system
2013-07-16 12:46:08 >>>>>>>>> Element is of class type: com.tailf.jnc.Leaf 

2013-07-16 12:46:08 >>>>>> Element name radius --- Element namespace urn:ietf:params:xml:ns:yang:ietf-system
2013-07-16 12:46:08 >>>>>> Element is of class type: gen.ietfSystem.system.Radius 

2013-07-16 12:46:08 >>>>>>>>> Element name server --- Element namespace urn:ietf:params:xml:ns:yang:ietf-system
2013-07-16 12:46:08 >>>>>>>>> Element is of class type: gen.ietfSystem.system.radius.Server

Please come back to me if you need the source, I've written a simple test harness I'm happy to share. Thanks, Mark

hardcoded gen package prefix

To remove the "gen" from the package I tried changing the output directory to src from src/gen, however the resulting code doesn't compile.

The output directory isn't really an issue, but the generated code shouldn't have a package prefixed with "gen".

XML output does not escape XML 'special' characters

When writing a value which contains an XML character entity (for instance '&' in the string 'yin & yang'), JNC does not escape the '&' (the XML should be yin & yang).
When JNC reads such data, the XML parser works fine and everything seems to be translated properly. But when writing to the netconf agent, the XML output does not follow XML standards. It looks like the XML is encoded 'by hand instead' of using an XML library.
I'm looking into replacing the manual XML generation with using JDOM if anyone is interested.

Some files are not generated correctly by pyang using jnc.py

I downloaded JNC and generated jnc.jar. However the compilation for examples/0-intro fails because there seems to be a problem in some of the files generated by pyang. When the generate target in build.xml is run by ant, it generates java files under src/gen/com/example/test. There are four directories here. All the other Java files seem to be OK, however package-info.java has each character on a new line. The compilation fails for package-info.java. I then removed package-info.java from under all these directories. The compilation worked after that. However when I do ant run, it fails and there is a parsing exception for Simple.schema. Simple.schema has the same problem as package-info.java. Every character is on a different line.

Does anyone know what could be source of this problem. Thanks.

Parsing saved XML

When saving XML we will need to parse this back into a NodeSet with our own types in. The code below shows casting an Element to an Equipment type after reading from a device. (The use of the 'delimeter' will be explained in another bug). The cast is successful on the NodeSet returned from the NetconfSession, but when I try to save that XML and use it to build a new NodeSet the children are all Elements and cannot be cast into our model types.

    NodeSet all = session.getConfig();

    Equipment equipment = (Equipment) all.get(0);

    StringBuilder savedXML = new StringBuilder();
    Iterator it = all.iterator();

    while (it.hasNext()) {
        Element object = (Element)it.next();
        savedXML.append(object.toXMLString());
        savedXML.append("</delimeter>");
    }
    NodeSet nodeSet = new NodeSet();
    String[] configElements = savedXML.toString().split("</delimeter>");
    for (int i = 0; i < configElements.length; i++) {
        Element element = new XMLParser().parse(configElements[i]);
        nodeSet.add(element);
    }

    Equipment equip = (Equipment)nodeSet.get(0); //This results in a ClassCastException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.