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

Unable to integrate jnc to pyang. #79

Closed chaitu6 closed 1 year ago

chaitu6 commented 7 years ago

I would like to integrate jnc to pyang for java class generation. I added the jnc.py plug to pyang/plugins in pyang installation. And the executed setup.py file of pyang . Then tried the pyang -v command But am facing the following issue Traceback (most recent call last): File "/usr/local/bin/pyang", line 4, in import('pkg_resources').run_script('pyang==1.7.3', 'pyang') File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 719, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 1504, in run_script exec(code, namespace, namespace) File "/usr/local/lib/python2.7/dist-packages/pyang-1.7.3-py2.7.egg/EGG-INFO/scripts/pyang", line 450, in run() File "/usr/local/lib/python2.7/dist-packages/pyang-1.7.3-py2.7.egg/EGG-INFO/scripts/pyang", line 169, in run p.add_opts(optparser) File "/usr/local/lib/python2.7/dist-packages/pyang-1.7.3-py2.7.egg/pyang/plugins/tree.py", line 46, in add_opts if plugin.is_plugin_registered('restconf'): File "/usr/local/lib/python2.7/dist-packages/pyang-1.7.3-py2.7.egg/pyang/plugin.py", line 59, in is_plugin_registered if plugin.name == name: AttributeError: 'JNCPlugin' object has no attribute 'name'

Please help me out.

manujagobind commented 6 years ago

Were you able to fix this? @chaitu6

danieldai commented 6 years ago

@manujagobind It seems can be fixed by supply a name to JNCPlugin class

class JNCPlugin(plugin.PyangPlugin):
    """The plug-in class of JNC.

    The methods of this class are invoked by pyang during initialization. The
    emit method is of particular interest if you are new to writing plugins to
    pyang. It is from there that the parsing of the YANG statement tree
    emanates, producing the generated classes that constitutes the output of
    this plug-in.

    """
    name = "jnc"
kaushik2306 commented 6 years ago
  1. Installed pyang using "pip install pyang"
  2. Copied jnc.py file to the pyang downloaded project "C:\Users\Kaushik\Documents\pyang-master\pyang\plugins"
  3. Executed "python setup.py install"
  4. Executed below command "pyang -v'. Getting below Error when performed step-4 C:\Users\Kaushik\Documents\pyang-master>pyang -V C:\Python27\python.exe: can't find 'main' module in 'C:\Users\Kaushik\Documents\pyang-master\pyang'

Could someone also help me to bypass this issue and also a proper step to generate java class using jnc because it is not given in user manual. Please not I am using Windows 10.

Thanks

lanfeust9 commented 5 years ago

@manujagobind It seems can be fixed by supply a name to JNCPlugin class

class JNCPlugin(plugin.PyangPlugin):
    """The plug-in class of JNC.

    The methods of this class are invoked by pyang during initialization. The
    emit method is of particular interest if you are new to writing plugins to
    pyang. It is from there that the parsing of the YANG statement tree
    emanates, producing the generated classes that constitutes the output of
    this plug-in.

    """
    name = "jnc"

In which file do you add this?

xotonic commented 5 years ago

@lanfeust9 https://github.com/tail-f-systems/JNC/blob/aae755b01e95b4de846e74adbd0fd287f5ac5a2f/jnc.py#L60

DataEdgeSystems commented 5 years ago

hi can any one please help me in generation java class from .yang file , i tried pyang with JNC but getting following error while executing command:

dataedge@ubuntu:~/sdnwork/JNC/examples/yang$ pyang -f jnc --jnc-output src/gen/simple yang/simple.yang Usage: pyang [options] [...]

Validates the YANG module in (or stdin), and all its dependencies.

pyang: error: no such option: --jnc-output

i had put jnc pluging into yang plugin dir also