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

load operational data to netsim device

sm000x
Level 5
Level 5

Hi, All:

I want to create a netsim device with operational data.
After I create the simualted network:
ncs-netsim create-network <pakage> 3 upf

In netsim/upf/upf0, I see the start.sh has the following:
++++++++++++++++++++++++++++++++
test -f cdb/O.cdb
first_time=$?

env sname=${NAME} ${CONFD} -c confd.conf ${CONFD_FLAGS} \
--addloadpath ${CONFD_DIR}/etc/confd
ret=$?

if [ ! $first_time = 0 ]; then
true;
## If there is anything we want to do after the
## first initial start, this is the place. An example could be
## to load CDB operational data from xml files
fi
++++++++++++++++++++++++++++++++

I want to load the operational data: cfgmgr_init.xml
<config xmlns="http://tail-f.com/ns/config/1.0">
<config-schema xmlns="http://affirmednetworks.com/ns/yang/cna-cfgmgr">
<config-schema-list>
<service-type>bgpmgr</service-type>
<version>1.1.83</version>
</config-schema-list>
</config-schema>
</config>

to the netsim device: upf0

I add cfgmgr_init.xml in start.sh:
if [ ! $first_time = 0 ]; then
true;
## If there is anything we want to do after the
## first initial start, this is the place. An example could be
## to load CDB operational data from xml files
cfgmgr_init.xml
fi

when I start upf0, I got the following error:
[root@mtznjv1cnro03 packages]# ncs-netsim start upf0
./start.sh: line 35: cfgmgr_init.xml: command not found
DEVICE upf0 OK STARTED
[root@mtznjv1cnro03 packages]#

The cfgmgr_init.xml is not loaded.

Does anyone know how to load the operational data to the netsim device?

Thank you
sm000x

1 Accepted Solution

Accepted Solutions

Jesus Illescas
Cisco Employee
Cisco Employee

Taking a look at the `nso-examples` collection, the `develop-service` on `getting-started` shows how to add oper data to a netsim device.

In the case of the example, this is how they do it

# So for example here we can load operational data
# Test, and only do this the first time

if [ $ret = 0 -a ! $first_time = 0 ]; then
    ${CONFD_DIR}/bin/confd_load -l -m -O ${PACKAGE_NETSIM_DIR}/oper/${NAME}.xml
fi

They are using `confd_load` to load the oper configuration. I would assume that `PACKAGE_NETSIM_DIR` uses an absolute path.

Take a look at the full example https://github.com/NSO-developer/nso-examples/blob/main/getting-started/develop-service/init/router.in/netsim/start.sh#L33C44-L33C62

To keep a record here, this is the full start.sh on the example

# We may optionally have start.sh file in the netsim directory
# It will be transformed and sourced with a set of environment
# variables.
# If we need to start additional C programs we can do that here
# Also if we need to load additional XML/CLI files etc we
# can do that here.
# This script will have access to the following environment variables
   
# CONFD_IPC_PORT    - which port is this ConfD instance listening to for IPC
# NETCONF_SSH_PORT  - which port is this ConfD instance listening to for netconf
# NETCONF_TCP_PORT
# CLI_SSH_PORT      - which port is this ConfD instance listening to for CLI/ssh
# SNMP_PORT         - which port is this ConfD instance listening to for snmp
# NAME              - what is the name of this ConfD instance
# CONFD             - path to the confd executable
# CONFD_DIR         - path to the ConfD installation
# PACKAGE_NETSIM_DIR - path to the netsim directory in the package which
#                      was used to produce this netsim network                 


test -f  cdb/O.cdb
first_time=$?

env sname=${NAME} ${CONFD} -c confd.conf ${CONFD_FLAGS} \
                  --addloadpath ${CONFD_DIR}/etc/confd 
ret=$?
   
# So for example here we can load operational data
# Test, and only do this the first time

if [ $ret = 0 -a ! $first_time = 0 ]; then
    ${CONFD_DIR}/bin/confd_load -l -m -O ${PACKAGE_NETSIM_DIR}/oper/${NAME}.xml
fi
exit $ret

 

View solution in original post

2 Replies 2

Jesus Illescas
Cisco Employee
Cisco Employee

Taking a look at the `nso-examples` collection, the `develop-service` on `getting-started` shows how to add oper data to a netsim device.

In the case of the example, this is how they do it

# So for example here we can load operational data
# Test, and only do this the first time

if [ $ret = 0 -a ! $first_time = 0 ]; then
    ${CONFD_DIR}/bin/confd_load -l -m -O ${PACKAGE_NETSIM_DIR}/oper/${NAME}.xml
fi

They are using `confd_load` to load the oper configuration. I would assume that `PACKAGE_NETSIM_DIR` uses an absolute path.

Take a look at the full example https://github.com/NSO-developer/nso-examples/blob/main/getting-started/develop-service/init/router.in/netsim/start.sh#L33C44-L33C62

To keep a record here, this is the full start.sh on the example

# We may optionally have start.sh file in the netsim directory
# It will be transformed and sourced with a set of environment
# variables.
# If we need to start additional C programs we can do that here
# Also if we need to load additional XML/CLI files etc we
# can do that here.
# This script will have access to the following environment variables
   
# CONFD_IPC_PORT    - which port is this ConfD instance listening to for IPC
# NETCONF_SSH_PORT  - which port is this ConfD instance listening to for netconf
# NETCONF_TCP_PORT
# CLI_SSH_PORT      - which port is this ConfD instance listening to for CLI/ssh
# SNMP_PORT         - which port is this ConfD instance listening to for snmp
# NAME              - what is the name of this ConfD instance
# CONFD             - path to the confd executable
# CONFD_DIR         - path to the ConfD installation
# PACKAGE_NETSIM_DIR - path to the netsim directory in the package which
#                      was used to produce this netsim network                 


test -f  cdb/O.cdb
first_time=$?

env sname=${NAME} ${CONFD} -c confd.conf ${CONFD_FLAGS} \
                  --addloadpath ${CONFD_DIR}/etc/confd 
ret=$?
   
# So for example here we can load operational data
# Test, and only do this the first time

if [ $ret = 0 -a ! $first_time = 0 ]; then
    ${CONFD_DIR}/bin/confd_load -l -m -O ${PACKAGE_NETSIM_DIR}/oper/${NAME}.xml
fi
exit $ret

 

Hi Jesus:

Thank you so much for the help. It works.

Thank you

sm000x