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

I want to use mock device in my testing instead of real device

anupsahoo03
Level 1
Level 1

Hi all,

I have created a mock device using pyats genie library. That means my mock device has learnt all possible features of real device.

My requirement is how do I SSH the mock device from NSO , how do I onboard the mock device in NSO so that I can use the mock device in my testing. Also is mock device writable ? I mean can we push configurations into the mock device like we do in real device.

 

 

6 Replies 6

balaji.bandi
Hall of Fame
Hall of Fame

Not sure what mock device you referring here, you can create a LAB environment Like CML / PNET / any other and use the device to automation.

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Jesus Illescas
Cisco Employee
Cisco Employee

For development you can use netsim which simulates devices. Take a look at this learning lab https://developer.cisco.com/learning/modules/nso-labs/nso-intro/setting-up-nso/ which includes instructions to help you get started on NSO and you will have an NSO instance right away.

If you want to get closer to real devices, you can use CML as balaji suggested. There are sandboxes available along learning labs where you can test this. See Cisco DevNet Sandbox

Take a look at the learning labs available here https://developer.cisco.com/learning/search/categories/Networking/products/NSO/?contentType=track,module,lab&isDevEnvOnly=true&page=1

I would suggest to use netsim or virtual devices for your testing, since they will interact better with NSO.

anupsahoo03
Level 1
Level 1

Hi Balaji / Jesus, Thanks for your replies.

My goal or purpose here is to use a mock device in NSO for my regression testing. Because a mock device is just a recording of real device configurations in yaml format (I am talking in terms of pyATS framework). But the limitation in pyATS mock device is that the mock device (the yaml format recording of real device configs) is only readable, we can not write/ config the mock device and also I m not able to SSH the mock device in NSO , rather I can just telnet the mock device using localhost 8266 port from NSO. 

As per your suggestions we can use CML devices, but the capability on which I am working is not going to work with CML devices. That needs only real devices. Also CML devices are sometimes out of sync or not reachable that affects the regression test. Hence I was planning to use a mock device concept, where we don't have dependencies on any devices , we won't have sync from issue since mock device is just a recordings of real device.

Please suggest how I Should proceed.

You dont have to use CML, you can run a lot of the routers as virtual versions but can skip the CML part. Take a look at https://github.com/vrnetlab/vrnetlab. 

Do development on netsims and testing on virtual and physical. 

snovello
Cisco Employee
Cisco Employee

Jesus Illescas suggested to use netsim, not CML, and that is the right answer. Netsim also has the capability of responding to commands with mocked responses, to see how, just look at the scripts within the netsim directory of a CLI NED as well as the files confd.c.cli and confd.i.cli. You could add more by copying how those scripts are done and get the mocked reponses from you pyats genie recording.

If you wanted to use the mocked device, which is started by running a script. One way would be to set up a user in linux and set them up to start that script immediately on login (in their .profile or .bashrc). Another option is that some NEDs have setting to manage devices that have to be reached via jumphosts or terminal servers. There you can specify prompts and responses (a bit like tcl expect) and so you could in the ned setting define that when it logs in it expects a linux prompt and then should start the script.

I just mention it for completeness. what you should use is netsim.

 

snovello
Cisco Employee
Cisco Employee
Hello,
Since I don’t use pyats much, I watched this video https://www.youtube.com/watch?v=cn1jdfkoJS4
about mock devices in pyats genie.

Could I connect to a mock device from NSO? Yes but you have to arrange that I ssh somewhere and immediately get the behavior of the mock device. For example I could create a use on the pyats host and their .bashrc would execute mock_device_cli with all the right params. Another way is that some cli NEDs have settings to get through a terminal server. Where I can specify prompts and commands to execute, so that might also be used to start the script.

Can I configure a mock device? No because the answer to ‘show run’ would always be the mocked response that was recorded on the real device. Basically as far as I can see the response to anything in a mock device is always simply copied out of the yaml file that is created when you make the recording.

Most netsim devices for cli neds have a facility to returned mocked responses to commands. Just look into the netsim folder of the NED typically ‘show version’ may be implemented. Using pyats to collect such mocked responses and then using netsim might be an approach you could take.
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: