napalm-automation-community / napalm-h3c-cw7-ssh

NAPALM driver for H3C Comware V7, over SSH
Apache License 2.0
22 stars 9 forks source link

driver.get_interfaces() only one interface #1

Closed mclee23 closed 2 years ago

mclee23 commented 2 years ago

H3C S6520 SW

"display interface" result like this:

"""

display interface Bridge-Aggregation35 Current state: UP Line protocol state: UP IP packet frame type: Ethernet II, hardware address: 600b-038a-a395 Description: fw Bandwidth: 40000000 kbps 40Gbps-speed mode, full-duplex mode Link speed type is autonegotiation, link duplex type is autonegotiation PVID: 1 Port link-type: Trunk VLAN Passing: 1(default vlan), 12-13, 16-19, 21, 23, 160, 168, 192-193, 1706 VLAN permitted: 1(default vlan), 2-4094 Trunk port encapsulation: IEEE 802.1q Last clearing of counters: Never Last 300 seconds input: 11479 packets/sec 3640495 bytes/sec 0% Last 300 seconds output: 11574 packets/sec 3648299 bytes/sec 0% Input (total): 71053448389 packets, 47565916009556 bytes 71027994700 unicasts, 1105740 broadcasts, 24347949 multicasts, 0 pauses Input (normal): 71053448388 packets, - bytes 71027994700 unicasts, 1105740 broadcasts, 24347949 multicasts, 0 pauses Input: 0 input errors, 0 runts, 0 giants, 0 throttles 0 CRC, 0 frame, - overruns, 0 aborts - ignored, - parity errors Output (total): 71382158739 packets, 47594556534427 bytes 71322766211 unicasts, 19229074 broadcasts, 40163454 multicasts, 0 pauses Output (normal): 71382158732 packets, - bytes 71322766210 unicasts, 19229074 broadcasts, 40163454 multicasts, 0 pauses Output: 0 output errors, - underruns, - buffer failures 0 aborts, 0 deferred, 0 collisions, 0 late collisions 0 lost carrier, - no carrier Bridge-Aggregation38 Current state: UP Line protocol state: UP IP packet frame type: Ethernet II, hardware address: 600b-038a-a395 Description: abc Bandwidth: 40000000 kbps 40Gbps-speed mode, full-duplex mode Link speed type is autonegotiation, link duplex type is autonegotiation PVID: 1 Port link-type: Trunk VLAN Passing: 1(default vlan), 12-13, 16-19, 21, 23, 160, 168, 192-193, 1706 VLAN permitted: 1(default vlan), 2-4094 Trunk port encapsulation: IEEE 802.1q Last clearing of counters: Never Last 300 seconds input: 109 packets/sec 8177 bytes/sec 0% Last 300 seconds output: 120 packets/sec 9418 bytes/sec 0% Input (total): 130998977 packets, 18556616169 bytes 130100036 unicasts, 109839 broadcasts, 789102 multicasts, 0 pauses Input (normal): 130998977 packets, - bytes 130100036 unicasts, 109839 broadcasts, 789102 multicasts, 0 pauses Input: 0 input errors, 0 runts, 0 giants, 0 throttles 0 CRC, 0 frame, - overruns, 0 aborts - ignored, - parity errors Output (total): 174932435 packets, 24434894669 bytes 137650820 unicasts, 20442493 broadcasts, 16839122 multicasts, 0 pauses Output (normal): 174932435 packets, - bytes 137650820 unicasts, 20442493 broadcasts, 16839122 multicasts, 0 pauses Output: 0 output errors, - underruns, - buffer failures 0 aborts, 0 deferred, 0 collisions, 0 late collisions 0 lost carrier, - no carrier Bridge-Aggregation47 Current state: UP Line protocol state: UP IP packet frame type: Ethernet II, hardware address: 600b-038a-a395 Description: vpc1 Bandwidth: 20000000 kbps 20Gbps-speed mode, full-duplex mode Link speed type is autonegotiation, link duplex type is autonegotiation PVID: 1 Port link-type: Trunk VLAN Passing: 1(default vlan), 12-13, 16-19, 21, 23, 160, 168, 192-193, 1706 VLAN permitted: 1(default vlan), 2-4094 Trunk port encapsulation: IEEE 802.1q Last clearing of counters: Never Last 300 seconds input: 5978 packets/sec 1780706 bytes/sec 0% Last 300 seconds output: 5574 packets/sec 1868151 bytes/sec 0% Input (total): 38336468925 packets, 28317447377454 bytes 38304843420 unicasts, 13089512 broadcasts, 18535993 multicasts, 0 pauses Input (normal): 38336468925 packets, - bytes 38304843420 unicasts, 13089512 broadcasts, 18535993 multicasts, 0 pauses Input: 0 input errors, 0 runts, 0 giants, 0 throttles 0 CRC, 0 frame, - overruns, 0 aborts - ignored, - parity errors Output (total): 35882826538 packets, 23256221052935 bytes 35874915425 unicasts, 4561193 broadcasts, 3349920 multicasts, 0 pauses Output (normal): 35882826538 packets, - bytes 35874915425 unicasts, 4561193 broadcasts, 3349920 multicasts, 0 pauses Output: 0 output errors, - underruns, - buffer failures 0 aborts, 0 deferred, 0 collisions, 0 late collisions 0 lost carrier, - no carrier FortyGigE1/0/49 Current state: Administratively DOWN Line protocol state: DOWN IP packet frame type: Ethernet II, hardware address: b845-f47a-9a74 Description: NO-USE Bandwidth: 40000000 kbps Loopback is not set Media type is optical fiber, Port hardware type is 40G_BASE_CSR4_QSFP_PLUS Unknown-speed mode, unknown-duplex mode Link speed type is autonegotiation, link duplex type is autonegotiation Flow-control is not enabled Maximum frame length: 10000 Allow jumbo frames to pass Broadcast max-ratio: 100% Multicast max-ratio: 100% Unicast max-ratio: 100% PVID: 1 MDI type: Automdix Port link-type: Access Tagged VLANs: None Untagged VLANs: 1 Port priority: 0 Last link flapping: Never Last clearing of counters: Never Current system time:2022-04-29 21:27:56 beijing+08:00:00 Last time when physical state changed to up:- Last time when physical state changed to down:2013-01-01 03:12:55 beijing+08:00:00 Peak input rate: 0 bytes/sec, at 2022-03-30 16:38:41 Peak output rate: 0 bytes/sec, at 2022-03-30 16:38:41 Last 300 seconds input: 0 packets/sec 0 bytes/sec -% Last 300 seconds output: 0 packets/sec 0 bytes/sec -% Input (total): 0 packets, 0 bytes 0 unicasts, 0 broadcasts, 0 multicasts, 0 pauses Input (normal): 0 packets, - bytes 0 unicasts, 0 broadcasts, 0 multicasts, 0 pauses Input: 0 input errors, 0 runts, 0 giants, 0 throttles 0 CRC, 0 frame, - overruns, 0 aborts - ignored, - parity errors Output (total): 0 packets, 0 bytes 0 unicasts, 0 broadcasts, 0 multicasts, 0 pauses Output (normal): 0 packets, - bytes 0 unicasts, 0 broadcasts, 0 multicasts, 0 pauses Output: 0 output errors, - underruns, - buffer failures 0 aborts, 0 deferred, 0 collisions, 0 late collisions 0 lost carrier, - no carrier IPv4 traffic statistics: Last 300 seconds input rate: 0 packets/sec, 0 bytes/sec Last 300 seconds output rate: 0 packets/sec, 0 bytes/sec Input: 0 packets, 0 bytes Output: 0 packets, 0 bytes IPv6 traffic statistics: Last 300 seconds input rate: 0 packets/sec, 0 bytes/sec Last 300 seconds output rate: 0 packets/sec, 0 bytes/sec Input: 0 packets, 0 bytes Output: 0 packets, 0 bytes """ print result: [{'interface': 'Bridge-Aggregation35', 'link_status': 'UP', 'protocol_status': 'UP', 'mac_address': '600b-038a-a395', 'description': 'fw', 'bandwidth': '40000000', 'mtu': '', 'speed_mode': '40Gbps', 'duplex_mode': 'full', 'media_type': '', 'hardware_type': '', 'pvid': '1', 'link_type': 'Trunk', 'last_flapping': '', 'primary_ipaddr': '', 'rx_pkts': '86689781', 'rx_bytes': '-', 'rx_unicast': '0', 'rx_broadcast': '0', 'rx_multicast': '1976648', 'rx_errors': '0', 'rx_aborts': '', 'rx_crc': '', 'tx_pkts': '', 'tx_bytes': '', 'tx_unicast': '', 'tx_broadcast': '', 'tx_multicast': '', 'tx_errors': '', 'tx_aborts': ''}] {'Bridge-Aggregation35': {'is_enabled': True, 'is_up': True, 'description': 'fw', 'speed': 40000000, 'mtu': -1, 'mac_address': '60:0B:03:8A:A3:95', 'last_flapped': -1}} only one port
mclee23 commented 2 years ago

def _get_structured_output(self, command: str, template_name: str = None): """ Wrapper for napalm.base.helpers.textfsm_extractor(). """ if template_name is None: templatename = "".join(command.split()) raw_output = self.send_command(command) print(raw_output) # raw_output: get all interface result = textfsm_extractor(self, template_name, raw_output) print(result) # only one port return result

is template wrong ???