示例#1
0
    def setUpClass(cls):
        cls.d = Connection(hostname='Router',
                           start=['mock_device_cli --os ios --state exec'],
                           os='ios',
                           enable_password='******',
                           username='******',
                           tacacs_password='******',
                           service_attributes=dict(ping=dict(timeout=2468)))
        cls.d.connect()
        cls.md = MockDevice(device_os='ios', state='exec')
        cls.ha = MockDeviceTcpWrapperIOS(port=0, state='login,exec_standby')

        # Add command output with 80K lines
        cls.ha.mockdevice.mock_data['enable']['commands']['show ospf dummy'] = \
        "123.123.123.123     123.123.123.123 1000        0x80000003 0x000000 0\n" * 80000

        cls.ha.start()
        cls.ha_device = Connection(
            hostname='Router',
            start=[
                'telnet 127.0.0.1 ' + str(cls.ha.ports[0]),
                'telnet 127.0.0.1 ' + str(cls.ha.ports[1])
            ],
            os='ios',
            username='******',
            tacacs_password='******',
            enable_password='******')
        cls.ha_device.connect()
        cls.logfile_testfile = '/tmp/test_log_file.log'
 def setUp(self):
     self.md = MockDevice(device_os='sros', state='execute')
     self.joined = lambda string: '\n'.join(string.splitlines())
     self.con = Connection(
         os='sros',
         hostname='COTKON04XR2',
         start=['mock_device_cli --os sros --state connect_ssh'],
         credentials={'default': {'username': '******', 'password': '******'}}
     )
     self.con.connect()
示例#3
0
 def test_learn_hostname_default(self):
     c = Connection(hostname='Router',
                    start=['mock_device_cli --os ios --state exec'],
                    os='ios',
                    enable_password='******',
                    username='******',
                    tacacs_password='******',
                    learn_hostname=True)
     c.settings.TERM = 'vt100'
     c.connect()
     md = MockDevice(device_os='ios', state='exec')
     expected_output = md.mock_data['exec']['commands'][
         'show version'].rstrip()
     output = c.execute('show version').replace('\r', '')
     self.assertEqual(output, expected_output)
示例#4
0
 def setUpClass(cls):
     cls.d = Connection(hostname='Router',
                        start=['mock_device_cli --os ios --state exec'],
                        os='ios',
                        enable_password='******',
                        username='******',
                        tacacs_password='******')
     cls.d.connect()
     cls.md = MockDevice(device_os='ios', state='exec')
     cls.ha = MockDeviceTcpWrapperIOS(port=0, state='login,exec_standby')
     cls.ha.start()
     cls.ha_device = Connection(
         hostname='Router',
         start=[
             'telnet 127.0.0.1 ' + str(cls.ha.ports[0]),
             'telnet 127.0.0.1 ' + str(cls.ha.ports[1])
         ],
         os='ios',
         username='******',
         tacacs_password='******',
         enable_password='******')
     cls.ha_device.connect()