Refactor Qtech model to utilize centralized VLAN range expansion utility

- Replaced the internal `_expand_vlan_range` function in the `Qtech` class with the new `expand_vlan_range` utility from `utils.py` for improved code maintainability.
- Added new configuration files `config_1.conf` and `config_2.conf` for Qtech devices to facilitate testing.
- Introduced expected output JSON files `config_1.expected.json` and `config_2.expected.json` to validate the parsing of Qtech configurations against expected results.
This commit is contained in:
IluaAir
2026-06-07 08:47:08 +03:00
parent 1bc01c9c1b
commit 0ef5e7798a
5 changed files with 450 additions and 41 deletions

42
tests/fixtures/qtech/config_1.conf vendored Normal file
View File

@@ -0,0 +1,42 @@
! QTECH LLC Internetwork Operating System Software
! QSW-8330-40T-DC Series Software, Version 2.2.0C Build 96279, RELEASE SOFTWARE
! ROM: System Bootstrap, Version 0.4.7,hardware version:A
! Serial num:6060606060606060, ID num:555555555555
! System image file is "Switch.bin"
! QTECH LLC QSW-8330-40T-DC RISC
! 524288K bytes of memory,16384K bytes of flash
! Base ethernet MAC Address: 08:c6:b3:08:cf:ff
! snmp info:
! vend_ID:27514 product_ID:404 system_ID:1.3.6.1.4.1.27514
interface GigaEthernet1/0/9
shutdown
description FREE
switchport pvid 102
storm-control broadcast threshold 15
storm-control broadcast action shutdown
storm-control broadcast auto_resume 60s
storm-control multicast threshold 10
storm-control multicast action shutdown
storm-control multicast auto_resume 60s
qos policy IPP3 ingress
!
interface VLAN1
ip address 192.168.0.1 255.255.0.0
ip mtu 1500
no ip directed-broadcast
!
interface VLAN1002
description test-1002
ip address 13.36.8.1 255.255.255.0
ip mtu 1500
no ip directed-broadcast
!
vlan 772
name test
!
vlan 888
name test_super
!
vlan 1,7,14-15,44,101-102,115,117-124,130-136,139,167,200-205,772
,1607
vlan 888,2016,2085-2088

View File

@@ -0,0 +1,185 @@
{
"system": {
"model": "QSW-8330-40T-DC",
"serial_number": "6060606060606060",
"version": "96279"
},
"interfaces": [
{
"interface": "GigaEthernet1/0/9",
"ip_address": null,
"mask": null,
"description": "FREE"
},
{
"interface": "VLAN1",
"ip_address": "192.168.0.1",
"mask": 16,
"description": null
},
{
"interface": "VLAN1002",
"ip_address": "13.36.8.1",
"mask": 24,
"description": "test-1002"
}
],
"vlans": [
{
"vlan_id": 772,
"description": "test"
},
{
"vlan_id": 888,
"description": "test_super"
},
{
"vlan_id": 1,
"description": null
},
{
"vlan_id": 7,
"description": null
},
{
"vlan_id": 14,
"description": null
},
{
"vlan_id": 15,
"description": null
},
{
"vlan_id": 44,
"description": null
},
{
"vlan_id": 101,
"description": null
},
{
"vlan_id": 102,
"description": null
},
{
"vlan_id": 115,
"description": null
},
{
"vlan_id": 117,
"description": null
},
{
"vlan_id": 118,
"description": null
},
{
"vlan_id": 119,
"description": null
},
{
"vlan_id": 120,
"description": null
},
{
"vlan_id": 121,
"description": null
},
{
"vlan_id": 122,
"description": null
},
{
"vlan_id": 123,
"description": null
},
{
"vlan_id": 124,
"description": null
},
{
"vlan_id": 130,
"description": null
},
{
"vlan_id": 131,
"description": null
},
{
"vlan_id": 132,
"description": null
},
{
"vlan_id": 133,
"description": null
},
{
"vlan_id": 134,
"description": null
},
{
"vlan_id": 135,
"description": null
},
{
"vlan_id": 136,
"description": null
},
{
"vlan_id": 139,
"description": null
},
{
"vlan_id": 167,
"description": null
},
{
"vlan_id": 200,
"description": null
},
{
"vlan_id": 201,
"description": null
},
{
"vlan_id": 202,
"description": null
},
{
"vlan_id": 203,
"description": null
},
{
"vlan_id": 204,
"description": null
},
{
"vlan_id": 205,
"description": null
},
{
"vlan_id": 1607,
"description": null
},
{
"vlan_id": 2016,
"description": null
},
{
"vlan_id": 2085,
"description": null
},
{
"vlan_id": 2086,
"description": null
},
{
"vlan_id": 2087,
"description": null
},
{
"vlan_id": 2088,
"description": null
}
]
}

36
tests/fixtures/qtech/config_2.conf vendored Normal file
View File

@@ -0,0 +1,36 @@
! QTECH LLC Internetwork Operating System Software
! QSW-8330-40T-DC Series Software, Version 2.2.0C Build 96279, RELEASE SOFTWARE
! ROM: System Bootstrap, Version 0.4.7,hardware version:A
! Serial num:6060606060606060, ID num:555555555555
! System image file is "Switch.bin"
! QTECH LLC QSW-8330-40T-DC RISC
! 524288K bytes of memory,16384K bytes of flash
! Base ethernet MAC Address: 08:c6:b3:08:cf:f7
! snmp info:
! vend_ID:27514 product_ID:404 system_ID:1.3.6.1.4.1.27514
interface GigaEthernet1/0/9
shutdown
description FREE
switchport pvid 102
storm-control broadcast threshold 15
storm-control broadcast action shutdown
storm-control broadcast auto_resume 60s
storm-control multicast threshold 10
storm-control multicast action shutdown
storm-control multicast auto_resume 60s
qos policy IPP3 ingress
!
interface VLAN1
ip address 192.168.0.1 255.255.0.0
ip mtu 1500
no ip directed-broadcast
!
interface VLAN1002
description test-1002
ip address 13.36.8.1 255.255.255.0
ip mtu 1500
no ip directed-broadcast
!
vlan 1,7,14-15,44,101-102,115,117-124,130-136,139,167,200-205,772
,1607
vlan 888,2016,2085-2088

View File

@@ -0,0 +1,185 @@
{
"system": {
"model": "QSW-8330-40T-DC",
"serial_number": "6060606060606060",
"version": "96279"
},
"interfaces": [
{
"interface": "GigaEthernet1/0/9",
"ip_address": null,
"mask": null,
"description": "FREE"
},
{
"interface": "VLAN1",
"ip_address": "192.168.0.1",
"mask": 16,
"description": null
},
{
"interface": "VLAN1002",
"ip_address": "13.36.8.1",
"mask": 24,
"description": "test-1002"
}
],
"vlans": [
{
"vlan_id": 1,
"description": null
},
{
"vlan_id": 7,
"description": null
},
{
"vlan_id": 14,
"description": null
},
{
"vlan_id": 15,
"description": null
},
{
"vlan_id": 44,
"description": null
},
{
"vlan_id": 101,
"description": null
},
{
"vlan_id": 102,
"description": null
},
{
"vlan_id": 115,
"description": null
},
{
"vlan_id": 117,
"description": null
},
{
"vlan_id": 118,
"description": null
},
{
"vlan_id": 119,
"description": null
},
{
"vlan_id": 120,
"description": null
},
{
"vlan_id": 121,
"description": null
},
{
"vlan_id": 122,
"description": null
},
{
"vlan_id": 123,
"description": null
},
{
"vlan_id": 124,
"description": null
},
{
"vlan_id": 130,
"description": null
},
{
"vlan_id": 131,
"description": null
},
{
"vlan_id": 132,
"description": null
},
{
"vlan_id": 133,
"description": null
},
{
"vlan_id": 134,
"description": null
},
{
"vlan_id": 135,
"description": null
},
{
"vlan_id": 136,
"description": null
},
{
"vlan_id": 139,
"description": null
},
{
"vlan_id": 167,
"description": null
},
{
"vlan_id": 200,
"description": null
},
{
"vlan_id": 201,
"description": null
},
{
"vlan_id": 202,
"description": null
},
{
"vlan_id": 203,
"description": null
},
{
"vlan_id": 204,
"description": null
},
{
"vlan_id": 205,
"description": null
},
{
"vlan_id": 772,
"description": null
},
{
"vlan_id": 1607,
"description": null
},
{
"vlan_id": 888,
"description": null
},
{
"vlan_id": 2016,
"description": null
},
{
"vlan_id": 2085,
"description": null
},
{
"vlan_id": 2086,
"description": null
},
{
"vlan_id": 2087,
"description": null
},
{
"vlan_id": 2088,
"description": null
}
]
}