Python beginner: Create Unitest out of SSH Session / Router CLI
In my test, a function on a router / switch to be executed via CLI. The function I speak via CLI as a query, and the function does exactly what it should. Problem now, the unit test, how do I build this? Output should be a.) Connect to SSH - Works / does not work b.) prompt opens - Works / does not work c.) Command (AAA Accounting) is executed - Works / does not work d.) command accounting disable is listed --- Works / does not work e.) Now, of course, the test should make an output accordingly. I had looked at some examples but just can not get on. I used Pythomn 3.7 with the packages Paramiko I am happy to answer any questions, and would be very happy if one or the other could answer accordingly. This is the function (a part !) I have implemented so far. This also works: s = SSH(host='172.xxx.xxx.xxx', username='xxxx', password='xxxx') s.query_interactive = True if s.login(): q = s.query('aaa') #CLI function open #accounting disable function q = s.query('accounting disable') # show information q = s.query('show config')
participants (1)
-
frentmeister