esptest.devices.switch module

class esptest.devices.switch.SwitchConfig(ip: str, port: int, login_method: str = 'telnet', login_username: str = '', login_password: str = '', timeout: float = 10)[source]

Bases: object

Parameters:
ip: str
port: int
login_method: str = 'telnet'
login_username: str = ''
login_password: str = ''
timeout: float = 10
class esptest.devices.switch.VlanInfo(id: int, interface_name: str = '', name: str = '', type: str = '', status: str = '', ip: str = '', mask: str = '', description: str = '', tagged_ports: str = '', untagged_ports: str = '')[source]

Bases: object

Parameters:
id: int
interface_name: str = ''
name: str = ''
type: str = ''
status: str = ''
ip: str = ''
mask: str = ''
description: str = ''
tagged_ports: str = ''
untagged_ports: str = ''
classmethod parse_interface_brief_line(line)[source]

Interface Link Protocol Primary IP Description

Parameters:

line (str)

Return type:

VlanInfo | None

parse_vlan_details(line)[source]

VLAN ID: 1 VLAN type: Static Route interface: Configured IPv4 address: 10.0.0.1 IPv4 subnet mask: 255.255.255.0 Description: Server Name: VLAN 0001

Parameters:

line (str)

Return type:

None

class esptest.devices.switch.PoolInfo(name: str, ip: str = '', mask: str = '', gateway: str = '', dns_list: str = '', vlan_id: int = 0)[source]

Bases: object

Parameters:
name: str
ip: str = ''
mask: str = ''
gateway: str = ''
dns_list: str = ''
vlan_id: int = 0
classmethod parse_pool_info(output)[source]

Parse the display ip pool output into a PoolInfo.

Example input:

Pool name: 111
Network: 10.0.0.0 mask 255.255.254.0
dns-list 8.8.8.8 114.114.114.114
expired day 1 hour 0 minute 0 second 0
gateway-list 10.0.0.1
static bindings:
    ip-address 10.0.0.10 mask 255.255.254.0
    hardware-address 1122-3344-aabb ethernet
Parameters:

output (str)

Return type:

PoolInfo

class esptest.devices.switch.InterfaceInfo(name: str, full_name: str = '', description: str = '', status: str = '', speed: str = '', duplex: str = '', link_mode: str = '', link_type: str = '', pvid: int = 0, permit_vlan: str = '')[source]

Bases: object

Parameters:
name: str
full_name: str = ''
description: str = ''
status: str = ''
speed: str = ''
duplex: str = ''
pvid: int = 0
permit_vlan: str = ''
classmethod parse_interface_line(line)[source]

Interface Link Speed Duplex Type PVID Description

Parameters:

line (str)

Return type:

InterfaceInfo | None

parse_interface_details(data)[source]

interface Ten-GigabitEthernet1/0/1 description test port link-mode bridge port link-type trunk undo port trunk permit vlan 1 port trunk permit vlan 111 to 112 2000 port link-aggregation group 1

Parameters:

data (str)

Return type:

None

class esptest.devices.switch.ArpInfo(ip: str, mac: str, vlan_id: str, interface: str = '', type: str = '', pool_name: str = '')[source]

Bases: object

Parameters:
ip: str
mac: str
vlan_id: str
interface: str = ''
type: str = ''
pool_name: str = ''
classmethod parse_arp_line(line)[source]

IP address MAC address VLAN/VSI name Interface Aging Type

Parameters:

line (str)

Return type:

ArpInfo | None

class esptest.devices.switch.StaticBindInfo(ip: str, mask: str, hardware_address: str, pool_name: str = '')[source]

Bases: object

Parameters:
  • ip (str)

  • mask (str)

  • hardware_address (str)

  • pool_name (str)

ip: str
mask: str
hardware_address: str
pool_name: str = ''
property mac: str
class esptest.devices.switch.H3CSwitch(config, log_file='')[source]

Bases: object

Parameters:
connect()[source]

Connect to the switch.

Return type:

None

disconnect()[source]

Disconnect from the switch, and save the configuration if needed.

Return type:

None

save()[source]

Save the configuration of the switch.

Return type:

None

reset_cache()[source]

Reset the cache of the switch.

Return type:

None

execute_command(command, timeout=-1)[source]

Execute a command on the switch and return the result.

Parameters:
Return type:

str

system_view()[source]

Enter system view of the switch.

Return type:

bool

get_vlan_info()[source]

Get VLAN (interface) information from the switch.

Return type:

List[VlanInfo]

get_pool_name_list()[source]

Get pool name list from the switch.

Return type:

List[str]

get_pool_info()[source]

Get pool information from the switch.

Return type:

List[PoolInfo]

get_interface_info(detail=False)[source]

Get interface information from the switch.

Parameters:

detail (bool)

Return type:

List[InterfaceInfo]

get_arp_info()[source]

Get ARP information from the switch.

Return type:

List[ArpInfo]

get_static_bind_info()[source]

Get static bind information from the switch.

Return type:

List[StaticBindInfo]

get_pool_by_ip(ip_address)[source]

Get pool name by IP address.

Parameters:

ip_address (str)

Return type:

PoolInfo

get_arp_info_by_ip(ip_address)[source]

Get ARP information by IP address.

Parameters:

ip_address (str)

Return type:

ArpInfo

add_one_static_bind(ip_address, hardware_address='', mask='', pool_name='', remove_existing=False)[source]

Add static bind information to the switch.

Parameters:
  • ip_address (str) – IP address to bind.

  • hardware_address (str) – Hardware address to bind.

  • mask (str) – Subnet mask.

  • pool_name (str) – Pool name.

  • remove_existing (bool) – Remove existing bind information for the IP address.

Return type:

bool