selfuryon / netdev

Asynchronous multi-vendor library for interacting with network devices
http://netdev.readthedocs.io/
Apache License 2.0
213 stars 45 forks source link

Connecting to ASA Timeout #26

Closed anknarang closed 5 years ago

anknarang commented 5 years ago

Hi,

I am able to connect device manually. but using netdev. I am getting Timeout. do i increase any timeout value in script ? if yes , how ?. Enable password is same. device are in active/standby.

enable mode prompt looks like this. We don't have any context

Hostname/pri/act>

Task exception was never retrieved future: <Task finished coro=<backup_config() done, defined at C:/Users/anarang/PycharmProjects/lambda/lambda-asa.py:10> exception=TimeoutError('Host 10.33.224.19 Timeout Error')> Traceback (most recent call last): File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\base.py", line 243, in _read_until_pattern output += await asyncio.wait_for(fut, self._timeout) File "C:\Users\anarang\AppData\Local\Programs\Python\Python37\lib\asyncio\tasks.py", line 419, in wait_for raise futures.TimeoutError() concurrent.futures._base.TimeoutError

raceback (most recent call last): File "C:/Users/anarang/PycharmProjects/lambda/lambda-asa.py", line 13, in backup_config await io.connect() File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\cisco\cisco_asa.py", line 54, in connect await self.enable_mode() File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\ios_like.py", line 100, in enable_mode output += await self._read_until_prompt() File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\base.py", line 231, in _read_until_prompt return await self._read_until_pattern(self._base_pattern) File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\base.py", line 245, in _read_until_pattern raise TimeoutError(self._host) netdev.exceptions.TimeoutError: Host 10.33.224.19 Timeout Error Task exception was never retrieved future: <Task finished coro=<backup_config() done, defined at C:/Users/anarang/PycharmProjects/lambda/lambda-asa.py:10> exception=TimeoutError('Host 10.33.224.18 Timeout Error')> Traceback (most recent call last): File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\base.py", line 243, in _read_until_pattern output += await asyncio.wait_for(fut, self._timeout) File "C:\Users\anarang\AppData\Local\Programs\Python\Python37\lib\asyncio\tasks.py", line 419, in wait_for raise futures.TimeoutError() concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/anarang/PycharmProjects/lambda/lambda-asa.py", line 13, in backup_config await io.connect() File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\cisco\cisco_asa.py", line 54, in connect await self.enable_mode() File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\ios_like.py", line 100, in enable_mode output += await self._read_until_prompt() File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\base.py", line 231, in _read_until_prompt return await self._read_until_pattern(self._base_pattern) File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\base.py", line 245, in _read_until_pattern raise TimeoutError(self._host) netdev.exceptions.TimeoutError: Host 10.33.224.18 Timeout Error

During handling of the above exception, another exception occurred:

anknarang commented 5 years ago

I also tested on standalone ASA with hostname cisco and enabled the deubug but same timeout issue.

Host 10.6.127.12: Trying to connect to the device Host 10.6.127.12: Establishing connection to port 22 Host 10.6.127.12: Connection is established Host 10.6.127.12: Reading until pattern Host 10.6.127.12: Setting base prompt Host 10.6.127.12: Finding prompt Host 10.6.127.12: Reading until pattern Host 10.6.127.12: Connection is established Host 10.6.127.12: Reading until pattern Host 10.6.127.12: Setting base prompt Host 10.6.127.12: Finding prompt Host 10.6.127.12: Reading until pattern Host 10.6.127.12: Entering to privilege exec Host 10.6.127.12: Checking privilege exec Host 10.6.127.12: Reading until pattern Host 10.6.127.12: Entering to privilege exec Host 10.6.127.12: Checking privilege exec Host 10.6.127.12: Reading until pattern Host 10.6.127.12: Reading until prompt or pattern Host 10.6.127.12: Reading until prompt or pattern Host 10.6.127.12: Reading until pattern Host 10.6.127.12: Reading until pattern Task exception was never retrieved Task exception was never retrieved future: <Task finished coro=<backup_config() done, defined at C:/Users/anarang/PycharmProjects/lambda/lambda-asa.py:17> exception=TimeoutError('Host 10.6.127.12 Timeout Error')> Traceback (most recent call last): File "C:\Users\anarang\PycharmProjects\venv\lib\site-packages\netdev\vendors\base.py", line 243, in _read_until_pattern output += await asyncio.wait_for(fut, self._timeout) File "C:\Users\anarang\AppData\Local\Programs\Python\Python37\lib\asyncio\tasks.py", line 419, in wait_for raise futures.TimeoutError() concurrent.futures._base.TimeoutError

selfuryon commented 5 years ago

There is no need to use timeouts in this case, because my library doesn't use it for waiting for the prompt. You can get more details in #10 issue. But if talking about your case: it's interesting and unusual. I've just tested it in my production environment and all works fine. So can you share your example code and example config? You can send me it privately in telegram or in my email.

anknarang commented 5 years ago

Thanks for replying.

where can i find your email ?

Thanks

selfuryon commented 5 years ago

Hello! My email is selfuryon@gmail.com

anknarang commented 5 years ago

Sent you email. please check

selfuryon commented 5 years ago

Hello! Yeah, I got all debug files, thank you! I'll try to investigate it tomorrow

anknarang commented 5 years ago

Thank you

anknarang commented 5 years ago

Hi,

Please can you let me know if you get chance to look. This is blocker for us. Nxos is working but due to ASA having issue. We need to decide in library As we want to use only one library for all of them.

Thank you

selfuryon commented 5 years ago

Hello! Sorry for a long time answer. I think the problem is in your init function: I found that you entered to an unprivileged mode, but you don't provide a secret password for entering a privileged mode. You should use secret param for that:

host = {'host':'x.x.x.x',
             'username':'admin', 
             'password':'x.x.x.x', 
             'secret':'x.x.x.x', 
             'device_type':'cisco_asa'}

Try it, it should work fine!

selfuryon commented 5 years ago

I've just tested it in my test environment and can confirm that it's the reason, But it's not desirable, we should get other exception. I will fix it

anknarang commented 5 years ago

yeah. it working. Thanks for helping out. I did not see this in any example or Doc. I might missed out.

Thank you.....

selfuryon commented 5 years ago

Yes, I have some problems with docs after I changed the structure of the project. Need to correct it #28