def test_bash(self): c = Connection(hostname='Router', start=['mock_device_cli --os iosxe --state isr_exec'], os='iosxe', username='******', tacacs_password='******', enable_password='******') with c.bash_console() as console: console.execute('ls') self.assertIn('exit', c.spawn.match.match_output) self.assertIn('Router#', c.spawn.match.match_output)
def test_bash(self): c = Connection(hostname='junos_vmx2', start=['mock_device_cli --os junos --state exec'], os='junos', username='******', tacacs_password='******') with c.bash_console() as console: console.execute('ls') self.assertIn('cli', c.spawn.match.match_output) self.assertIn('root@junos_vmx2>', c.spawn.match.match_output)
def test_run_prompt_rp(self): conn = Connection( hostname='R2', start=[ 'mock_device_cli --os iosxr --state enable_bash_run_prompt_rp --hostname R2' ], os='iosxr', enable_password='******') with conn.bash_console(): pass
def test_bash(self): c = Connection(hostname='switch', start=['mock_device_cli --os nxos --state exec'], os='nxos', username='******', tacacs_password='******') with c.bash_console() as console: console.execute('ls') self.assertIn('exit', c.spawn.match.match_output) self.assertIn('switch#', c.spawn.match.match_output)
def test_bash2(self): conn = Connection(hostname='Router', start=['mock_device_cli --os iosxr --state enable2'], os='iosxr', enable_password='******') with conn.bash_console() as console: out = console.execute('pwd') self.assertIn('disk0', out) ret = conn.spawn.match.match_output self.assertIn('exit', ret) self.assertIn('Router#', ret)
def test_bash_asr(self): c = Connection( hostname='Router', start=['mock_device_cli --os iosxe --state asr_exec'], os='iosxe', credentials=dict(default=dict(username='******', password='******')), log_buffer=True) with c.bash_console() as console: console.execute('df /bootflash/') self.assertIn('exit', c.spawn.match.match_output) self.assertIn('Router#', c.spawn.match.match_output) c.disconnect()
def test_bash_ha_standby(self): ha = MockDeviceTcpWrapperNXOS(port=0, state='exec,nxos_exec_standby') ha.start() d = Connection(hostname='Router', start=['telnet 127.0.0.1 '+ str(ha.ports[0]), 'telnet 127.0.0.1 '+ str(ha.ports[1]) ], os='nxos', username='******', tacacs_password='******') d.connect() with d.bash_console(target='standby') as console: console.execute('ls', target='standby') self.assertIn('exit', d.standby.spawn.match.match_output) self.assertIn('switch(standby)#', d.standby.spawn.match.match_output) d.disconnect() ha.stop()
def test_bash_asr(self): c = Connection(hostname='Router', start=['mock_device_cli --os iosxe --state asr_exec'], os='iosxe', username='******', tacacs_password='******', enable_password='******', settings=dict(POST_DISCONNECT_WAIT_SEC=0, GRACEFUL_DISCONNECT_WAIT_SEC=0.2), log_buffer=True) with c.bash_console() as console: console.execute('df /bootflash/') self.assertIn('exit', c.spawn.match.match_output) self.assertIn('Router#', c.spawn.match.match_output) c.disconnect()
def test_bash(self): md = MockDeviceTcpWrapperIOSXE(port=0, state='stack_enable' + ',stack_enable'*4, stack=True) md.start() try: d = Connection(hostname='Router', start = ['telnet 127.0.0.1 ' + str(i) for i in md.ports[:]], os='iosxe', chassis_type='stack', username='******', tacacs_password='******', enable_password='******') d.connect() with d.bash_console() as console: console.execute('df /bootflash/') self.assertIn('exit', d.spawn.match.match_output) self.assertIn('Router#', d.spawn.match.match_output) d.disconnect() finally: md.stop()