Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.2
4.0.0
80 changes: 74 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@

ncs-netsim is a great tool, but it lack of following features which are developed as part of netsim-wrapper

- netsim-wrapper features
- delete-devices \<device-names>
- create-network-from [ yaml | json ] \<filename>
- create-device-from [ yaml | json ] \<filename>
- create-network-template [ yaml | json ]
- create-device-template [ yaml | json ]
```python
Usage nwrap template create [network | device] [yaml | json] [<fileName>]
template load <fileName> [<username> <password>]
download <username> <password> link
delete-devices <DeviceNames>
-v | --version
-vv | --verbose
-h | --help

nwrap is an alias of `netsim-wrapper` and you can pass
multiple devnames instead of single devname, eg. start, stop, ...

Additionally we support all `ncs-netsim` commands
```

netsim-wrapper is a wrapper on top of ncs-netsim with added features. It's written in python and we opened the space to add more features to it.

Expand All @@ -33,6 +41,66 @@ ncs-netsim, It's a powerful tool to build a simulated network environment for Ne

netsim-wrapper, An open space to automate the ncs-netsim.

You can build your netsim network using JSON/YAML templates as follows

**creating device using YAML file**
```
nso-packages-path: ./nso-run/package
download-neds: false
neds:
- https://earth.tail-f.com:8443/ncs-pkgs/cisco-ios/5.7.1/ncs-5.7.1-cisco-ios-6.79.signed.bin
compile-neds: false
packages-reload: false
start-devices: true
add-to-nso: true
add-authgroup-to-nso: false
authgroup:
type: local
path: ./custom_authgroup.xml
device-mode:
name-based:
cisco-ios-cli-6.79:
- device-ios0
- device-ios1
load-day0-config: false
config-path: ../day0/
config-files:
- device_ios0_interface.cfg
- device_ios1_interface.cfg
```

**creating network using JSON format**
```
{
"nso-packages-path": "./nso-run/packages",
"download-neds": true,
"neds": [
"https://earth.tail-f.com:8443/ncs-pkgs/cisco-ios/5.7.1/ncs-5.7.1-cisco-ios-6.79.signed.bin"
],
"compile-neds": true,
"packages-reload": true,
"start-devices": true,
"add-to-nso": true,
"add-authgroup-to-nso": true,
"authgroup": {
"type": "system"
},
"device-mode": {
"prefix-based": {
"cisco-ios-cli-6.79": {
"count": 2,
"prefix": "network-ios"
}
}
},
"load-day0-config": true,
"config-path": "./day0/",
"config-files": [
"network_ios0_interface.cfg",
"network_ios1_interface.cfg"
]
}
```
## Pre-requisites

- ncs-netsim command must be reconginsed by the terminal.
Expand Down
31 changes: 31 additions & 0 deletions netsim_wrapper/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
from logging import DEBUG

from netsim_wrapper.nwrap import NWrap


def check_verbose(params):
nwrap = None
if '-vv' in params:
nwrap = NWrap(level=DEBUG)
params.remove('-vv')
if '--verbose' in params:
nwrap = NWrap(level=DEBUG)
params.remove('--verbose')
return nwrap, params


def nwrap():
nwrap, params = check_verbose(sys.argv)
if nwrap == None: nwrap = NWrap()

if len(params) >= 2:
if params[1] not in nwrap.options:
nwrap.help
nwrap.apply(params[1:])
nwrap.utils.exit
nwrap.help

if __name__ == "__main__":
nwrap()

Loading