예제 #1
0
    def test_connect_mit_check_init_commands(self):
        c = Connection(hostname='Router',
                       start=['mock_device_cli --os ios --state login'],
                       os='ios',
                       username='******',
                       enable_password='******',
                       tacacs_password='******',
                       mit=True)

        c.setup_connection = Mock()
        c.state_machine = Mock()
        c.state_machine.states = []
        c.connection_provider = c.connection_provider_class(c)
        c.spawn = Mock()
        c.spawn.buffer = ''

        c.execute = Mock(side_effect=mock_execute)
        c.configure = Mock(side_effect=mock_configure)
        c.connect()
        assert c.execute.called == False, 'Execute was called unexpectedly'
        assert c.configure.called == False, 'Configure was called unexpectedly'
예제 #2
0
        _os = p.os
        if p.series:
            plugin_name += "/%s" % p.series
            series = p.series
        else:
            series = None

        try:
            c = Connection(hostname='Router',
                           start=['bash'],
                           os=_os,
                           series=series,
                           log_stdout=False)
            # c = Connection(hostname='Router', start=['bash'], os=_os, series=series)
            c.init_service()
            c.connection_provider = c.connection_provider_class(c)

        except:
            print('---------------- ERROR ---------------', file=sys.stderr)
            traceback.print_exc()
            print('--------------------------------------', file=sys.stderr)

        else:
            print('\n\n')
            print(plugin_name)
            print('-' * len(plugin_name) + '\n')

            print_dialogs('default', c.state_machine.default_dialog)

            print_dialogs('connect',
                          c.connection_provider.get_connection_dialog())