Skip to content

Commit

Permalink
feat: add function
Browse files Browse the repository at this point in the history
    * get_interfaces_ip()
  • Loading branch information
xdai555 committed Feb 18, 2022
1 parent d759e56 commit 234e9f3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 17 additions & 1 deletion napalm_h3c_comware/comware.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,23 @@ def get_arp_table(self, vrf: str = ""):
arp_table.append(entry)
return arp_table

def get_interfaces_ip(self): ...
def get_interfaces_ip(self):
interfaces = {}
command = "display ip interface"
structured_output = self._get_structured_output(command)
for iface_entry in structured_output:
interface, ip_list = itemgetter(
"interface", "ip_address"
)(iface_entry)
ipv4 = {}
if len(ip_list) > 0:
for ip in ip_list:
ipv4[ip.split("/")[0]
] = {"prefix_length": int(ip.split("/")[1])}
interfaces[interface] = {
"ipv4": ipv4
}
return interfaces

def get_mac_address_move_table(self):
mac_address_move_table = []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Value INTERFACE (\S+)
Value List IP_ADDRESS (\d+(\.\d+){3}\/\d+)

Start
^\S+\s+current\s+state -> Continue.Record
^${INTERFACE}\s+current\s+state
^Internet\s+Address\s+is\s+${IP_ADDRESS}\s+Primary -> Continue
^Internet\s+Address\s+is\s+${IP_ADDRESS}\s+Sub -> Continue

0 comments on commit 234e9f3

Please sign in to comment.