11-13-2019 04:28 AM
Hi, I would like to know how to create a package with several services inside.
I saw that in the examples in /examples.ncs/, they usually do this. Like, one package named "example1", and inside that a folder named "packages" with all the services.
+example1
...
+packages
+service1
+service2
...
So far, I have only created packages with a service inside, with the command:
ncs-make-package --service-skeleton python-and-template name
Thanks
Solved! Go to Solution.
11-13-2019 05:47 AM
Hello,
I saw that in the examples in /examples.ncs/, they usually do this. Like, one package named "example1", and inside that a folder named "packages" with all the services.
No. A package has a specified directory structure that you need to follow. ie., something like
$ ls packages/vlan doc package-meta-data.xml shared-jar erlang private-jar src load-dir python templates
so, you put your yang models under src/yang, Java code in src/java, jar files in private-jar/shared-jar, compiled fxs files in "load-dir", Python code in "python", Erlang code in "erlang" etc. Of course, you don't need to have all of these.
What you might have seen is something like "package-store", containing multiple packages - not a single package.
Hi, I would like to know how to create a package with several services inside.
That being said, it's certainly possible to have a single package containing several service implementations. Simply put the code/template for those multiple services in the appropriate directory, and specify them as components in the package-meta-data.xml file. For example, if you implemented one service in a Java class named "VlanServiceRFS", and another in a Python class named "pyService", you can put the following in package-meta-data.xml:
<component> <name>vlan</name> <callback> <java-class-name>com.example.vlan.VlanServiceRFS</java-class-name> </callback> </component> <component> <name>service</name> <application> <python-class-name>pyService</python-class-name> </application> </component>
Also, it is not strictly necessary that you implement each service as a separate component either. You can register and implement multiple services in the same Java/Python class, and specify that class as one single component in the package-meta-data.xml. If your services are template based, you don't even have to specify any component, because you will specify the servicepoint names in the template itself. So, you can just put the templates for multiple services in the 'templates' directory of your package, and you are done.
So, it depends on how your services are implemented, and how you want to structure them. It's quite flexible.
Thanks,
Ram
11-13-2019 05:47 AM
Hello,
I saw that in the examples in /examples.ncs/, they usually do this. Like, one package named "example1", and inside that a folder named "packages" with all the services.
No. A package has a specified directory structure that you need to follow. ie., something like
$ ls packages/vlan doc package-meta-data.xml shared-jar erlang private-jar src load-dir python templates
so, you put your yang models under src/yang, Java code in src/java, jar files in private-jar/shared-jar, compiled fxs files in "load-dir", Python code in "python", Erlang code in "erlang" etc. Of course, you don't need to have all of these.
What you might have seen is something like "package-store", containing multiple packages - not a single package.
Hi, I would like to know how to create a package with several services inside.
That being said, it's certainly possible to have a single package containing several service implementations. Simply put the code/template for those multiple services in the appropriate directory, and specify them as components in the package-meta-data.xml file. For example, if you implemented one service in a Java class named "VlanServiceRFS", and another in a Python class named "pyService", you can put the following in package-meta-data.xml:
<component> <name>vlan</name> <callback> <java-class-name>com.example.vlan.VlanServiceRFS</java-class-name> </callback> </component> <component> <name>service</name> <application> <python-class-name>pyService</python-class-name> </application> </component>
Also, it is not strictly necessary that you implement each service as a separate component either. You can register and implement multiple services in the same Java/Python class, and specify that class as one single component in the package-meta-data.xml. If your services are template based, you don't even have to specify any component, because you will specify the servicepoint names in the template itself. So, you can just put the templates for multiple services in the 'templates' directory of your package, and you are done.
So, it depends on how your services are implemented, and how you want to structure them. It's quite flexible.
Thanks,
Ram
11-13-2019 06:14 AM
Thank you @ramkraja , the explanation was very clear.
I will try to do the "package-store" thing. What I wanted was to order the packages a little better, and be able to have several versions of the same model.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide