Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Cisco AP to Device Types #3151

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

Niltak
Copy link
Contributor

@Niltak Niltak commented Mar 29, 2023

Adding cisco_ap to supported device types. Tested on models 3700, 3800, and 9100 WAPs.

Example banner:

             Restricted Rights Legend

Use, duplication, or disclosure by the Government is subject to
restrictions as set forth in subparagraph (c) of the Commercial
Computer Software - Restricted Rights clause at FAR sec. 52.227-19 and
subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer
Software clause at DFARS sec. 252.227-7013.

            Cisco Systems, Inc.
            170 West Tasman Drive
            San Jose, California 95134-1706

This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to
[email protected].

This product contains some software licensed under the
"GNU General Public License, version 2" provided with
ABSOLUTELY NO WARRANTY under the terms of
"GNU General Public License, version 2", available here:
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html

This product contains some software licensed under the
"GNU Library General Public License, version 2" provided
with ABSOLUTELY NO WARRANTY under the terms of "GNU Library
General Public License, version 2", available here:
http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html

This product contains some software licensed under the
"GNU Lesser General Public License, version 2.1" provided
with ABSOLUTELY NO WARRANTY under the terms of "GNU Lesser
General Public License, version 2.1", available here:
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html

This product contains some software licensed under the 
"GNU General Public License, version 3" provided with 
ABSOLUTELY NO WARRANTY under the terms of  
"GNU General Public License, Version 3", available here: 
http://www.gnu.org/licenses/gpl.html.

This product contains some software licensed under the
"GNU Affero General Public License, version 3" provided
with ABSOLUTELY NO WARRANTY under the terms of
"GNU Affero General Public License, version 3", available here:
http://www.gnu.org/licenses/agpl-3.0.html.

Cisco AP Software, (ap3g3), C3802, RELEASE SOFTWARE
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2023 by Cisco Systems, Inc.
Compiled Wed Nov 10 08:49:19 GMT 2021

ROM: Bootstrap program is U-Boot boot loader
BOOTLDR: U-Boot boot loader Version 2013.01-gcb01933d4 (Nov 10 2020 - 23:41:12)

{{ REDACTED }}

Updated test example and below is the results.

Test Results:

============================================================================= test session starts ==============================================================================
platform linux -- Python 3.9.13, pytest-7.2.2, pluggy-1.0.0 -- /usr/bin/python3.9
cachedir: .pytest_cache
rootdir: /netmiko2, configfile: setup.cfg
collected 25 items                                                                                                                                                             

test_netmiko_show.py::test_failed_key SKIPPED (Not using SSH-keys)                                                                                                       [  4%]
test_netmiko_show.py::test_disable_paging PASSED                                                                                                                         [  8%]
test_netmiko_show.py::test_terminal_width PASSED                                                                                                                         [ 12%]
test_netmiko_show.py::test_ssh_connect PASSED                                                                                                                            [ 16%]
test_netmiko_show.py::test_ssh_connect_cm PASSED                                                                                                                         [ 20%]
test_netmiko_show.py::test_send_command_timing PASSED                                                                                                                    [ 24%]
test_netmiko_show.py::test_send_command_timing_no_cmd_verify SKIPPED                                                                                                     [ 28%]
test_netmiko_show.py::test_send_command PASSED                                                                                                                           [ 32%]
test_netmiko_show.py::test_send_command_no_cmd_verify SKIPPED                                                                                                            [ 36%]
test_netmiko_show.py::test_complete_on_space_disabled SKIPPED                                                                                                            [ 40%]
test_netmiko_show.py::test_send_command_textfsm SKIPPED (TextFSM/ntc-templates not supported on this platform)                                                           [ 44%]
test_netmiko_show.py::test_send_command_ttp SKIPPED (TTP template not existing for this platform)                                                                        [ 48%]
test_netmiko_show.py::test_send_command_genie SKIPPED (Genie not supported on this platform)                                                                             [ 52%]
test_netmiko_show.py::test_send_multiline_timing SKIPPED                                                                                                                 [ 56%]
test_netmiko_show.py::test_send_multiline SKIPPED                                                                                                                        [ 60%]
test_netmiko_show.py::test_send_multiline_prompt SKIPPED                                                                                                                 [ 64%]
test_netmiko_show.py::test_send_multiline_simple SKIPPED                                                                                                                 [ 68%]
test_netmiko_show.py::test_base_prompt PASSED                                                                                                                            [ 72%]
test_netmiko_show.py::test_strip_prompt FAILED                                                                                                                           [ 76%]
test_netmiko_show.py::test_strip_command PASSED                                                                                                                          [ 80%]
test_netmiko_show.py::test_normalize_linefeeds PASSED                                                                                                                    [ 84%]
test_netmiko_show.py::test_clear_buffer PASSED                                                                                                                           [ 88%]
test_netmiko_show.py::test_enable_mode PASSED                                                                                                                            [ 92%]
test_netmiko_show.py::test_disconnect PASSED                                                                                                                             [ 96%]
test_netmiko_show.py::test_disconnect_no_enable SKIPPED                                                                                                                  [100%]

=================================================================================== FAILURES ===================================================================================
______________________________________________________________________________ test_strip_prompt _______________________________________________________________________________

net_connect = <netmiko.cisco.cisco_ios.CiscoIosSSH object at 0x7f1a002de6d0>
commands = {'basic': 'show ip interface brief', 'extended_output': 'show version', 'version': 'show version', 'wide_command': 'show configuration wlan myverybiglonglistthatdoesntexistandwherethisexceeds80characterssolinewrappingoccurs'}
expected_responses = {'base_prompt': 'ap01-test', 'enable_prompt': 'ap01-test#', 'interface_ip': '10.10.10.100', 'multiple_line_output': 'Cisco AP Software', ...}

    def test_strip_prompt(net_connect, commands, expected_responses):
        """Ensure the router prompt is not in the command output."""
    
        if expected_responses["base_prompt"] == "":
            return
        show_ip = net_connect.send_command_timing(commands["basic"])
        show_ip_alt = net_connect.send_command(commands["basic"])
>       assert expected_responses["base_prompt"] not in show_ip
E       AssertionError: assert 'ap01-test' not in 'Interface  ...1-EARTHCITY>'
E         'ap01-test' is contained here:
E           Interface            IP-Address      Method   Status                 Protocol   Speed      Duplex  
E           wired0               10.10.10.100    DHCP     up                     up         1000       full    
E           auxiliary-client     unassigned      unset    up                     up         n/a        n/a     
E           wifi0                n/a             n/a      up                     up         n/a        n/a     
E           wifi1                n/a             n/a      up                     up         n/a        n/a     
E           ...
E         
E         ...Full output truncated (2 lines hidden), use '-vv' to show

test_netmiko_show.py:321: AssertionError
=========================================================================== short test summary info ============================================================================
SKIPPED [1] test_netmiko_show.py:25: Not using SSH-keys
SKIPPED [1] test_netmiko_show.py:88: Skipped
SKIPPED [1] test_netmiko_show.py:106: Skipped
SKIPPED [1] test_netmiko_show.py:128: Skipped
SKIPPED [1] test_netmiko_show.py:149: TextFSM/ntc-templates not supported on this platform
SKIPPED [1] test_netmiko_show.py:171: TTP template not existing for this platform
SKIPPED [1] test_netmiko_show.py:211: Genie not supported on this platform
SKIPPED [1] test_netmiko_show.py:231: Skipped
SKIPPED [1] test_netmiko_show.py:247: Skipped
SKIPPED [1] test_netmiko_show.py:272: Skipped
SKIPPED [1] test_netmiko_show.py:296: Skipped
SKIPPED [1] test_netmiko_show.py:401: Skipped
================================================================== 1 failed, 12 passed, 12 skipped in 24.96s ===================================================================

@codekuu
Copy link
Contributor

codekuu commented Apr 21, 2023

To make the test go through change the base_prompt variable for cisco_ap to base_prompt: "auxiliary-client" in the response.yml file.

Please include py.test -v test_netmiko_config.py --test_device cisco_ap as well.

@Niltak
Copy link
Contributor Author

Niltak commented May 24, 2023

I don't see why changing the base_prompt to something else will help. I changed it anyway and got two other tests include strip prompt to fail.

I did deep dive the test and found that paramiko was duping the base prompt. So the strip is working just isn't striping twice. Here is the debug:

prdnetjump01:~/python/netmiko2/tests> py.test -v test_netmiko_show.py --test_device cisco_ap -vv
=================================================================================== test session starts ===================================================================================
platform linux -- Python 3.9.13, pytest-7.2.2, pluggy-1.0.0 -- /usr/bin/python3.9
cachedir: .pytest_cache
rootdir: /home/***/python/netmiko2, configfile: setup.cfg
collected 25 items                                                                                                                                                                        

test_netmiko_show.py::test_failed_key SKIPPED (Not using SSH-keys)                                                                                                                  [  4%]
test_netmiko_show.py::test_disable_paging PASSED                                                                                                                                    [  8%]
test_netmiko_show.py::test_terminal_width PASSED                                                                                                                                    [ 12%]
test_netmiko_show.py::test_ssh_connect PASSED                                                                                                                                       [ 16%]
test_netmiko_show.py::test_ssh_connect_cm PASSED                                                                                                                                    [ 20%]
test_netmiko_show.py::test_send_command_timing 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /home/***/python/netmiko2/tests/netmiko/base_connection.py(1521)send_command_timing()
-> output = self._sanitize_output(
(Pdb) output
'show ip interface brief\nInterface            IP-Address      Method   Status                 Protocol   Speed      Duplex  \nwired0               10.160.144.245  DHCP     up                     up         1000       full    \nauxiliary-client     unassigned      unset    up                     up         n/a        n/a     \nwifi0                n/a             n/a      up                     up         n/a        n/a     \nwifi1                n/a             n/a      up                     up         n/a        n/a     \n\nap01-test>\nap01-test>'
prdnetjump01:~/python/netmiko2/tests> py.test -v test_netmiko_show.py --test_device cisco_ap -vv
=================================================================================== test session starts ===================================================================================
platform linux -- Python 3.9.13, pytest-7.2.2, pluggy-1.0.0 -- /usr/bin/python3.9
cachedir: .pytest_cache
rootdir: /home/***/python/netmiko2, configfile: setup.cfg
collected 25 items                                                                                                                                                                        

test_netmiko_show.py::test_failed_key SKIPPED (Not using SSH-keys)                                                                                                                  [  4%]
test_netmiko_show.py::test_disable_paging PASSED                                                                                                                                    [  8%]
test_netmiko_show.py::test_terminal_width PASSED                                                                                                                                    [ 12%]
test_netmiko_show.py::test_ssh_connect PASSED                                                                                                                                       [ 16%]
test_netmiko_show.py::test_ssh_connect_cm PASSED                                                                                                                                    [ 20%]
test_netmiko_show.py::test_send_command_timing 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /home/***/python/netmiko2/tests/netmiko/base_connection.py(1518)send_command_timing()
-> output += self.read_channel_timing(
(Pdb) step
> /home/***/python/netmiko2/tests/netmiko/base_connection.py(1519)send_command_timing()
-> last_read=last_read, read_timeout=read_timeout
(Pdb) step
> /home/***/python/netmiko2/tests/netmiko/base_connection.py(1518)send_command_timing()
-> output += self.read_channel_timing(
(Pdb) step
--Call--
> /home/***/python/netmiko2/tests/netmiko/base_connection.py(704)read_channel_timing()
-> def read_channel_timing(
(Pdb) step
> /home/***/python/netmiko2/tests/netmiko/base_connection.py(737)read_channel_timing()
-> if delay_factor is not None or max_loops is not None:
(Pdb) step
> /home/***/python/netmiko2/tests/netmiko/base_connection.py(740)read_channel_timing()
-> if self.read_timeout_override:
...
... ## Lots and lots of step walking
...
(Pdb) step
> /home/***/.local/lib/python3.9/site-packages/paramiko/channel.py(705)recv()
-> if ack > 0:
(Pdb) step
> /home/***/.local/lib/python3.9/site-packages/paramiko/channel.py(712)recv()
-> return out
(Pdb) step
--Return--
> /home/***/.local/lib/python3.9/site-packages/paramiko/channel.py(712)recv()->b'Interface  ...01-test>'
-> return out
(Pdb) step
> /home/***/python/netmiko2/tests/netmiko/channel.py(83)read_buffer()
-> if len(outbuf) == 0:
(Pdb) outbuf
b'Interface            IP-Address      Method   Status                 Protocol   Speed      Duplex  \r\nwired0               10.160.144.245  DHCP     up                     up         1000       full    \r\nauxiliary-client     unassigned      unset    up                     up         n/a        n/a     \r\nwifi0                n/a             n/a      up                     up         n/a        n/a     \r\nwifi1                n/a             n/a      up                     up         n/a        n/a     \r\n\rap01-test>\rap01-test>'

Pre strip

Interface            IP-Address      Method   Status                 Protocol   Speed      Duplex  
wired0               10.160.144.245  DHCP     up                     up         1000       full    
auxiliary-client     unassigned      unset    up                     up         n/a        n/a     
wifi0                n/a             n/a      up                     up         n/a        n/a     
wifi1                n/a             n/a      up                     up         n/a        n/a     

ap01-test>
ap01-test>

After strip

E       AssertionError: assert 'ap01-test' not in 'Interface            IP-Address      Method   Status                 Protocol   Speed      Duplex  \nwired0               10.160.144.245  DHCP     up                     up         1000       full    \nauxiliary-client     unassigned      unset    up                     up         n/a        n/a     \nwifi0                n/a             n/a      up                     up         n/a        n/a     \nwifi1                n/a             n/a      up                     up         n/a        n/a     \n\nap01-test>'
E         'ap01-test' is contained here:
E           Interface            IP-Address      Method   Status                 Protocol   Speed      Duplex  
E           wired0               10.160.144.245  DHCP     up                     up         1000       full    
E           auxiliary-client     unassigned      unset    up                     up         n/a        n/a     
E           wifi0                n/a             n/a      up                     up         n/a        n/a     
E           wifi1                n/a             n/a      up                     up         n/a        n/a     
E           
E           ap01-test>

@Niltak
Copy link
Contributor Author

Niltak commented May 24, 2023

cisco_ap is set to no_config but here is the shorten results for test_netmiko_config:

prdnetjump01:~/python/netmiko2/tests> py.test -v test_netmiko_config.py --test_device cisco_ap
=================================================================================== test session starts ===================================================================================
platform linux -- Python 3.9.13, pytest-7.2.2, pluggy-1.0.0 -- /usr/bin/python3.9
cachedir: .pytest_cache
rootdir: /home/sampsoka1/python/netmiko2, configfile: setup.cfg
collected 13 items                                                                                                                                                                        

test_netmiko_config.py::test_ssh_connect PASSED                                                                                                                                     [  7%]
test_netmiko_config.py::test_enable_mode PASSED                                                                                                                                     [ 15%]
test_netmiko_config.py::test_config_mode SKIPPED (Platform doesn't support config mode.)                                                                                            [ 23%]
test_netmiko_config.py::test_exit_config_mode FAILED                                                                                                                                [ 30%]
test_netmiko_config.py::test_config_set FAILED                                                                                                                                      [ 38%]
test_netmiko_config.py::test_config_set_generator FAILED                                                                                                                            [ 46%]
test_netmiko_config.py::test_config_set_longcommand FAILED                                                                                                                          [ 53%]
test_netmiko_config.py::test_config_hostname PASSED                                                                                                                                 [ 61%]
test_netmiko_config.py::test_config_from_file FAILED                                                                                                                                [ 69%]
test_netmiko_config.py::test_config_error_pattern SKIPPED (No error_pattern defined.)                                                                                               [ 76%]
test_netmiko_config.py::test_banner SKIPPED (No banner defined.)                                                                                                                    [ 84%]
test_netmiko_config.py::test_global_cmd_verify SKIPPED (No banner defined.)                                                                                                         [ 92%]
test_netmiko_config.py::test_disconnect PASSED  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants