cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3113
Views
4
Helpful
3
Replies

How to create netsim devices using two different types of ned in one directory which should start and stop using single netsim command command?

chandans
Cisco Employee
Cisco Employee

I want to create two types netsim devices for example PE(Cisco-ios) and CE(cisco-iosxr) which should start and stop using single command??

1 Accepted Solution

Accepted Solutions

yfherzog
Cisco Employee
Cisco Employee

Hi,

Have a look at the ncs-netsim help below.

If you create the first device(s) using 'ncs-netsim create-network', you can  add additional device(s) of same or different types with 'ncs-netsim add-to-network' using the same command structure.

If you create the first device using 'ncs-netsim create-device' you can add additional device with the 'ncs-netsim add-device' command (again, same command structure as create-device).

Once you created the devices, netsim will start, stop, restart all devices on the netsim dir, unless you specify a device name.

Hope that helps,

Yftach

YFHERZOG-M-W1ZZ:logs yfherzog$ ncs-netsim --help

Usage ncs-netsim  [--dir <NetsimDir>]

                  create-network <NcsPackage> <NumDevices> <Prefix> |

                  create-device <NcsPackage> <DeviceName> |

                  add-to-network <NcsPackage> <NumDevices> <Prefix> |

                  add-device <NcsPackage> <DeviceName> |

                  delete-network                     |

                  [-a | --async]  start [devname]    |

                  [-a | --async ] stop [devname]     |

                  [-a | --async ] reset [devname]    |

                  [-a | --async ] restart [devname]  |

                  list                      |

                  is-alive [devname]        |

                  status [devname]          |

                  whichdir                  |

                  ncs-xml-init [devname]    |

                  ncs-xml-init-remote [devname] |

                  packages                  |

                  netconf-console devname [XpathFilter] |

                  [-w | --window] [cli | cli-c | cli-i] devname

See manpage for ncs-netsim for more info. NetsimDir is optional

and defaults to ./netsim, any netsim directory above in the path,

or $NETSIM_DIR if set.

View solution in original post

3 Replies 3

yfherzog
Cisco Employee
Cisco Employee

Hi,

Have a look at the ncs-netsim help below.

If you create the first device(s) using 'ncs-netsim create-network', you can  add additional device(s) of same or different types with 'ncs-netsim add-to-network' using the same command structure.

If you create the first device using 'ncs-netsim create-device' you can add additional device with the 'ncs-netsim add-device' command (again, same command structure as create-device).

Once you created the devices, netsim will start, stop, restart all devices on the netsim dir, unless you specify a device name.

Hope that helps,

Yftach

YFHERZOG-M-W1ZZ:logs yfherzog$ ncs-netsim --help

Usage ncs-netsim  [--dir <NetsimDir>]

                  create-network <NcsPackage> <NumDevices> <Prefix> |

                  create-device <NcsPackage> <DeviceName> |

                  add-to-network <NcsPackage> <NumDevices> <Prefix> |

                  add-device <NcsPackage> <DeviceName> |

                  delete-network                     |

                  [-a | --async]  start [devname]    |

                  [-a | --async ] stop [devname]     |

                  [-a | --async ] reset [devname]    |

                  [-a | --async ] restart [devname]  |

                  list                      |

                  is-alive [devname]        |

                  status [devname]          |

                  whichdir                  |

                  ncs-xml-init [devname]    |

                  ncs-xml-init-remote [devname] |

                  packages                  |

                  netconf-console devname [XpathFilter] |

                  [-w | --window] [cli | cli-c | cli-i] devname

See manpage for ncs-netsim for more info. NetsimDir is optional

and defaults to ./netsim, any netsim directory above in the path,

or $NETSIM_DIR if set.

gschudel
Cisco Employee
Cisco Employee

Hi

In addition to the details that Yftach provided, you might also wish to look in the ncs ./examples

directory to check the "Makefile" in most of the provided examples. In most of the "Makefile" files

provided with the examples, a part of the recipes is (typically) to create and start NETSIM devices.

If you want you can even create your own - leading the the result you asked for (i assume) -- i.e. one command to start

both cisco-ios and cisco-ios-xr NETSIM devices..

For example, this recipe here (below) is a complete example. Save it as "Makefile"...

and then (after sourcing ncsrc), just type things like: "make clean all start" or "make demo-restart"

(please read and understand the Makefile contents, please read Makefile "man page")

#------------------

# List the NED packages required for this project

NED_PACKAGES = \

cisco-ios \

cisco-iosxr


#------------------

#------------------

ALL_PACKAGES = $(NED_PACKAGES)

#------------------

#------------------

# Create the netsim using the create-network argument to ncs-netsim

NETWORK = create-network packages/cisco-ios 2 c \

create-network packages/cisco-iosxr 2 xr


NETSIM_DIR = netsim

MKDIR_P = mkdir -p

#------------------

#------------------

all: build-all $(NETSIM_DIR)

#------------------

#------------------

build-all:

for i in $(ALL_PACKAGES); do \

echo $${i}; \

   $(MAKE) -C packages/$${i}/src all || exit 1; \

   done

#------------------

#------------------

$(NETSIM_DIR):

${MKDIR_P} ncs-cdb logs state

ncs-netsim --dir netsim $(NETWORK)

ncs-netsim ncs-xml-init > ncs-cdb/netsim_devices_init.xml

#------------------


# --------STOP/START code...

# stop everything...

stop:

-ncs --stop &

-ncs-netsim stop


# stop ncs only...

stop_ncs:

ncs --stop


# start everything... (no resets)

start: start_netsim start_ncs


# start netsim alone...

#   -a option runs everything in the background (reduces the time to start or stop a netsim network)

start_netsim:

ncs-netsim -a start


# start ncs alone...

#   note: the --ignore-initial-validation option makes NCS skip any validation

#   callpoints when committing initial transaction (on first startup)

start_ncs:

ncs --ignore-initial-validation

# --------CLEAN code...

clean-ned-packages:

for i in $(NED_PACKAGES); do \

   $(MAKE) -C packages/$${i}/src clean || exit 1; \

   done


clean-cdb:

rm -rf ncs-cdb/*.cdb


clean-netsim:

rm -rf netsim


clean-state:

rm -rf state/*


clean-logs:

rm -rf logs/*


clean: clean-ned-packages clean-cdb clean-netsim clean-state clean-logs

rm -rf running.DB

rm -rf *.trace

rm -rf bin

rm -rf ncs-cdb/*.xml

# --------DEMO RESTART...

# use this to clean out CDB, netsim, etc. w/o re-compiling anything...

demo-restart: qstop clean-cdb clean-netsim clean-state clean-logs $(NETSIM_DIR) start


qstop-python:

pkill -f ncs-python-vm || true


qstop: qstop-python

pkill -f ncs.conf || true

pkill -f confd.conf || true


# --------RESET options...

# restart  [DeviceName]  This is the equivalent of 'stop', 'reset', 'start'

netsim_restart:

ncs-netsim -a restart




alam.bilal
Cisco Employee
Cisco Employee

Also take a look at "ncs-project" tool. One stop shop for setting up a project, downloading and building the packages, creating and starting NETSIMs. It automatically sets up the required makefiles to build, clean, start (NETSIM, packages, NSO etc).