diff --git a/changelog/undistributed/hvrp_display_interfaces_and_static_routing_20230726151700.rst b/changelog/undistributed/hvrp_display_interfaces_and_static_routing_20230726151700.rst new file mode 100644 index 0000000000..bea6465502 --- /dev/null +++ b/changelog/undistributed/hvrp_display_interfaces_and_static_routing_20230726151700.rst @@ -0,0 +1,10 @@ +-------------------------------------------------------------------------------- + New +-------------------------------------------------------------------------------- + +* hvrp + * Added DisplayInterface + * display interface + * display interface {interface} + * Added DisplayStaticRoute + * display current-configuration | include ^ip route-static \ No newline at end of file diff --git a/sdk_generator/outputs/github_parser.json b/sdk_generator/outputs/github_parser.json index 809993a974..cc2e483ea8 100644 --- a/sdk_generator/outputs/github_parser.json +++ b/sdk_generator/outputs/github_parser.json @@ -8493,6 +8493,17 @@ "url": "https://github.com/CiscoTestAutomation/genieparser/tree/master/src/genie/libs/parser/hvrp/display_bgp.py#L305" } }, + "display current-configuration | include ^ip route-static": { + "hvrp": { + "class": "DisplayStaticRoute", + "doc": null, + "module_name": "display_static_route", + "package": "genie.libs.parser", + "schema": "{\n'ip_routes': {\n Any (str) *: {\n 'ip_version': ,\n 'subnet': ,\n 'subnet_mask': ,\n 'subnet_prefix': ,\n 'next_hop': ,\n 'preference': ,\n 'route_name': ,\n },\n },\n}", + "uid": "display_current-configuration___include_^ip_route-static", + "url": "https://github.com/CiscoTestAutomation/genieparser/tree/master/src/genie/libs/parser/hvrp/display_static_route.py#L22" + } + }, "display interface": { "comware": { "class": "DisplayInterfaces", @@ -8502,6 +8513,15 @@ "schema": "{\nAny (str) *: {\n 'oper_status': ,\n 'enabled': ,\n Optional (str) description: ,\n 'type': ,\n Optional (str) frame_type: ,\n Optional (str) ipv6_frame_type: ,\n Optional (str) port_speed: ,\n Optional (str) duplex_mode: ,\n Optional (str) media_type: ,\n Optional (str) port_type: ,\n Optional (str) mtu: ,\n Optional (str) max_frame_length: ,\n Optional (str) pvid: ,\n Optional (str) mac_address: ,\n Optional (str) ipv6_mac_address: ,\n Optional (str) auto_negotiate: ,\n Optional (str) priority: ,\n Optional (str) counters: {\n Optional (str) rate: {\n Optional (str) load_interval: ,\n Optional (str) in_rate_pkts: ,\n Optional (str) out_rate_pkts: ,\n Optional (str) in_rate_bytes: ,\n Optional (str) out_rate_bytes: ,\n },\n Optional (str) normal: {\n Optional (str) in_pkts: ,\n Optional (str) in_octets: ,\n Optional (str) out_pkts: ,\n Optional (str) out_octets: ,\n Optional (str) in_unicast_pkts: ,\n Optional (str) in_broadcast_pkts: ,\n Optional (str) in_multicast_pkts: ,\n Optional (str) in_mac_pause_frames: ,\n Optional (str) out_unicast_pkts: ,\n Optional (str) out_broadcast_pkts: ,\n Optional (str) out_multicast_pkts: ,\n Optional (str) out_mac_pause_frames: ,\n },\n Optional (str) out_unicast_pkts: ,\n Optional (str) out_errors: ,\n Optional (str) out_collision: ,\n Optional (str) out_lost_carrier: ,\n Optional (str) out_no_carrier: ,\n Optional (str) in_multicast_pkts: ,\n Optional (str) in_unicast_pkts: ,\n Optional (str) out_broadcast_pkts: ,\n Optional (str) out_abort: ,\n Optional (str) in_errors: ,\n Optional (str) in_parity_errors: ,\n Optional (str) in_ignored: ,\n Optional (str) in_throttles: ,\n Optional (str) in_overrun: ,\n Optional (str) out_mac_pause_frames: ,\n Optional (str) out_deferred: ,\n Optional (str) in_mac_pause_frames: ,\n Optional (str) out_octets: ,\n Optional (str) in_octets: ,\n Optional (str) in_runts: ,\n Optional (str) out_multicast_pkts: ,\n Optional (str) in_frame: ,\n Optional (str) in_broadcast_pkts: ,\n Optional (str) out_buffer_failure: ,\n Optional (str) out_pkts: ,\n Optional (str) out_late_collision: ,\n Optional (str) in_giants: ,\n Optional (str) out_underruns: ,\n Optional (str) in_crc_errors: ,\n Optional (str) in_abort: ,\n Optional (str) in_pkts: ,\n Optional (str) last_clear: ,\n },\n Optional (str) switchport: {\n Optional (str) mode: ,\n Optional (str) tagged: ,\n Optional (str) untagged: ,\n Optional (str) vlan_passing: ,\n Optional (str) vlan_permitted: ,\n Optional (str) encapsulation: ,\n },\n Optional (str) ipv4: {\n Any (str) *: {\n Optional (str) ip: ,\n Optional (str) prefix_length: ,\n Optional (str) secondary: ,\n },\n },\n },\n}", "uid": "display_interface", "url": "https://github.com/CiscoTestAutomation/genieparser/tree/master/src/genie/libs/parser/comware/show_interface.py#L115" + }, + "hvrp": { + "class": "DisplayInterface", + "doc": "parser for display interface\n display interface ", + "module_name": "display_interface", + "package": "genie.libs.parser", + "schema": "{\nAny (str) *: {\n Optional (str) ip_address: ,\n Optional (str) subnet_prefix: ,\n Optional (str) subnet_mask: ,\n Optional (str) admin_status: ,\n Optional (str) crc_errors: ,\n Optional (str) line_status: ,\n Optional (str) line_up_since: ,\n Optional (str) interface_description: ,\n Optional (str) mtu: ,\n Optional (str) cellular_info: {\n Optional (str) ip_address: ,\n Optional (str) subnet_prefix: ,\n Optional (str) subnet_mask: ,\n Optional (str) modem_state: ,\n Optional (str) modem_model: ,\n Optional (str) wireless_technology: ,\n Optional (str) rssi: ,\n Optional (str) sinr: ,\n },\n Optional (str) time_last_up: ,\n Optional (str) system_info: ,\n Optional (str) input_packets: ,\n Optional (str) input_bytes: ,\n Optional (str) output_packets: ,\n Optional (str) output_bytes: ,\n Optional (str) output_rate_packets: ,\n Optional (str) output_rate_bits: ,\n Optional (str) input_rate_bits: ,\n Optional (str) input_rate_packets: ,\n Optional (str) system_time: ,\n Optional (str) port_mode: ,\n Optional (str) port_speed: ,\n Optional (str) port_negotiation: ,\n Optional (str) mac_address: ,\n },\n}", + "uid": "display_interface", + "url": "https://github.com/CiscoTestAutomation/genieparser/tree/master/src/genie/libs/parser/hvrp/display_interface.py#L48" } }, "display interface brief": { @@ -8524,6 +8544,15 @@ "schema": "{\nAny (str) *: {\n 'oper_status': ,\n 'enabled': ,\n Optional (str) description: ,\n 'type': ,\n Optional (str) frame_type: ,\n Optional (str) ipv6_frame_type: ,\n Optional (str) port_speed: ,\n Optional (str) duplex_mode: ,\n Optional (str) media_type: ,\n Optional (str) port_type: ,\n Optional (str) mtu: ,\n Optional (str) max_frame_length: ,\n Optional (str) pvid: ,\n Optional (str) mac_address: ,\n Optional (str) ipv6_mac_address: ,\n Optional (str) auto_negotiate: ,\n Optional (str) priority: ,\n Optional (str) counters: {\n Optional (str) rate: {\n Optional (str) load_interval: ,\n Optional (str) in_rate_pkts: ,\n Optional (str) out_rate_pkts: ,\n Optional (str) in_rate_bytes: ,\n Optional (str) out_rate_bytes: ,\n },\n Optional (str) normal: {\n Optional (str) in_pkts: ,\n Optional (str) in_octets: ,\n Optional (str) out_pkts: ,\n Optional (str) out_octets: ,\n Optional (str) in_unicast_pkts: ,\n Optional (str) in_broadcast_pkts: ,\n Optional (str) in_multicast_pkts: ,\n Optional (str) in_mac_pause_frames: ,\n Optional (str) out_unicast_pkts: ,\n Optional (str) out_broadcast_pkts: ,\n Optional (str) out_multicast_pkts: ,\n Optional (str) out_mac_pause_frames: ,\n },\n Optional (str) out_unicast_pkts: ,\n Optional (str) out_errors: ,\n Optional (str) out_collision: ,\n Optional (str) out_lost_carrier: ,\n Optional (str) out_no_carrier: ,\n Optional (str) in_multicast_pkts: ,\n Optional (str) in_unicast_pkts: ,\n Optional (str) out_broadcast_pkts: ,\n Optional (str) out_abort: ,\n Optional (str) in_errors: ,\n Optional (str) in_parity_errors: ,\n Optional (str) in_ignored: ,\n Optional (str) in_throttles: ,\n Optional (str) in_overrun: ,\n Optional (str) out_mac_pause_frames: ,\n Optional (str) out_deferred: ,\n Optional (str) in_mac_pause_frames: ,\n Optional (str) out_octets: ,\n Optional (str) in_octets: ,\n Optional (str) in_runts: ,\n Optional (str) out_multicast_pkts: ,\n Optional (str) in_frame: ,\n Optional (str) in_broadcast_pkts: ,\n Optional (str) out_buffer_failure: ,\n Optional (str) out_pkts: ,\n Optional (str) out_late_collision: ,\n Optional (str) in_giants: ,\n Optional (str) out_underruns: ,\n Optional (str) in_crc_errors: ,\n Optional (str) in_abort: ,\n Optional (str) in_pkts: ,\n Optional (str) last_clear: ,\n },\n Optional (str) switchport: {\n Optional (str) mode: ,\n Optional (str) tagged: ,\n Optional (str) untagged: ,\n Optional (str) vlan_passing: ,\n Optional (str) vlan_permitted: ,\n Optional (str) encapsulation: ,\n },\n Optional (str) ipv4: {\n Any (str) *: {\n Optional (str) ip: ,\n Optional (str) prefix_length: ,\n Optional (str) secondary: ,\n },\n },\n },\n}", "uid": "display_interface_interface", "url": "https://github.com/CiscoTestAutomation/genieparser/tree/master/src/genie/libs/parser/comware/show_interface.py#L115" + }, + "hvrp": { + "class": "DisplayInterface", + "doc": "parser for display interface\n display interface ", + "module_name": "display_interface", + "package": "genie.libs.parser", + "schema": "{\nAny (str) *: {\n Optional (str) ip_address: ,\n Optional (str) subnet_prefix: ,\n Optional (str) subnet_mask: ,\n Optional (str) admin_status: ,\n Optional (str) crc_errors: ,\n Optional (str) line_status: ,\n Optional (str) line_up_since: ,\n Optional (str) interface_description: ,\n Optional (str) mtu: ,\n Optional (str) cellular_info: {\n Optional (str) ip_address: ,\n Optional (str) subnet_prefix: ,\n Optional (str) subnet_mask: ,\n Optional (str) modem_state: ,\n Optional (str) modem_model: ,\n Optional (str) wireless_technology: ,\n Optional (str) rssi: ,\n Optional (str) sinr: ,\n },\n Optional (str) time_last_up: ,\n Optional (str) system_info: ,\n Optional (str) input_packets: ,\n Optional (str) input_bytes: ,\n Optional (str) output_packets: ,\n Optional (str) output_bytes: ,\n Optional (str) output_rate_packets: ,\n Optional (str) output_rate_bits: ,\n Optional (str) input_rate_bits: ,\n Optional (str) input_rate_packets: ,\n Optional (str) system_time: ,\n Optional (str) port_mode: ,\n Optional (str) port_speed: ,\n Optional (str) port_negotiation: ,\n Optional (str) mac_address: ,\n },\n}", + "uid": "display_interface_interface", + "url": "https://github.com/CiscoTestAutomation/genieparser/tree/master/src/genie/libs/parser/hvrp/display_interface.py#L48" } }, "docker stats --no-stream": { diff --git a/src/genie/libs/parser/hvrp/display_interface.py b/src/genie/libs/parser/hvrp/display_interface.py new file mode 100644 index 0000000000..d71e849649 --- /dev/null +++ b/src/genie/libs/parser/hvrp/display_interface.py @@ -0,0 +1,334 @@ +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Optional +import re + + +class DisplayInterfaceSchema(MetaParser): + schema = { + Any(): { + Optional('ip_address'): str, + Optional('subnet_prefix'): str, + Optional('subnet_mask'): str, + Optional('admin_status'): str, + Optional('crc_errors'): str, + Optional('line_status'): bool, + Optional('line_up_since'): str, + Optional('interface_description'): str, + Optional('mtu'): int, + Optional('cellular_info'): + { + Optional('ip_address'): str, + Optional('subnet_prefix'): str, + Optional('subnet_mask'): str, + Optional('modem_state'): str, + Optional('modem_model'): str, + Optional('wireless_technology'): str, + Optional('rssi'): str, + Optional('sinr'): str, + }, + Optional('time_last_up'): str, + Optional('system_info'): str, + Optional('input_packets'): str, + Optional('input_bytes'): str, + Optional('output_packets'): str, + Optional('output_bytes'): str, + Optional('output_rate_packets'): str, + Optional('output_rate_bits'): str, + Optional('input_rate_bits'): str, + Optional('input_rate_packets'): str, + Optional('system_time'): str, + Optional('port_mode'): str, + Optional('port_speed'): str, + Optional('port_negotiation'): str, + Optional('mac_address'): str, + } + } + + +class DisplayInterface(DisplayInterfaceSchema): + """parser for display interface + display interface """ + + cli_command = ['display interface', 'display interface {interface}'] + + @staticmethod + def translater_cidr_netmask(cidr): + """ + # to convert prefix to subnetmask. huawei only shows prefix len + Translate CIDR to netmask notation. + :param cidr: + :return: netmask as string + """ + return '.'.join( + [str((m >> (3 - i) * 8) & 0xff) for i, m in enumerate( + [-1 << (32 - int(cidr))] * 4)] + ) + + def cli(self, interface="", output=None): + if output is None: + if interface: + cmd = self.cli_command[1].format(interface=interface) + else: + cmd = self.cli_command[0] + out = self.device.execute(cmd) + else: + out = output + + ####### GENERAL + # Atm0/0/0 current state : UP + # GigabitEthernet0/0/0 current state : Administratively DOWN + # LoopBack0 current state : DOWN + + p1 = re.compile(r'^(?P[\w\/\.\-\:]+) +current +state +:(?P[\w\s]+$)') + + # Line protocol current state : UP + # Line protocol current state : DOWN + p2 = re.compile( + r'^Line +protocol +current +state +: +(?P[\w\s]+$)') + + # Last line protocol up time : 2022-01-24 12:00:41 + p3 = re.compile( + r'^Last line +protocol +up +time +: +(?P.*$)') + + # ex: Description:145.7.64.247 Backup Link + p4 = re.compile(r'^Description: *(?P.*)$') + + # Route Port,The Maximum Transmit Unit is 1500 + # Switch Port, TPID : 8100(Hex), The Maximum Transmit Unit is 1500 + p5 = re.compile(r'^.*The Maximum Transmit Unit is (?P\d+)') + + # Last physical up time : 2022-01-24 12:00:41 + p6 = re.compile(r'^Last physical up time \s+:\s+(?P.*$)') + + # Last physical down time : 2022-01-24 11:56:21 + p7 = re.compile(r'^Last physical down time \s+:\s+(?P.*$)') + + # Current system time: 2022-01-27 11:41:40+01:00 + p8 = re.compile(r'^Current system time:\s+(?P.*$)') + + # Input: 69561 packets, 7394401 bytes + p9 = re.compile(r'^Input:\s+(?P\d+).*,\s+(?P\d+)') + + # Output: 69361 packets, 739411401 bytes + p10 = re.compile(r'^Output:\s+(?P\d+).*,\s+(?P\d+)') + + # default is 30. people can change that. + # not sure if i should handle that no usecase for it + # Last 30 seconds input rate 3856 bits/sec, 3 packets/sec + p11 = re.compile(r'^Last \d+ seconds input rate (?P\d+) .*,\s+(?P\d+)') + + # Last 30 seconds output rate 4504 bits/sec, 3 packets/sec + p12 = re.compile(r'^Last \d+ seconds output rate (?P\d+) .*,\s+(?P\d+)') + + # Port Mode: COMMON COPPER + # Port Mode: AUTO + p13 = re.compile(r'^Port Mode:\s+(?P.*$)') + + # port speed settings can be 1000/100/10/AUTO + # we dont need the Loopback part + # Speed : 1000, Loopback: NONE + # Speed : AUTO, Loopback: NONE + p14 = re.compile(r'^Speed\s+:\s+(?P\d+|\w+),') + + # Duplex: FULL, Negotiation: ENABLE + p15 = re.compile(r'^Duplex:\s+(?P\d+|\w+),\s+Negotiation:\s+(?P.*$)') + + # IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is c444-7d9c-77c9 + p16 = re.compile(r'^IP Sending Frames\' .*Hardware address is\s+(?P[\d\w]{0,4}-[\d\w]{0,4}-[\d\w]{0,4})$') + + # note below begins with 2 leading spaces in the cli + # CRC: 0, Giants: 0 + p17 = re.compile(r'^.*CRC:\s+(?P.*(?=,))') + + ####### ROUTED port Interfaces + + # Internet Address is 10.1.1.132/32 + p1_routed = re.compile('^Internet Address is (?P[0-9\.x]+)\/(?P[0-9]+)$') + + ####### CELLULAR Interfaces + # Internet Address is negotiated, 10.124.234.33/32 + p1_cellular = re.compile(r'^Internet Address is negotiated, (?P[0-9\.x]+)\/(?P[0-9]+)') + + # Current Network Connection = LTE(LTE) + p2_cellular = re.compile(r'^Current Network Connection\s+=\s+(?P.*$)') + + # Current RSSI = -67 dBm + p3_cellular = re.compile(r'^Current RSSI\s+=\s+(?P.*$)') + + # Current SINR = 17 dB (good) + p4_cellular = re.compile(r'^Current SINR\s+=\s+(?P.*$)') + + # Modem State: Present + p5_cellular = re.compile(r'^Modem State:\s+(?P.*)$') + + # below mean modem model + # Model = EP06 + p6_cellular = re.compile(r'^Model\s+=\s+(?P.*)$') + + interface_dict = {} + for line in out.splitlines(): + line = line.strip() + + # we match an interface name and state and continue with that + m = p1.match(line) + if m: + interface = m.groupdict()['interface'] + interface_state = m.groupdict()['admin_status'] + + if interface not in interface_dict: + interface_dict[interface] = {} + if 'ellular' in interface: + interface_dict[interface]['cellular_info'] = {} + + interface_dict[interface]['admin_status'] = interface_state + + m = p2.match(line) + if m: + line_status = m.groupdict()['line_status'] + if 'UP' in line_status: + interface_dict[interface]['line_status'] = True + else: + interface_dict[interface]['line_status'] = False + + m = p3.match(line) + if m: + interface_dict[interface]['line_up_since'] = m.groupdict()[ + 'line_up_since'] + + m = p4.match(line) + if m: + interface_dict[interface]['interface_description'] = \ + m.groupdict()['interface_description'] + + m = p5.match(line) + if m: + interface_dict[interface]['mtu'] = int(m.groupdict()['mtu']) + + m = p6.match(line) + if m: + interface_dict[interface]['time_last_up'] = \ + m.groupdict()['time_last_up'] + + m = p7.match(line) + if m: + interface_dict[interface]['time_last_down'] = m.groupdict()[ + 'time_last_down'] + + m = p8.match(line) + if m: + interface_dict[interface]['system_time'] = m.groupdict()[ + 'system_time'] + + m = p9.match(line) + if m: + interface_dict[interface]['input_packets'] = m.groupdict()[ + 'input_packets'] + interface_dict[interface]['input_bytes'] = m.groupdict()[ + 'input_bytes'] + + m = p10.match(line) + if m: + interface_dict[interface]['output_packets'] = m.groupdict()[ + 'output_packets'] + interface_dict[interface]['output_bytes'] = m.groupdict()[ + 'output_bytes'] + + m = p11.match(line) + if m: + interface_dict[interface]['input_rate_bits'] = m.groupdict()[ + 'input_rate_bits'] + interface_dict[interface]['input_rate_packets'] = m.groupdict()[ + 'input_rate_packets'] + + m = p12.match(line) + if m: + interface_dict[interface]['output_rate_bits'] = m.groupdict()[ + 'output_rate_bits'] + interface_dict[interface]['output_rate_packets'] = m.groupdict()[ + 'output_rate_packets'] + + m = p13.match(line) + if m: + interface_dict[interface]['port_mode'] = m.groupdict()[ + 'port_mode'] + + m = p14.match(line) + if m: + interface_dict[interface]['port_speed'] = m.groupdict()[ + 'port_speed'] + + m = p15.match(line) + if m: + interface_dict[interface]['port_speed'] = m.groupdict()[ + 'port_speed'] + interface_dict[interface]['port_negotiation'] = m.groupdict()[ + 'port_negotiation'] + + m = p16.match(line) + if m: + interface_dict[interface]['mac_address'] = m.groupdict()[ + 'mac_address'] + + m = p17.match(line) + if m: + interface_dict[interface]['crc_errors'] = m.groupdict()[ + 'crc_errors'] + + m = p1_routed.match(line) + if m: + ip_address = m.groupdict()['ip'] + subnet_prefix = m.groupdict()['prefix_length'] + subnet_mask = self.translater_cidr_netmask( + m.groupdict()['prefix_length'] + ) + + interface_dict[interface]['ip_address'] = ip_address + interface_dict[interface]['subnet_prefix'] = subnet_prefix + interface_dict[interface]['subnet_mask'] = subnet_mask + + m_cellular = p1_cellular.match(line) + if m_cellular: + ip_address = m_cellular.groupdict()['ip'] + subnet_prefix = m_cellular.groupdict()['prefix_length'] + subnet_mask = self.translater_cidr_netmask( + m_cellular.groupdict()['prefix_length'] + ) + + interface_dict[interface]['cellular_info']['ip_address'] \ + = ip_address + interface_dict[interface]['cellular_info']['subnet_prefix'] \ + = subnet_prefix + interface_dict[interface]['cellular_info']['subnet_mask'] \ + = subnet_mask + + m_cellular = p2_cellular.match(line) + if m_cellular: + interface_dict[ + interface]['cellular_info']['wireless_technology'] \ + = m_cellular.groupdict()['wireless_technology'] + + m_cellular = p3_cellular.match(line) + if m_cellular: + interface_dict[ + interface]['cellular_info']['rssi'] \ + = m_cellular.groupdict()['rssi'] + + m_cellular = p4_cellular.match(line) + if m_cellular: + interface_dict[ + interface]['cellular_info']['sinr'] \ + = m_cellular.groupdict()['sinr'] + + m_cellular = p5_cellular.match(line) + if m_cellular: + interface_dict[ + interface]['cellular_info']['modem_state'] \ + = m_cellular.groupdict()['modem_state'] + + m_cellular = p6_cellular.match(line) + if m_cellular: + interface_dict[ + interface]['cellular_info']['modem_model'] \ + = m_cellular.groupdict()['modem_model'] + + return(interface_dict) \ No newline at end of file diff --git a/src/genie/libs/parser/hvrp/display_static_route.py b/src/genie/libs/parser/hvrp/display_static_route.py new file mode 100644 index 0000000000..c48e0ecd3c --- /dev/null +++ b/src/genie/libs/parser/hvrp/display_static_route.py @@ -0,0 +1,102 @@ +from genie.metaparser import MetaParser, Any +import re +import logging + + +class DisplayStaticrouteSchema(MetaParser): + schema = { + "ip_routes": { + Any(): { + "ip_version": str, + 'subnet': str, + 'subnet_mask': str, + 'subnet_prefix': str, + 'next_hop': str, + 'preference': str, + 'route_name': str, + } + } + } + + +class DisplayStaticRoute(DisplayStaticrouteSchema): + cli_command = "display current-configuration | include ^ip route-static" + + """ +ip route-static 0.0.0.0 0.0.0.0 192.168.12.42 preference 1 +ip route-static 0.0.0.0 0.0.0.0 1.1.1.2 track bfd-session aa +ip route-static 145.7.64.247 255.255.255.255 NULL0 preference 250 +ip route-static 145.13.71.128 255.255.255.128 192.168.12.42 preference 1 +ip route-static 145.13.71.128 255.255.255.128 NULL0 preference 250 +ip route-static 145.13.76.0 255.255.255.0 192.168.12.42 preference 1 +ip route-static 145.13.76.0 255.255.255.0 NULL0 preference 250 +ip route-static 192.168.28.0 255.255.255.0 192.168.12.42 preference 1 +ip route-static 192.168.28.0 255.255.255.0 NULL0 preference 250 description testroute +ipv6 route-static :: 0 2001:67C:2504:F009::15A preference 1 description testroute-2 +ipv6 route-static 2A07:3500:1BC0:: 49 2A07:3500:1BC0::F001:1002 description testroute-3 + """ + + @staticmethod + def convert_netmask_to_cidr(netmask): + return sum(bin(int(x)).count('1') for x in netmask.split('.')) + + def cli(self, output=None): + out = self.device.execute( + self.cli_command) if output is None else output + + ip_routes_dict = {} + + result_dict = {} + + # matches + # ip route-static 192.168.28.0 255.255.255.0 192.168.12.42 preference 1 + # ip route-static 192.168.28.0 255.255.255.0 NULL0 preference 250 description testroute + p_ip_route_with_next_hop = re.compile(r'^(ipv6|ip)\sroute-static\s+(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[:A-Z0-9]{0,39})\s+(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[:A-Z0-9]{0,39})\s+(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[A-Za-z0-9-_:\.\/]*)') + p_ip_version = re.compile(r"^(?Pipv6|ip)") + p_preference = re.compile(r"(.*)preference\s+(?P\w+)") + p_route_name = re.compile(r"(.*)description\s+(?P([A-Za-z0-9-_@\"\`\&\,\+\=\/\'\.\(\)\[\]]*))") + + logging.debug(out) + for line in out.splitlines(): + line = line.strip() + + match_route_with_next_hop = p_ip_route_with_next_hop.match(line) + if match_route_with_next_hop: + subnet = match_route_with_next_hop.groupdict()['subnet'] + subnet_mask = match_route_with_next_hop.groupdict()[ + 'subnet_mask'] + subnet_prefix = str(self.convert_netmask_to_cidr(subnet_mask)) + next_hop = match_route_with_next_hop.groupdict()['next_hop'] + + match_ip_version = p_ip_version.match(line) + ip_version = "4" + if match_ip_version: + if "v6" in match_ip_version.groupdict()['ip_version']: + ip_version = "6" + + preference = '' + match_preference = p_preference.match(line) + if match_preference: + preference = match_preference.groupdict()['preference'] + + + route_name = '' + match_route_name = p_route_name.match(line) + if match_route_name: + route_name = match_route_name.groupdict()['route_name'] + + if 'ip_routes' not in ip_routes_dict: + result_dict = ip_routes_dict.setdefault('ip_routes', {}) + + identifier = f"{subnet}/{subnet_prefix}/{next_hop}" + result_dict[identifier] = { + 'ip_version': ip_version, + 'subnet': subnet, + 'subnet_mask': subnet_mask, + 'subnet_prefix': subnet_prefix, + 'next_hop': next_hop, + 'route_name': route_name, + 'preference': preference, + } + continue + return ip_routes_dict \ No newline at end of file diff --git a/src/genie/libs/parser/hvrp/tests/DisplayInterface/cli/empty/empty_output_output.txt b/src/genie/libs/parser/hvrp/tests/DisplayInterface/cli/empty/empty_output_output.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/genie/libs/parser/hvrp/tests/DisplayInterface/cli/equal/golden_output_expected.py b/src/genie/libs/parser/hvrp/tests/DisplayInterface/cli/equal/golden_output_expected.py new file mode 100644 index 0000000000..8aa59571fe --- /dev/null +++ b/src/genie/libs/parser/hvrp/tests/DisplayInterface/cli/equal/golden_output_expected.py @@ -0,0 +1,167 @@ +expected_output = { + 'Atm0/0/0': { + 'admin_status': ' UP', 'line_status': True, + 'line_up_since': '2022-01-20 17:52:13 UTC+01:00', + 'interface_description': 'Connection to TO-VPN # ax10001b #', + 'mtu': 1500, + 'time_last_up': '2022-01-20 17:52:13 UTC+01:00', + 'system_time': '2022-01-27 16:24:34+01:00', + 'input_rate_bits': '424', 'input_rate_packets': '0', + 'output_rate_bits': '248', 'output_rate_packets': '0', + 'input_packets': '159078', 'input_bytes': '16881401', + 'output_packets': '60908', 'output_bytes': '6664962'}, + 'Cellular0/0/0': { + 'cellular_info': {'modem_state': 'Present', + 'modem_model': 'ME909s-120', + 'wireless_technology': 'Unknown', + 'rssi': 'Unknown'}, + 'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'HUAWEI, AR Series, Cellular0/0/0 Interface', + 'mtu': 1500, 'time_last_up': '-', + 'system_time': '2022-01-27 16:24:34+01:00', + 'input_packets': '0', 'input_bytes': '0', + 'output_packets': '0', 'output_bytes': '0'}, + 'Cellular0/0/1': { + 'cellular_info': {'modem_state': 'Not present'}, + 'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'HUAWEI, AR Series, Cellular0/0/1 Interface', + 'mtu': 1500, 'time_last_up': '-', + 'system_time': '2022-01-27 16:24:35+01:00', + 'input_packets': '0', 'input_bytes': '0', + 'output_packets': '0', 'output_bytes': '0'}, + 'GigabitEthernet0/0/0': { + 'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'HUAWEI, AR Series, GigabitEthernet0/0/0 Interface', + 'mac_address': 'f03f-9566-fc42', + 'time_last_up': '-', + 'system_time': '2022-01-27 16:24:35+01:00', + 'port_mode': 'COMMON COPPER', + 'port_speed': 'FULL', + 'port_negotiation': 'ENABLE', + 'input_rate_bits': '0', + 'input_rate_packets': '0', + 'output_rate_bits': '0', + 'output_rate_packets': '0', + 'input_packets': '0', 'input_bytes': '0', + 'crc_errors': '0', 'output_packets': '0', + 'output_bytes': '0'}, + 'GigabitEthernet0/0/1': { + 'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'HUAWEI, AR Series, GigabitEthernet0/0/1 Interface', + 'mac_address': 'f03f-9566-fc42', + 'time_last_up': '-', + 'system_time': '2022-01-27 16:24:35+01:00', + 'port_mode': 'COMMON COPPER', + 'port_speed': 'FULL', + 'port_negotiation': 'ENABLE', + 'input_rate_bits': '0', + 'input_rate_packets': '0', + 'output_rate_bits': '0', + 'output_rate_packets': '0', + 'input_packets': '0', 'input_bytes': '0', + 'crc_errors': '0', 'output_packets': '0', + 'output_bytes': '0'}, + 'GigabitEthernet0/0/2': { + 'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'HUAWEI, AR Series, GigabitEthernet0/0/2 Interface', + 'mac_address': 'f03f-9566-fc42', + 'time_last_up': '-', + 'system_time': '2022-01-27 16:24:36+01:00', + 'port_mode': 'COMMON COPPER', + 'port_speed': 'FULL', + 'port_negotiation': 'ENABLE', + 'input_rate_bits': '0', + 'input_rate_packets': '0', + 'output_rate_bits': '0', + 'output_rate_packets': '0', + 'input_packets': '0', 'input_bytes': '0', + 'crc_errors': '0', 'output_packets': '0', + 'output_bytes': '0'}, + 'GigabitEthernet0/0/3': { + 'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'HUAWEI, AR Series, GigabitEthernet0/0/3 Interface', + 'mac_address': 'f03f-9566-fc42', + 'time_last_up': '-', + 'system_time': '2022-01-27 16:24:36+01:00', + 'port_mode': 'COMMON COPPER', + 'port_speed': 'FULL', + 'port_negotiation': 'ENABLE', + 'input_rate_bits': '0', + 'input_rate_packets': '0', + 'output_rate_bits': '0', + 'output_rate_packets': '0', + 'input_packets': '0', 'input_bytes': '0', + 'crc_errors': '0', 'output_packets': '0', + 'output_bytes': '0'}, + 'GigabitEthernet0/0/4': {'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'HUAWEI, AR Series, GigabitEthernet0/0/4 Interface', + 'mtu': 1500, + 'mac_address': 'f03f-9566-fc43', + 'time_last_up': '-', + 'system_time': '2022-01-27 16:24:37+01:00', + 'port_mode': 'COMMON COPPER', + 'port_speed': 'FULL', + 'port_negotiation': 'ENABLE', + 'input_rate_bits': '0', + 'input_rate_packets': '0', + 'output_rate_bits': '0', + 'output_rate_packets': '0', + 'input_packets': '0', 'input_bytes': '0', + 'crc_errors': '0', 'output_packets': '0', + 'output_bytes': '0'}, + 'GigabitEthernet0/0/5': { + 'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'VirtualPort', + 'mtu': 1500, + 'mac_address': 'f03f-9566-fc44', + 'time_last_up': '-', + 'system_time': '2022-01-27 16:24:38+01:00', + 'port_mode': 'COMMON COPPER', + 'port_speed': 'FULL', + 'port_negotiation': 'ENABLE', + 'input_rate_bits': '0', + 'input_rate_packets': '0', + 'output_rate_bits': '0', + 'output_rate_packets': '0', + 'input_packets': '0', 'input_bytes': '0', + 'crc_errors': '0', 'output_packets': '0', + 'output_bytes': '0'}, + 'LoopBack0': { + 'admin_status': ' UP', + 'interface_description': 'HUAWEI, AR Series, LoopBack0 Interface', + 'mtu': 1500, 'ip_address': '10.1.1.138', + 'subnet_prefix': '32', + 'subnet_mask': '255.255.255.255', + 'system_time': '2022-01-27 16:24:38+01:00', + 'input_rate_bits': '0', 'input_rate_packets': '0', + 'output_rate_bits': '0', 'output_rate_packets': '0'}, + 'NULL0': { + 'admin_status': ' UP', + 'interface_description': 'HUAWEI, AR Series, NULL0 Interface', + 'mtu': 1500, 'system_time': '2022-01-27 16:24:38+01:00', + 'input_rate_bits': '0', 'input_rate_packets': '0', + 'output_rate_bits': '0', 'output_rate_packets': '0'}, + 'Virtual-Template0': { + 'admin_status': ' UP', 'line_status': True, + 'line_up_since': '2022-01-20 17:52:14 UTC+01:00', + 'interface_description': 'HUAWEI, AR Series, Virtual-Template0 Interface', + 'mtu': 1500, + 'system_time': '2022-01-27 16:24:39+01:00', + 'input_rate_bits': '160', + 'input_rate_packets': '0', + 'output_rate_bits': '8', + 'output_rate_packets': '0'}, + 'Vlanif1': { + 'admin_status': ' Administratively DOWN', + 'line_status': False, + 'interface_description': 'HUAWEI, AR Series, Vlanif1 Interface', + 'mtu': 1500, 'mac_address': 'f03f-9566-fc42', + 'system_time': '2022-01-27 16:24:39+01:00'}} \ No newline at end of file diff --git a/src/genie/libs/parser/hvrp/tests/DisplayInterface/cli/equal/golden_output_output.txt b/src/genie/libs/parser/hvrp/tests/DisplayInterface/cli/equal/golden_output_output.txt new file mode 100644 index 0000000000..7aa0dc1979 --- /dev/null +++ b/src/genie/libs/parser/hvrp/tests/DisplayInterface/cli/equal/golden_output_output.txt @@ -0,0 +1,373 @@ + +display interface +Atm0/0/0 current state : UP +Line protocol current state : UP +Last line protocol up time : 2022-01-20 17:52:13 UTC+01:00 +Description:Connection to TO-VPN # ax10001b # +Route Port,The Maximum Transmit Unit is 1500 +Internet protocol processing : disabled +AAL enabled: AAL5, Maximum PVCs: 16 +PVCs on main-interface: 1 (Total PVCs: 1) +Last physical up time : 2022-01-20 17:52:13 UTC+01:00 +Last physical down time : 2022-01-20 17:49:41 UTC+01:00 +Current system time: 2022-01-27 16:24:34+01:00 + +Port PHY type : VDSL +The physical up times since the system startup : 1 +Last 30 seconds input rate 424 bits/sec, 0 packets/sec +Last 30 seconds output rate 248 bits/sec, 0 packets/sec + +Input: 159078 packets, 16881401 bytes + OAM Cells: 0, ASM Cells: 0 + Packet Errors: 0, Packet Discards: 0 + Cell Errors: 0 + +Output: 60908 packets, 6664962 bytes + OAM Cells: 0, ASM Cells: 0 + Packet Errors: 0, Packet Discards: 0 + Input bandwidth utilization : 0.01% + Output bandwidth utilization : 0.04% + +Cellular0/0/0 current state : Administratively DOWN +Line protocol current state : DOWN +Description:HUAWEI, AR Series, Cellular0/0/0 Interface +Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) +Internet protocol processing : disabled +Last physical up time : - +Last physical down time : 2022-01-20 17:49:42 UTC+01:00 +Current system time: 2022-01-27 16:24:34+01:00 +Modem State: Present +Model = ME909s-120 +Current Network Connection = Unknown +Current RSSI = Unknown +Last 30 seconds input rate 0 bytes/sec 0 bits/sec 0 packets/sec +Last 30 seconds output rate 0 bytes/sec 0 bits/sec 0 packets/sec +Input: 0 packets, 0 bytes + Unicast: 0, Ununicast: 0 + +Output: 0 packets, 0 bytes + Unicast: 0, Ununicast: 0 + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +Cellular0/0/1 current state : Administratively DOWN +Line protocol current state : DOWN +Description:HUAWEI, AR Series, Cellular0/0/1 Interface +Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) +Internet protocol processing : disabled +Last physical up time : - +Last physical down time : 2022-01-20 17:49:42 UTC+01:00 +Current system time: 2022-01-27 16:24:35+01:00 +Modem State: Not present +Last 30 seconds input rate 0 bytes/sec 0 bits/sec 0 packets/sec +Last 30 seconds output rate 0 bytes/sec 0 bits/sec 0 packets/sec +Input: 0 packets, 0 bytes + Unicast: 0, Ununicast: 0 + +Output: 0 packets, 0 bytes + Unicast: 0, Ununicast: 0 + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +GigabitEthernet0/0/0 current state : Administratively DOWN +Line protocol current state : DOWN +Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface +Switch Port, PVID : 1, TPID : 8100(Hex), The Maximum Frame Length is 1800 +IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is f03f-9566-fc42 +Last physical up time : - +Last physical down time : 2022-01-20 17:49:39 UTC+01:00 +Current system time: 2022-01-27 16:24:35+01:00 +Port Mode: COMMON COPPER +Speed : 1000, Loopback: NONE +Duplex: FULL, Negotiation: ENABLE +Mdi : AUTO, Clock : - +Last 30 seconds input rate 0 bits/sec, 0 packets/sec +Last 30 seconds output rate 0 bits/sec, 0 packets/sec +Input peak rate 0 bits/sec,Record time: - +Output peak rate 0 bits/sec,Record time: - + +Input: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + CRC: 0, Giants: 0 + Jabbers: 0, Throttles: 0 + Runts: 0, Symbols: 0 + Ignoreds: 0, Frames: 0 + +Output: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + Collisions: 0, ExcessiveCollisions: 0 + Late Collisions: 0, Deferreds: 0 + + Input bandwidth utilization threshold : 100.00% + Output bandwidth utilization threshold: 100.00% + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +GigabitEthernet0/0/1 current state : Administratively DOWN +Line protocol current state : DOWN +Description:HUAWEI, AR Series, GigabitEthernet0/0/1 Interface +Switch Port, PVID : 1, TPID : 8100(Hex), The Maximum Frame Length is 1800 +IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is f03f-9566-fc42 +Last physical up time : - +Last physical down time : 2022-01-20 17:49:40 UTC+01:00 +Current system time: 2022-01-27 16:24:35+01:00 +Port Mode: COMMON COPPER +Speed : 1000, Loopback: NONE +Duplex: FULL, Negotiation: ENABLE +Mdi : AUTO, Clock : - +Last 30 seconds input rate 0 bits/sec, 0 packets/sec +Last 30 seconds output rate 0 bits/sec, 0 packets/sec +Input peak rate 0 bits/sec,Record time: - +Output peak rate 0 bits/sec,Record time: - + +Input: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + CRC: 0, Giants: 0 + Jabbers: 0, Throttles: 0 + Runts: 0, Symbols: 0 + Ignoreds: 0, Frames: 0 + +Output: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + Collisions: 0, ExcessiveCollisions: 0 + Late Collisions: 0, Deferreds: 0 + + Input bandwidth utilization threshold : 100.00% + Output bandwidth utilization threshold: 100.00% + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +GigabitEthernet0/0/2 current state : Administratively DOWN +Line protocol current state : DOWN +Description:HUAWEI, AR Series, GigabitEthernet0/0/2 Interface +Switch Port, PVID : 1, TPID : 8100(Hex), The Maximum Frame Length is 1800 +IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is f03f-9566-fc42 +Last physical up time : - +Last physical down time : 2022-01-20 17:49:40 UTC+01:00 +Current system time: 2022-01-27 16:24:36+01:00 +Port Mode: COMMON COPPER +Speed : 1000, Loopback: NONE +Duplex: FULL, Negotiation: ENABLE +Mdi : AUTO, Clock : - +Last 30 seconds input rate 0 bits/sec, 0 packets/sec +Last 30 seconds output rate 0 bits/sec, 0 packets/sec +Input peak rate 0 bits/sec,Record time: - +Output peak rate 0 bits/sec,Record time: - + +Input: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + CRC: 0, Giants: 0 + Jabbers: 0, Throttles: 0 + Runts: 0, Symbols: 0 + Ignoreds: 0, Frames: 0 + +Output: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + Collisions: 0, ExcessiveCollisions: 0 + Late Collisions: 0, Deferreds: 0 + + Input bandwidth utilization threshold : 100.00% + Output bandwidth utilization threshold: 100.00% + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +GigabitEthernet0/0/3 current state : Administratively DOWN +Line protocol current state : DOWN +Description:HUAWEI, AR Series, GigabitEthernet0/0/3 Interface +Switch Port, PVID : 1, TPID : 8100(Hex), The Maximum Frame Length is 1800 +IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is f03f-9566-fc42 +Last physical up time : - +Last physical down time : 2022-01-20 17:49:41 UTC+01:00 +Current system time: 2022-01-27 16:24:36+01:00 +Port Mode: COMMON COPPER +Speed : 1000, Loopback: NONE +Duplex: FULL, Negotiation: ENABLE +Mdi : AUTO, Clock : - +Last 30 seconds input rate 0 bits/sec, 0 packets/sec +Last 30 seconds output rate 0 bits/sec, 0 packets/sec +Input peak rate 0 bits/sec,Record time: - +Output peak rate 0 bits/sec,Record time: - + +Input: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + CRC: 0, Giants: 0 + Jabbers: 0, Throttles: 0 + Runts: 0, Symbols: 0 + Ignoreds: 0, Frames: 0 + +Output: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + Collisions: 0, ExcessiveCollisions: 0 + Late Collisions: 0, Deferreds: 0 + + Input bandwidth utilization threshold : 100.00% + Output bandwidth utilization threshold: 100.00% + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +GigabitEthernet0/0/4 current state : Administratively DOWN +Line protocol current state : DOWN +Description:HUAWEI, AR Series, GigabitEthernet0/0/4 Interface +Route Port,The Maximum Transmit Unit is 1500 +Internet protocol processing : disabled +IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is f03f-9566-fc43 +Last physical up time : - +Last physical down time : 2022-01-20 17:49:39 UTC+01:00 +Current system time: 2022-01-27 16:24:37+01:00 +Port Mode: COMMON COPPER +Speed : 1000, Loopback: NONE +Duplex: FULL, Negotiation: ENABLE +Mdi : AUTO, Clock : - +Last 30 seconds input rate 0 bits/sec, 0 packets/sec +Last 30 seconds output rate 0 bits/sec, 0 packets/sec +Input peak rate 0 bits/sec,Record time: - +Output peak rate 0 bits/sec,Record time: - + +Input: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + CRC: 0, Giants: 0 + Jabbers: 0, Throttles: 0 + Runts: 0, Symbols: 0 + Ignoreds: 0, Frames: 0 + +Output: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + Collisions: 0, ExcessiveCollisions: 0 + Late Collisions: 0, Deferreds: 0 + + Input bandwidth utilization threshold : 100.00% + Output bandwidth utilization threshold: 100.00% + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +GigabitEthernet0/0/5 current state : Administratively DOWN +Line protocol current state : DOWN +Description:VirtualPort +Route Port,The Maximum Transmit Unit is 1500 +Internet protocol processing : disabled +IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is f03f-9566-fc44 +Last physical up time : - +Last physical down time : 2022-01-20 17:49:41 UTC+01:00 +Current system time: 2022-01-27 16:24:38+01:00 +Port Mode: COMMON COPPER +Speed : 1000, Loopback: NONE +Duplex: FULL, Negotiation: ENABLE +Mdi : AUTO, Clock : - +Last 30 seconds input rate 0 bits/sec, 0 packets/sec +Last 30 seconds output rate 0 bits/sec, 0 packets/sec +Input peak rate 0 bits/sec,Record time: - +Output peak rate 0 bits/sec,Record time: - + +Input: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + CRC: 0, Giants: 0 + Jabbers: 0, Throttles: 0 + Runts: 0, Symbols: 0 + Ignoreds: 0, Frames: 0 + +Output: 0 packets, 0 bytes + Unicast: 0, Multicast: 0 + Broadcast: 0, Jumbo: 0 + Discard: 0, Total Error: 0 + + Collisions: 0, ExcessiveCollisions: 0 + Late Collisions: 0, Deferreds: 0 + + Input bandwidth utilization threshold : 100.00% + Output bandwidth utilization threshold: 100.00% + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +LoopBack0 current state : UP +Line protocol current state : UP (spoofing) +Description:HUAWEI, AR Series, LoopBack0 Interface +Route Port,The Maximum Transmit Unit is 1500 +Internet Address is 10.1.1.138/32 +Physical is Loopback +Current system time: 2022-01-27 16:24:38+01:00 + Last 30 seconds input rate 0 bits/sec, 0 packets/sec + Last 30 seconds output rate 0 bits/sec, 0 packets/sec + Realtime 0 seconds input rate 0 bits/sec, 0 packets/sec + Realtime 0 seconds output rate 0 bits/sec, 0 packets/sec + Input: 0 bytes + Output:0 bytes + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +NULL0 current state : UP +Line protocol current state : UP (spoofing) +Description:HUAWEI, AR Series, NULL0 Interface +Route Port,The Maximum Transmit Unit is 1500 +Internet protocol processing : disabled +Physical is NULL DEV +Current system time: 2022-01-27 16:24:38+01:00 + Last 30 seconds input rate 0 bits/sec, 0 packets/sec + Last 30 seconds output rate 0 bits/sec, 0 packets/sec + Realtime 0 seconds input rate 0 bits/sec, 0 packets/sec + Realtime 0 seconds output rate 0 bits/sec, 0 packets/sec + Input: 0 bytes + Output:10100 bytes + Input bandwidth utilization : 0% + Output bandwidth utilization : 0% + +Virtual-Template0 current state : UP +Line protocol current state : UP +Last line protocol up time : 2022-01-20 17:52:14 UTC+01:00 +Description:HUAWEI, AR Series, Virtual-Template0 Interface +Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) +Internet Address is unnumbered, using address of LoopBack0(10.1.1.138/32) +Link layer protocol is PPP +LCP initial +Physical is None +Current system time: 2022-01-27 16:24:39+01:00 + Last 30 seconds input rate 160 bits/sec, 0 packets/sec + Last 30 seconds output rate 8 bits/sec, 0 packets/sec + Realtime 0 seconds input rate 0 bits/sec, 0 packets/sec + Realtime 0 seconds output rate 0 bits/sec, 0 packets/sec + Input: 4089628 bytes + Output:982860 bytes + Input bandwidth utilization : 0.25% + Output bandwidth utilization : 0.01% + +Vlanif1 current state : Administratively DOWN +Line protocol current state : DOWN +Description:HUAWEI, AR Series, Vlanif1 Interface +Route Port,The Maximum Transmit Unit is 1500 +Internet protocol processing : disabled +IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is f03f-9566-fc42 +Current system time: 2022-01-27 16:24:39+01:00 + Input bandwidth utilization : -- + Output bandwidth utilization : -- \ No newline at end of file diff --git a/src/genie/libs/parser/hvrp/tests/DisplayStaticRoute/cli/empty/empty_output_output.txt b/src/genie/libs/parser/hvrp/tests/DisplayStaticRoute/cli/empty/empty_output_output.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/genie/libs/parser/hvrp/tests/DisplayStaticRoute/cli/equal/golden_output_expected.py b/src/genie/libs/parser/hvrp/tests/DisplayStaticRoute/cli/equal/golden_output_expected.py new file mode 100644 index 0000000000..2517697eff --- /dev/null +++ b/src/genie/libs/parser/hvrp/tests/DisplayStaticRoute/cli/equal/golden_output_expected.py @@ -0,0 +1,103 @@ +expected_output = { + 'ip_routes': { + '0.0.0.0/0/1.1.1.2': { + 'ip_version': '4', + 'next_hop': '1.1.1.2', + 'preference': '', + 'route_name': '', + 'subnet': '0.0.0.0', + 'subnet_mask': '0.0.0.0', + 'subnet_prefix': '0', + }, + '0.0.0.0/0/192.168.12.42': { + 'ip_version': '4', + 'next_hop': '192.168.12.42', + 'preference': '1', + 'route_name': '', + 'subnet': '0.0.0.0', + 'subnet_mask': '0.0.0.0', + 'subnet_prefix': '0', + }, + '145.13.71.128/25/192.168.12.42': { + 'ip_version': '4', + 'next_hop': '192.168.12.42', + 'preference': '1', + 'route_name': '', + 'subnet': '145.13.71.128', + 'subnet_mask': '255.255.255.128', + 'subnet_prefix': '25', + }, + '145.13.71.128/25/NULL0': { + 'ip_version': '4', + 'next_hop': 'NULL0', + 'preference': '250', + 'route_name': '', + 'subnet': '145.13.71.128', + 'subnet_mask': '255.255.255.128', + 'subnet_prefix': '25', + }, + '145.13.76.0/24/192.168.12.42': { + 'ip_version': '4', + 'next_hop': '192.168.12.42', + 'preference': '1', + 'route_name': '', + 'subnet': '145.13.76.0', + 'subnet_mask': '255.255.255.0', + 'subnet_prefix': '24', + }, + '145.13.76.0/24/NULL0': { + 'ip_version': '4', + 'next_hop': 'NULL0', + 'preference': '250', + 'route_name': '', + 'subnet': '145.13.76.0', + 'subnet_mask': '255.255.255.0', + 'subnet_prefix': '24', + }, + '145.7.64.247/32/NULL0': { + 'ip_version': '4', + 'next_hop': 'NULL0', + 'preference': '250', + 'route_name': '', + 'subnet': '145.7.64.247', + 'subnet_mask': '255.255.255.255', + 'subnet_prefix': '32', + }, + '192.168.28.0/24/192.168.12.42': { + 'ip_version': '4', + 'next_hop': '192.168.12.42', + 'preference': '1', + 'route_name': '', + 'subnet': '192.168.28.0', + 'subnet_mask': '255.255.255.0', + 'subnet_prefix': '24', + }, + '192.168.28.0/24/NULL0': { + 'ip_version': '4', + 'next_hop': 'NULL0', + 'preference': '250', + 'route_name': 'testroute', + 'subnet': '192.168.28.0', + 'subnet_mask': '255.255.255.0', + 'subnet_prefix': '24', + }, + '2A07:3500:1BC0::/3/2A07:3500:1BC0::F001:1002': { + 'ip_version': '6', + 'next_hop': '2A07:3500:1BC0::F001:1002', + 'preference': '', + 'route_name': 'testroute-3', + 'subnet': '2A07:3500:1BC0::', + 'subnet_mask': '49', + 'subnet_prefix': '3', + }, + '::/0/2001:67C:2504:F009::15A': { + 'ip_version': '6', + 'next_hop': '2001:67C:2504:F009::15A', + 'preference': '1', + 'route_name': 'testroute-2', + 'subnet': '::', + 'subnet_mask': '0', + 'subnet_prefix': '0', + }, + }, +} diff --git a/src/genie/libs/parser/hvrp/tests/DisplayStaticRoute/cli/equal/golden_output_output.txt b/src/genie/libs/parser/hvrp/tests/DisplayStaticRoute/cli/equal/golden_output_output.txt new file mode 100644 index 0000000000..3db3ddbb17 --- /dev/null +++ b/src/genie/libs/parser/hvrp/tests/DisplayStaticRoute/cli/equal/golden_output_output.txt @@ -0,0 +1,11 @@ +ip route-static 0.0.0.0 0.0.0.0 192.168.12.42 preference 1 +ip route-static 0.0.0.0 0.0.0.0 1.1.1.2 track bfd-session aa +ip route-static 145.7.64.247 255.255.255.255 NULL0 preference 250 +ip route-static 145.13.71.128 255.255.255.128 192.168.12.42 preference 1 +ip route-static 145.13.71.128 255.255.255.128 NULL0 preference 250 +ip route-static 145.13.76.0 255.255.255.0 192.168.12.42 preference 1 +ip route-static 145.13.76.0 255.255.255.0 NULL0 preference 250 +ip route-static 192.168.28.0 255.255.255.0 192.168.12.42 preference 1 +ip route-static 192.168.28.0 255.255.255.0 NULL0 preference 250 description testroute +ipv6 route-static :: 0 2001:67C:2504:F009::15A preference 1 description testroute-2 +ipv6 route-static 2A07:3500:1BC0:: 49 2A07:3500:1BC0::F001:1002 description testroute-3 \ No newline at end of file