def test_attach(self):
     c = Connection(
         hostname='LEAF',
         start=[
             'mock_device_cli --os nxos --state n9k_login --hostname LEAF'
         ],
         os='nxos',
         platform='aci',
         tacacs_password='******')
     c.connect()
     with c.attach(1) as mod:
         mod.execute('')
     c.disconnect()
    def test_attach_console_lc0(self):
        conn = Connection(
            hostname='Router',
            start=['mock_device_cli --os iosxr --state spitfire_enable'],
            os='iosxr',
            platform='spitfire',
            mit=True)

        conn.connect()
        with conn.attach('0/0/CPU0') as console:
            out = console.execute('ls')
            self.assertIn('dummy_file', out)
        ret = conn.spawn.match.match_output
        self.assertIn('exit\r\nlogout\r\nRP/0/RP0/CPU0:Router#', ret)
예제 #3
0
    def test_attach_module(self):
        c = Connection(
            hostname='switch',
            start=['mock_device_cli --os nxos --state exec'],
            os='nxos',
            credentials=dict(default=dict(username='******', password='******')),
            init_exec_commands=[],
            init_config_commands=[])

        with c.attach(1) as m:
            m.execute('debug platform internal tah elam asic 0',
                      allow_state_change=True)
            m.execute(
                'trigger init asic 0 slice 2 lu-a2d 1 in-select 9 out-select 1 use-src-id 25',
                allow_state_change=True)
            m.execute('set outer ipv4 dst_ip 225.1.1.1 src_ip 11.2.1.100')
        self.assertEqual(c.state_machine.current_state, 'enable')
        c.disconnect()