cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Creating a GENERIC NED v 1.0

1365
Views
0
Helpful
4
Comments

Creating a GENERIC NED v 1.0


Content list
1. Introduction
2. NED demo video overview:
3. Device commands
4. Adapting the demo-ned to your device
5. Setting up a NED instance to communicate with the device
6. Debugging and trouble-shooting
7. Contents:

 

1 Introduction:
The idea of this article, the reference file, video, demo-ned and more is to provide a guide which
explains how to conveniently develop a bare minimum Generic NED with what is available after
installing NSO.

 

In the past ncs-make-package was used for generating new NEDs. Nowadays a NED generator is used and demo-ned is the result of a NED generator when requiring a Generic REST NED.

 

2. NED demo video overview:
This demo video will:
go through how the device work
show the commands to list and modify config which the NED supports
explain the YANG model
explain the Java Code
show how to set up a NED instance
demonstrate how to fetch config - sync-from
demonstrate how to output config changes - commit dry run
demonstrate how to create/delete config – commit
demonstrate the logging functionality

 

The name of the demo video is "Generic REST NED Development"

 

3. Device commands
What the NEDs sends to the device is determined by what commands the device require. This means that different
NEDs for different devices will send different commands.
This is also the part to adapt when adapting the demo-ned to another device.
For details refer to section "Device commands and NSO CLI commands" in the Reference file.

 

4. Adapting the demo-ned to your device
There are two steps when adapting the demo-ned to the any device. The first step is mandatory and covers device
communication. The second step is optional and covers namespace, ids and other NED internal details.
If you just need to quickly create a NED that communicates to any device, doing the first step is enough.
However, if the NED is to be used with other NEDs or if further development is expected then it is a good idea to do the
second step as well.

 

First step
In this first step only the java file JVXNedGeneric needs to be modified.
The methods to be modified are:
public void show(NedWorker worker, int th) throws NedException, IOException {

 

private void edit(NedWorker worker, NedEditOp[] ops, StringBuilder dryRun, int th) throws Exception {When fetching config from a device the NED command sync-from needs to be issued. Sync-from will call show.

 

When sending commands to the device the NED command commit needs to be issued. Commit will call prepare, which
in turn will call edit to fetch the command to be sent.
If just printing the commands to be sent is enough then the NED command commit dry-run needs to be issued. Commit
dry-run will call prepareDry, which in turn will call edit to fetch the command to be sent.

 

The key here is to:
adapt show so that it issues the device commands which lists config.
adapt edit so that it issues the correct command to either create, modify or delete config.
The idea with the NED is to emulate the procedure and use the same commands used when communicating to the
device from the CLI or REST API.

 

This part will be covered in the video.

 

For more details refer to the section "Commands and Java correlation" in the Reference file.

 

Second step - editing the NED details
The second step requires more file editing. Demo-ned and test-device-ned has the same functionality.
Test-device-ned is demo-ned after applying the second step where this replacement has been used.
GRX - devname
JVX - dn
DVX - Cisco
The details and where to replace values can be found in the section "Adapting an existing NED – Step Two" in the
Reference file.

 

5. Setting up a NED instance to communicate with the device
Once the demo-ned has been adapted to a device a NED instance has to be created so that the NED can communicate
with a device.
How to do this is described in section "Setting up a NED-instance" in the Reference file.

 

6. Debugging and trouble-shooting
One can also insert logging into the NED so that data can be printed out into log files.
How to do this is described in section "Debugging and trouble-shooting" in the Reference file.

Comments
Beginner

@hoatruo wrote:

In the past ncs-make-package was used for generating new NEDs. Nowadays a NED generator is used and demo-ned is the result of a NED generator when requiring a Generic REST NED.


Hi hoatruo,

 

is there somewhere where such a NED generator can be found please? Thanks

Cisco Employee

Hi Roland!

 

This generator is not available outside the NED team yet. Do you need any specific NED?

 

Thanks,

Hoa

Beginner

Hi @hoatruo ,

I am looking forward to use this to create a Generic REST NED with basic functionality to interact with a McAfee Web Gateway proxy via REST API. Would you be able to provide the code skeleton to work on? It would work nicely just like in your example.

 

Thanks,

Gustavo

Cisco Employee

Hi @gusmb 

 

The code skeleton is not publicly available yet.

If you need a NED for your project, please contact @fzeisig.

 

Thanks,

Hoa