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

Support for AlaxalA AX switch series #3411

Closed
wants to merge 4 commits into from

Conversation

inaba-vdom-0
Copy link
Contributor

I further added support for the AlaxalA AX switch series.
https://www.alaxala.com/en/

Only AX3600S series and AX2600S series box switches are supported by this code.
Some command structures are different for chassis-type switches.

Test configuration:

test_devices.yml

alaxala_ax36s:
  device_type: alaxala_ax36s
  ip: 192.168.1.30
  username: test
  password: test
  secret: test

commands.yml

alaxala_ax36s:
  version: "show version"
  basic: "show ip interface up"
  extended_output: "show system"   # requires paging to be disabled
  config: 
    - "logging facility local0"      # base command
    - "no logging facility"
    - "logging facility local1"      # something you can verify has changed
  config_verification: "show running-config"
  config_file: "alaxala_ax36s_commands.txt"
  save_config_cmd: 'write'
  save_config_confirm: False
  save_config_response: ""

responses.yml

alaxala_ax36s:
  base_prompt: "switch"
  router_prompt : "!switch>"
  enable_prompt: "!switch#"
  interface_ip: 192.168.1.30
  version_banner: "Model: AX"
  multiple_line_output: "Device resources"
  file_check_cmd: "switchport access vlan 2"
  save_config: ''

alaxala_ax36s_commands.txt

interface gigabitethernet 0/2
 switchport access vlan 2
 shutdown
 no shutdown

This code is based on the class CiscoBaseConnection because the prompt output from the device resembles Cisco IOS.
However, when modifying the configuration, an "!" is outputted at the beginning of the prompt.
Therefore, the acquisition of base_prompt is adjusted.

example_device_output.log

switch(config)# interface gigabitethernet 0/2
switch(config-if)#  shutdown
!switch(config-if)#  no shutdown
!switch(config-if)# 

I will send the test results.
test_result.log

(netmiko-py3.10) vd-0@test-vm:~/dev-1/netmiko/tests/test_alaxala_ax36s$ ./test_alaxala_.sh
Starting tests...good luck:
AlaxalA AX Seriex
============================= test session starts ==============================
platform linux -- Python 3.10.12, pytest-7.1.2, pluggy-1.3.0 -- /home/vd-0/dev-1/netmiko/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/vd-0/dev-1/netmiko, configfile: setup.cfg
plugins: pylama-8.3.8
collected 25 items                                                             

test_netmiko_show.py::test_failed_key SKIPPED (Not using SSH-keys)
test_netmiko_show.py::test_disable_paging PASSED
test_netmiko_show.py::test_terminal_width PASSED
test_netmiko_show.py::test_ssh_connect PASSED
test_netmiko_show.py::test_ssh_connect_cm PASSED
test_netmiko_show.py::test_send_command_timing PASSED
test_netmiko_show.py::test_send_command_timing_no_cmd_verify SKIPPED
test_netmiko_show.py::test_send_command PASSED
test_netmiko_show.py::test_send_command_no_cmd_verify SKIPPED
test_netmiko_show.py::test_complete_on_space_disabled SKIPPED
test_netmiko_show.py::test_send_command_textfsm SKIPPED (TextFSM/ntc...)
test_netmiko_show.py::test_send_command_ttp SKIPPED (TTP template no...)
test_netmiko_show.py::test_send_command_genie SKIPPED (Genie not sup...)
test_netmiko_show.py::test_send_multiline_timing SKIPPED
test_netmiko_show.py::test_send_multiline SKIPPED
test_netmiko_show.py::test_send_multiline_prompt SKIPPED
test_netmiko_show.py::test_send_multiline_simple SKIPPED
test_netmiko_show.py::test_base_prompt PASSED
test_netmiko_show.py::test_strip_prompt PASSED
test_netmiko_show.py::test_strip_command PASSED
test_netmiko_show.py::test_normalize_linefeeds PASSED
test_netmiko_show.py::test_clear_buffer PASSED
test_netmiko_show.py::test_enable_mode PASSED
test_netmiko_show.py::test_disconnect PASSED
test_netmiko_show.py::test_disconnect_no_enable SKIPPED

=========================== 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
======================= 13 passed, 12 skipped in 27.71s ========================
============================= test session starts ==============================
platform linux -- Python 3.10.12, pytest-7.1.2, pluggy-1.3.0 -- /home/vd-0/dev-1/netmiko/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/vd-0/dev-1/netmiko, configfile: setup.cfg
plugins: pylama-8.3.8
collected 13 items                                                             

test_netmiko_config.py::test_ssh_connect PASSED
test_netmiko_config.py::test_enable_mode PASSED
test_netmiko_config.py::test_config_mode PASSED
test_netmiko_config.py::test_exit_config_mode PASSED
test_netmiko_config.py::test_config_set PASSED
test_netmiko_config.py::test_config_set_generator PASSED
test_netmiko_config.py::test_config_set_longcommand PASSED
test_netmiko_config.py::test_config_hostname PASSED
test_netmiko_config.py::test_config_from_file PASSED
test_netmiko_config.py::test_config_error_pattern SKIPPED (No error_...)
test_netmiko_config.py::test_banner SKIPPED (No banner defined.)
test_netmiko_config.py::test_global_cmd_verify SKIPPED (No banner de...)
test_netmiko_config.py::test_disconnect PASSED

=========================== short test summary info ============================
SKIPPED [1] test_netmiko_config.py:175: No error_pattern defined.
SKIPPED [1] test_netmiko_config.py:209: No banner defined.
SKIPPED [1] test_netmiko_config.py:242: No banner defined.
=================== 10 passed, 3 skipped in 77.68s (0:01:17) ===================
(netmiko-py3.10) vd-0@test-vm:~/dev-1/netmiko/tests/test_alaxala_ax36s$ 

I also conducted tests for autodetection.

  • sample code
    test-code-autodetect.py
from netmiko.ssh_autodetect import SSHDetect
from netmiko.ssh_dispatcher import ConnectHandler
import logging

logging.basicConfig(filename="netmiko_test-code.log", level=logging.DEBUG)
logger = logging.getLogger("netmiko")

remote_device = {
    "ip": "192.168.1.30",
    "username": "test",
    "password": "test",
    "secret": "test",
    "device_type": "autodetect",
    "global_delay_factor": 3,
    "session_log": "test-code.log",
    "fast_cli": False,
}

guesser = SSHDetect(**remote_device)
best_match = guesser.autodetect()
print(best_match)
print(guesser.potential_matches)

remote_device["device_type"] = best_match
connection = ConnectHandler(**remote_device)

enable = connection.enable()

result = connection.send_command(command_string="show version")
print(result)

config = connection.config_mode()
print(config)

configure = connection.send_config_from_file(
    "./tests/test_alaxala_ax36s/alaxala_ax36s_commands.txt")
indent = connection.send_command('\n')
print(configure)

save = connection.save_config()
print(save)

showrun = connection.send_command('show running-config')
print(showrun)

connection.disconnect()

terminal_output.log

vd-0@test-vm:~/dev-1/netmiko$ /home/vd-0/dev-1/netmiko/.venv/bin/python /home/vd-0/dev-1/netmiko/tests/test_alaxala_ax36s/test-code-autodetect.py
alaxala_ax36s
{'alaxala_ax36s': 99}
Date 2000/01/04 20:35:04 UTC
Model: AX3640S-24T
S/W: OS-L3A Ver. 11.14.S 
H/W: AX-3640-24TE-A [---masked---]
configure terminal
switch(config)# 
interface gigabitethernet 0/2
switch(config-if)#  switchport access vlan 2
switch(config-if)#  shutdown
!switch(config-if)#  no shutdown
!switch(config-if)# end
Unsaved changes found! Do you exit "configure" without save ? (y/n): y
!switch# 
write
switch(config)# 
switch(config)# 
#Last modified by test at Tue Jan  4 20:35:29 2000 with version 11.14.S
!
hostname "switch"
!
vlan 1
  name "VLAN0001"
!
vlan 2
!
vlan 10
!
spanning-tree mode pvst
!
interface gigabitethernet 0/1
  media-type rj45
  switchport mode access
  switchport access vlan 10
!
interface gigabitethernet 0/2
  switchport mode access
  switchport access vlan 2
!
interface gigabitethernet 0/3
  switchport mode access
!
interface gigabitethernet 0/4
  switchport mode access
!
interface gigabitethernet 0/5
  switchport mode access
!
interface gigabitethernet 0/6
  switchport mode access
!
interface gigabitethernet 0/7
  switchport mode access
!
interface gigabitethernet 0/8
  switchport mode access
!
interface gigabitethernet 0/9
  switchport mode access
!
interface gigabitethernet 0/10
  switchport mode access
!
interface gigabitethernet 0/11
  switchport mode access
!
interface gigabitethernet 0/12
  switchport mode access
!
interface gigabitethernet 0/13
  switchport mode access
!
interface gigabitethernet 0/14
  switchport mode access
!
interface gigabitethernet 0/15
  switchport mode access
!
interface gigabitethernet 0/16
  switchport mode access
!
interface gigabitethernet 0/17
  switchport mode access
!
interface gigabitethernet 0/18
  switchport mode access
!
interface gigabitethernet 0/19
  switchport mode access
!
interface gigabitethernet 0/20
  switchport mode access
!
interface gigabitethernet 0/21
  switchport mode access
!
interface gigabitethernet 0/22
  switchport mode access
!
interface gigabitethernet 0/23
  switchport mode access
!
interface gigabitethernet 0/24
  switchport mode access
!
interface vlan 1
!
interface vlan 10
  ip address 192.168.1.30 255.255.255.0
!
logging facility local1
!
username test view-class allcommand
!
line vty 0 15
  transport input all
!
ip ssh
ip ssh version 2
!

I look forward to having these codes reviewed.
Thank you!

@ktbyers
Copy link
Owner

ktbyers commented Jul 10, 2024

Superseded by #3462

@ktbyers ktbyers closed this Jul 10, 2024
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.

2 participants