tail-f-systems / JNC

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.
Other
77 stars 87 forks source link

How to use these generated classes with other netconf devices? #83

Closed herunkang2018 closed 1 year ago

herunkang2018 commented 6 years ago

Hi ALL,

I am starting to manage openvswitch with of-config, and the of-config is about two part: a ofc-server to connect to ovsdb(a datastore server for ovs) and a netconf agent using netconf protocol to interact with a netconf maneger like JNC.

My problem is that when I use pyang JNC plugin and of-config's yang schema to generate java classes, and using these classes to my project according to the example, it says

java.lang.ClassCastException: com.tailf.jnc.Element cannot be cast to gen.ofconf.ofconf.CapableSwitch

the code is:

CapableSwitch csTest = (CapableSwitch) config;

the example code is like this:

    public static Configuration getJunosConfiguration(NodeSet configs) {
        Element config = null;
        for (Element elem : configs) {
            if (elem.name.equals("configuration")) {
                config = elem;
                break;
            }
        }
        return (Configuration)config;
    }

and I find that CapableSwitch just extends YangElement, but it can't cast to Element class so I can't using the generated classes to modify configuration.

Any reply is appreciated!

martin-volf commented 1 year ago

Apologies for late response, the project was kind of on hiatus for a while. Do you still see the problem, even with recent changes? As you write, generated classes extend YangElement which extends Element, so you should not see it. Feel free to reopen if you still do.