dev #3
@@ -14,11 +14,4 @@ class H3C(BaseDevice):
|
||||
vlans.append(item)
|
||||
continue
|
||||
vlans.extend({"vlan_id": vlan_id} for vlan_id in vlan_ids)
|
||||
return vlans
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open("./test5.txt") as file:
|
||||
data = file.read()
|
||||
h3c = H3C(data)
|
||||
print(h3c.parse())
|
||||
return vlans
|
||||
@@ -26,13 +26,13 @@ Active-image: {{ ignore }} {{ _start_ }}
|
||||
<group name="interfaces">
|
||||
interface {{ interface | ORPHRASE }}
|
||||
ip address {{ ip_address }} {{ mask | to_cidr }}
|
||||
name {{ description }}
|
||||
description {{ description }}
|
||||
name {{ description | ORPHRASE}}
|
||||
description {{ description | ORPHRASE }}
|
||||
</group>
|
||||
|
||||
<group name="vlans">
|
||||
interface vlan {{ vlan_id | _start_ }}
|
||||
name {{ name }}
|
||||
name {{ name | ORPHRASE }}
|
||||
|
||||
vlan {{ _db_ | _start_ }}
|
||||
vlan {{ vlan_ids | joinmatches(',') | unrange("-", ",") | split(",")}}
|
||||
|
||||
@@ -21,6 +21,7 @@ default_system = {
|
||||
|
||||
<group name="interfaces">
|
||||
interface {{ interface }}
|
||||
description {{ description | ORPHRASE }}
|
||||
ip address {{ ip_address }} {{ mask | to_cidr }}
|
||||
</group>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ default_system = {
|
||||
|
||||
<group name="interfaces">
|
||||
interface {{ interface }}
|
||||
description {{ description }}
|
||||
description {{ description | ORPHRASE }}
|
||||
ip address {{ ip_address }} {{ mask | to_cidr }}
|
||||
</group>
|
||||
<group name="vlans">
|
||||
|
||||
169
tests/fixtures/h3c/config.conf
vendored
Normal file
169
tests/fixtures/h3c/config.conf
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
# H3C Comware Software, Version 7.1.070, Release 6616P01
|
||||
# Copyright (c) 2004-2021 New H3C Technologies Co., Ltd. All rights reserved.
|
||||
# Last reboot reason : User reboot
|
||||
#
|
||||
# Boot image: flash:/s9820-cmw710-boot-r6616p01.bin
|
||||
# Boot image version: 7.1.070, Release 6616P01
|
||||
# Compiled May 06 2021 11:00:00
|
||||
# System image: flash:/s9820-cmw710-system-r6616p01.bin
|
||||
# System image version: 7.1.070, Release 6616P01
|
||||
# Compiled May 06 2021 11:00:00
|
||||
#
|
||||
#
|
||||
# MPU(M) Slot 1:
|
||||
# H3C S9820-64H MPU(M) with 1 C2538 Processor(s)
|
||||
# BOARD TYPE: S9820-64H
|
||||
# DRAM: 8192M bytes
|
||||
# FLASH: 3630M bytes
|
||||
# NVRAM: 0K bytes
|
||||
# PCB 1 Version: VER.A
|
||||
# PCB 2 Version: VER.B
|
||||
# PCB 3 Version: VER.A
|
||||
# PCB 4 Version: VER.A
|
||||
# Basic BootWare Version: 105
|
||||
# Extended BootWare Version: 108
|
||||
# CPLD 1 Version: 002
|
||||
# CPLD 2 Version: 027
|
||||
# CPLD 3 Version: 002
|
||||
# CPLD 4 Version: 002
|
||||
# FPGA 1 Version: 001
|
||||
# Release Version: H3C S9820-64H-6616P01
|
||||
# Patch Version: None
|
||||
# Reboot Cause: UserReboot
|
||||
# [SubSlot 0] 64QSFP28
|
||||
#
|
||||
# MPU(S) Slot 2:
|
||||
# H3C S9820-64H MPU(S) with 1 C2538 Processor(s)
|
||||
# BOARD TYPE: S9820-64H
|
||||
# DRAM: 8192M bytes
|
||||
# FLASH: 3630M bytes
|
||||
# NVRAM: 0K bytes
|
||||
# PCB 1 Version: VER.A
|
||||
# PCB 2 Version: VER.B
|
||||
# PCB 3 Version: VER.A
|
||||
# PCB 4 Version: VER.A
|
||||
# Basic BootWare Version: 105
|
||||
# Extended BootWare Version: 108
|
||||
# CPLD 1 Version: 002
|
||||
# CPLD 2 Version: 027
|
||||
# CPLD 3 Version: 002
|
||||
# CPLD 4 Version: 002
|
||||
# FPGA 1 Version: 001
|
||||
# Release Version: H3C S9820-64H-6616P01
|
||||
# Patch Version: None
|
||||
# Reboot Cause: IRFMergeReboot
|
||||
# [SubSlot 0] 64QSFP28
|
||||
# Slot Type State Subslot Soft Ver Patch Ver
|
||||
# 1 S9820-64H Master 0 S9820-64H-6616P01 None
|
||||
# 2 S9820-64H Standby 0 S9820-64H-6616P01 None
|
||||
#
|
||||
vlan 1
|
||||
#
|
||||
vlan 12
|
||||
name BGP to OSPF1
|
||||
#
|
||||
vlan 13
|
||||
name BGP to OSPF2
|
||||
#
|
||||
vlan 15
|
||||
name HW_TEST_1
|
||||
description HW_TEST_1
|
||||
#
|
||||
vlan 222
|
||||
name MGMT
|
||||
description MGMT
|
||||
#
|
||||
vlan 222
|
||||
#
|
||||
vlan 1112 to 1116
|
||||
#
|
||||
vlan 1122
|
||||
name DATA
|
||||
#
|
||||
vlan 1123
|
||||
#
|
||||
vlan 1200
|
||||
#
|
||||
vlan 1512
|
||||
#
|
||||
vlan 1513
|
||||
description cluster HW_TEST_1
|
||||
#
|
||||
vlan 2000
|
||||
description cluster HW_TEST_2
|
||||
#
|
||||
vlan 3377
|
||||
name VRF3377
|
||||
#
|
||||
irf-port 1/2
|
||||
port group interface HundredGigE1/0/63
|
||||
port group interface HundredGigE1/0/64
|
||||
#
|
||||
irf-port 2/1
|
||||
port group interface HundredGigE2/0/63
|
||||
port group interface HundredGigE2/0/64
|
||||
#
|
||||
interface Bridge-Aggregation1
|
||||
description HW_TEST_1
|
||||
port link-type trunk
|
||||
undo port trunk permit vlan 1
|
||||
port trunk permit vlan 221 1112 to 1116 1512 2000
|
||||
link-aggregation mode dynamic
|
||||
#
|
||||
interface Bridge-Aggregation2
|
||||
description HW_TEST_2
|
||||
port link-type trunk
|
||||
undo port trunk permit vlan 1
|
||||
port trunk permit vlan 221 1112 to 1116 1512
|
||||
link-aggregation mode dynamic
|
||||
#
|
||||
interface Bridge-Aggregation3
|
||||
description HW_TEST_3
|
||||
port link-type trunk
|
||||
undo port trunk permit vlan 1
|
||||
port trunk permit vlan 221 1112 to 1116 1512 2000
|
||||
link-aggregation mode dynamic
|
||||
#
|
||||
interface Bridge-Aggregation4
|
||||
description HW_TEST_4
|
||||
port link-type trunk
|
||||
undo port trunk permit vlan 1
|
||||
port trunk permit vlan 221 1112 to 1116 1512
|
||||
link-aggregation mode dynamic
|
||||
#
|
||||
interface NULL0
|
||||
#
|
||||
interface Vlan-interface1
|
||||
dhcp client identifier ascii 0098a92d5735b0-VLAN0001
|
||||
#
|
||||
interface Vlan-interface12
|
||||
description BGP to OSPF1
|
||||
mtu 9008
|
||||
ip address 15.12.16.246 255.255.255.252
|
||||
#
|
||||
interface Vlan-interface3000
|
||||
description L3 to HW_TEST_3
|
||||
ip binding vpn-instance HW_TEST_3
|
||||
ip address 192.168.19.254 255.255.255.128
|
||||
#
|
||||
interface HundredGigE1/0/3
|
||||
port link-mode bridge
|
||||
description HW_TEST_1
|
||||
port link-type trunk
|
||||
undo port trunk permit vlan 1
|
||||
port trunk permit vlan 221 1112 to 1116 1512
|
||||
storm-constrain broadcast pps 1100 1000
|
||||
storm-constrain multicast pps 1100 1000
|
||||
storm-constrain control shutdown
|
||||
port link-aggregation group 2
|
||||
#
|
||||
interface HundredGigE1/0/63
|
||||
description HW_TEST_2
|
||||
#
|
||||
interface M-GigabitEthernet0/0/0
|
||||
ip address 192.168.10.101 255.255.255.0
|
||||
dhcp client identifier hex 0298a92d5735b0
|
||||
#
|
||||
interface M-GigabitEthernet0/0/1
|
||||
dhcp client identifier hex 0298a92d5735b0
|
||||
#
|
||||
155
tests/fixtures/h3c/config.expected.json
vendored
Normal file
155
tests/fixtures/h3c/config.expected.json
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
{
|
||||
"system": {
|
||||
"model": "S9820-64H",
|
||||
"serial_number": "",
|
||||
"version": "7.1.070"
|
||||
},
|
||||
"interfaces": [
|
||||
{
|
||||
"interface": "Bridge-Aggregation1",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": "HW_TEST_1"
|
||||
},
|
||||
{
|
||||
"interface": "Bridge-Aggregation2",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": "HW_TEST_2"
|
||||
},
|
||||
{
|
||||
"interface": "Bridge-Aggregation3",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": "HW_TEST_3"
|
||||
},
|
||||
{
|
||||
"interface": "Bridge-Aggregation4",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": "HW_TEST_4"
|
||||
},
|
||||
{
|
||||
"interface": "NULL0",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"interface": "Vlan-interface1",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"interface": "Vlan-interface12",
|
||||
"ip_address": "15.12.16.246",
|
||||
"mask": 30,
|
||||
"description": "BGP to OSPF1"
|
||||
},
|
||||
{
|
||||
"interface": "Vlan-interface3000",
|
||||
"ip_address": "192.168.19.254",
|
||||
"mask": 25,
|
||||
"description": "L3 to HW_TEST_3"
|
||||
},
|
||||
{
|
||||
"interface": "HundredGigE1/0/3",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": "HW_TEST_1"
|
||||
},
|
||||
{
|
||||
"interface": "HundredGigE1/0/63",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": "HW_TEST_2"
|
||||
},
|
||||
{
|
||||
"interface": "M-GigabitEthernet0/0/0",
|
||||
"ip_address": "192.168.10.101",
|
||||
"mask": 24,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"interface": "M-GigabitEthernet0/0/1",
|
||||
"ip_address": null,
|
||||
"mask": null,
|
||||
"description": null
|
||||
}
|
||||
],
|
||||
"vlans": [
|
||||
{
|
||||
"vlan_id": 1,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 12,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 13,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 15,
|
||||
"description": "HW_TEST_1"
|
||||
},
|
||||
{
|
||||
"vlan_id": 222,
|
||||
"description": "MGMT"
|
||||
},
|
||||
{
|
||||
"vlan_id": 222,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 1122,
|
||||
"description": "DATA"
|
||||
},
|
||||
{
|
||||
"vlan_id": 1123,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 1200,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 1512,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 1513,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 2000,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 3377,
|
||||
"description": "HW_TEST_1"
|
||||
},
|
||||
{
|
||||
"vlan_id": 1112,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 1113,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 1114,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 1115,
|
||||
"description": null
|
||||
},
|
||||
{
|
||||
"vlan_id": 1116,
|
||||
"description": null
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -12,6 +12,7 @@ MODEL_CASES = [
|
||||
("qtech", "config_2.conf", "config_2.expected.json"),
|
||||
("huawei", "config.conf", "config.expected.json"),
|
||||
("eltex", "config.conf", "config.expected.json"),
|
||||
("h3c", "config.conf", "config.expected.json"),
|
||||
("quasar", "config_1.conf", "config_1.expected.json"),
|
||||
("quasar", "config_2.conf", "config_2.expected.json"),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user