Code dup
Description
code refactoring:
-
added new module
connection: which has the protocol connection classes likessh,telnetandserial. this approach is needed to split the business logic from external libraries , so we can easily change libraries without changing our code. also this is needed to add different connection types. -
added
terminal_modesmodule: objects that handle entering and exiting from different terminal modes likeconfig_mode,enable_mode... etc. this approach is to eliminate code duplication in theDevicesclasses.
those are the major changes, there are some changes on the device level, like adding methods, removing methods ... etc.
a new main method added to BaseDevice is _session_preparation , which will be called to prepare each device session.
new features:
- telnet support.
- textfsm.
Thank you for refactoring the code! I'm going to test it this weekend and plan to merge it on Monday if all is fine!
Thanks, please note that this pr has vt100 as term_mod, you can change it from constants.py module.
If I have any problems with that on Mikrotik I think I change it only for Mikrotik. I test it separately. Thank you for the information!
@selfuryon please have a look at the updated pr.
you need to pip install textfsm before running the code, i could not find requirements.txt file to add it.
@selfuryon please have a look at the updated pr. you need to
pip install textfsmbefore running the code, I could not findrequirements.txtfile to add it.
Yeah, I switched to use poetry for building the project and for dependency management. You can add it to pyproject.toml. This file is used not only poetry right now. You can find more information about that in PEP517 and PEP518
Thanks for new commits! I'll check it more deeply tomorrow!
please check updated pr
I have some problems with HP Comware in testing. Need to go deeper
Hello! I think for more than 2 weeks about the structure of code from this PR. It's a good new structure and new approaches but it still has some lack of isolation which can confuse.
As example:
- We have a duplication for device hierarchy in
vendorandterminal_modesfolders: both have cisco, hp, and others - Terminal modes classes have a link to a device class and vice versa. They call the other one in their work
- There are exist a
send_commandin both classesterminal modeanddevice - All constants for terminal modes still are included in the device class
- Device class tracks current terminal mode
- We still have a three level of inheritance
So I decided to get your idea, take some techniques and class and make a refactor for the module in a slight different another way (see #34)
make sense, looking forward to see the new structure.
is there any way to get structured output using asyncssh netdev library? it seems asyncio is not compatible with netconf? Please provide a way to get structured output using asyncio netdev. I am trying to run this on Juniper vMX devices