cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
866
Views
5
Helpful
2
Replies

Multiple Services package

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

1 Accepted Solution

Accepted Solutions

ramkraja
Cisco Employee
Cisco Employee

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

View solution in original post

2 Replies 2

ramkraja
Cisco Employee
Cisco Employee

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

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.

 

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: