cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
7038
Views
12
Helpful
25
Replies

Example for a simple stacked NSO Service

ks
Level 1
Level 1

Hello,

I am quite new to NSO Development. I am searching for a example for a simple stacked NSO Service. I went through the development guide but I am not quite sure how to accomplish this.

Thank you

Knut

25 Replies 25

Thank you very much for your reply,

that's right!

But I don't understand hwo the first service call the second service. I'm think the first service like a second services'father. That's right my interpretation?

 

Thanks a lot

Thank you very much!

That's right!

But I don't understand how the first service call second service. I'm think first service like a second service's father.

Is correct my interpretation?

 

Thanks a lot

It is more like a pipe connected to another pipe. The output of one is the input to the next.

You put input into service_first, the output of service_first is the input to service_second and the output from service_second is the input to the device. Hopefully running through the example a few times with commit dry-run will help you.

Thank you!

I see that the call to second service is into the service_first.xml

 

<service_second xmlns="http://com/example/servicesecond">
<name>{/name}</name>
<GigabitEthernetIface>{/GigabitEthernetIface}</GigabitEthernetIface>
<ntp-hostname>{/ntp-hostname}</ntp-hostname>
</service_second>

 

I would like to see an example where the first service calls the second service into java code with the template.

Do you know?  Are there some examples about it in the NSO Manuals?

 

Thank a lot, a lot!!!!

Hi,

I understand the operatione. Thank you.

I ask you two question :)

Is there a type for yang to give a string parameter with the blank space? It's very important for me, but I think that's impossible!

 

How can I see in NSO the link between a father service and a son service?

 

Thanka a lot

 

 

What do you mean by blank space? Strings can certainly contain spaces.

You can do a show on the service in operational mode to see what other services it modifies (.how myservice directly-modified services)

Thanks,

That's ok! I solved!!!!

 

Thank you very much

Hi  Vleijon,

well found!

I have a new problem :(

My service creates a Port-Channel whit a only interface. 

Then another service adds a "service instance" on the my Port-Channel.

This is the problem:

when I recall my service for add another interface at the Port-Channel, my service deletes la "service instance".

Are there a way for no delete the "service instance"?

 

Thanks

Do you happen to have any tags defined on the XML template that configures anything under the port-channel on that service (e.g. no-create)?

 

When you modify your port-channel service, it removes whatever it created in-memory and then re-applies it.
If the port-channel instance on the device data model doesn't have any other owners, then anything under it will be removed when the port-channel service that created it is modified/re-deployed.

 

If the service that uses the port-channel has tags='no-create' for the port-channel node, then that may explain why the service instance under the port-channel interface is being removed.

Hi yfherzog,

thanks very much.

I haven't got the tag "no-create" on the port-channel node, but there is on your child, the interface TenGigabitEthernet

This is my template:

 

<config-template xmlns="http://tail-f.com/ns/config/1.0">
<devices xmlns="http://tail-f.com/ns/ncs">
<device>

<name>{/router}</name>
<config>
<interface xmlns="urn:ios" >
<Port-channel >
<name>{port-channel}</name>
<description>{pc-description}</description>
<ip>
<no-address>
<address>false</address>
</no-address>
</ip>
<load-interval>{pc-load-interval}</load-interval>
<mtu>{pc-mtu}</mtu>
<service-policy>
<input>{pc-service-policy}</input>
</service-policy>
<shutdown tags="delete"/>
</Port-channel>
</interface>
<interface xmlns="urn:ios" foreach="{interface}" >
<TenGigabitEthernet when="{interface-type='TenGigabitEthernet'}" tags="nocreate">
<name>{interface-index}</name>
<channel-group tags="merge">
<number>{pc-interface}</number>
<mode>active</mode>
</channel-group >
<description tags="merge">{description}</description>
<ip>
<no-address>
<address>false</address>
</no-address>
</ip>
<load-interval tags="merge">{load-interval}</load-interval>
<mtu tags="merge">{mtu}</mtu>
<service-policy tags="merge">
<input>{service-policy}</input>
</service-policy>
<shutdown tags="delete"/>
</TenGigabitEthernet>
</interface>
</config>
</device>
</devices>
</config-template>

 

The problem would can be it?!!!

 

Thanks a lot of. 

Thanks!

 

 

 

 

What about the template on the service that uses the port-channel (the one that adds a service instance on the port channel interface?

Do you have nocreate there on the port-channel interface?

 

The nocreate tag means, if it's not there, then don't create it.

Technically, it means that the service will not increase the reference counter (refcount) on the configs tagged with nocreate.

When a refcount on a node reaches 0, NSO automatically deletes that node.

 

If you have nocreate on the port-channel on the service that uses the port, this is what should happen:

 

1. service that creates the port channel sets the refcount on the port-channel to 1.

2. service that adds a service instance on the port channel leaves the refcount at 1 (nocreate), and sets some other attributes on the port (change their refcount to 1).

3. You then modify the service that created the port-channel: Fastmap undos whatever that service configured in memory. This means, reducing the refcount on all the nodes that service configured - including the port-channel node, which is now at 0. This causes everything under that node to be deleted.

4. The service then re-applies its mapping logic and recreates the port-channel node, and everything under it which is part of the port-channel service (e.g. description). This causes everything that was created by this service to stay in place, but anything else to be deleted, and that might be what you're seeing.

 

If you remove the nocreate from the service that adds the service instance on the port-channel, then the following will happen:

 

1. service that creates the port channel sets the refcount on the port-channel to 1.

2. service that adds a service instance on the port channel increases on the port-channel node to 2 (merge), and sets some other attributes on the port (change their refcount to 1).

3. You then modify the service that created the port-channel: Fastmap undos whatever that service configured in memory. reducing the refcount on the port-channel node to 1. As it doesn't reach 0, NSO will NOT remove the node, and will only delete the configs which are only owned by the service which created the port-channel (e.g. port-channel description).

4. The service then re-applies its mapping logic and increments the refcount on the port-channel node to 2 again, and applies everything under it which is part of the port-channel service.

 

 

If indeed you have that nocreate on the service that creates the service instance on the port-channel interface, then remove it (change to merge), re-deploy that service instance (to set the refcount correctly) and then try your modification again.

 

You can actually see the refcount value on any node with "show running ... | display service-meta-data"

For example:

 

show running-config devices device ios-0 config ios:interface Port-channel 4 | display xml | display service-meta-data

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: