Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 0 additions & 116 deletions ansible/library/show_ipv6_interface.py

This file was deleted.

35 changes: 0 additions & 35 deletions docs/api_wiki/ansible_methods/show_ipv6_interface.md

This file was deleted.

45 changes: 3 additions & 42 deletions tests/common/devices/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ def _show_and_parse_crm_resources():
logging.warning("CRM counters are not ready yet, will retry after 10 seconds")
time.sleep(10)
timeout -= 10
assert(timeout >= 0)
assert (timeout >= 0)

return crm_facts

Expand Down Expand Up @@ -2198,32 +2198,6 @@ def ping_v4(self, ipv4, count=1, ns_arg=""):
return False
return True

def ping_v6(self, ipv6, count=1, ns_arg=""):
"""
Returns 'True' if ping to IP address works, else 'False'
Args:
IPv6 address

Returns:
True or False
"""
try:
socket.inet_pton(socket.AF_INET6, ipv6)
except socket.error:
raise Exception("Invalid IPv6 address {}".format(ipv6))

netns_arg = ""
if ns_arg is not DEFAULT_NAMESPACE:
netns_arg = "sudo ip netns exec {} ".format(ns_arg)

try:
self.shell("{}ping -6 -q -c{} {} > /dev/null".format(
netns_arg, count, ipv6
))
except RunAnsibleModuleFail:
return False
return True

def is_backend_portchannel(self, port_channel, mg_facts):
ports = mg_facts["minigraph_portchannels"].get(port_channel)
# minigraph facts does not have backend portchannel IFs
Expand All @@ -2234,21 +2208,17 @@ def is_backend_portchannel(self, port_channel, mg_facts):
def is_backend_port(self, port, mg_facts):
return True if "Ethernet-BP" in port else False

def active_ip_interfaces(self, ip_ifs, tbinfo, ns_arg=DEFAULT_NAMESPACE, intf_num="all", ipv6_ifs=None):
def active_ip_interfaces(self, ip_ifs, tbinfo, ns_arg=DEFAULT_NAMESPACE, intf_num="all"):
"""
Return a dict of active IP (Ethernet or PortChannel) interfaces, with
interface and peer IPv4 address.

If ipv6_ifs exists, also returns the interfaces' IPv6 address and its peer
IPv6 addresses if found for each interface.

Returns:
Dict of Interfaces and their IPv4 address (with IPv6 if ipv6_ifs exists)
Dict of Interfaces and their IPv4 address
"""
active_ip_intf_cnt = 0
mg_facts = self.get_extended_minigraph_facts(tbinfo, ns_arg)
ip_ifaces = {}

for k, v in list(ip_ifs.items()):
if ((k.startswith("Ethernet") and not is_inband_port(k)) or
(k.startswith("PortChannel") and not
Expand All @@ -2264,15 +2234,6 @@ def active_ip_interfaces(self, ip_ifs, tbinfo, ns_arg=DEFAULT_NAMESPACE, intf_nu
}
active_ip_intf_cnt += 1

if ipv6_ifs:
ipv6_intf = ipv6_ifs[k]
if (ipv6_intf["peer_ipv6"] != "N/A" and self.ping_v6(ipv6_intf["peer_ipv6"],
count=3, ns_arg=ns_arg)):
ip_ifaces[k].update({
"ipv6": ipv6_intf["ipv6"],
"peer_ipv6": ipv6_intf["peer_ipv6"]
})

if isinstance(intf_num, int) and intf_num > 0 and active_ip_intf_cnt == intf_num:
break

Expand Down
25 changes: 3 additions & 22 deletions tests/common/devices/sonic_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,6 @@ def show_ip_interface(self, *module_args, **complex_args):
complex_args['namespace'] = self.namespace
return self.sonichost.show_ip_interface(*module_args, **complex_args)

def show_ipv6_interface(self, *module_args, **complex_args):
"""Wrapper for the ansible module 'show_ipv6_interface'

Args:
module_args: other ansible module args passed from the caller
complex_args: other ansible keyword args

Returns:
[dict]: [the output of show ipv6 interface status command]
"""
complex_args['namespace'] = self.namespace
return self.sonichost.show_ipv6_interface(*module_args, **complex_args)

def run_sonic_db_cli_cmd(self, sonic_db_cmd):
cmd = "{} {}".format(self.sonic_db_cli, sonic_db_cmd)
return self.sonichost.command(cmd, verbose=False)
Expand Down Expand Up @@ -294,23 +281,17 @@ def is_backend_portchannel(self, port_channel):
return False
return True

def get_active_ip_interfaces(self, tbinfo, intf_num="all", include_ipv6=False):
def get_active_ip_interfaces(self, tbinfo, intf_num="all"):
"""
Return a dict of active IP (Ethernet or PortChannel) interfaces, with
interface and peer IPv4 address.

If include_ipv6 is true, also returns IPv6 and its peer IPv6 addresses.

Returns:
Dict of Interfaces and their IPv4 address (with IPv6 if include_ipv6 option is true)
Dict of Interfaces and their IPv4 address
"""
ipv6_ifs = None
ip_ifs = self.show_ip_interface()["ansible_facts"]["ip_interfaces"]
if include_ipv6:
ipv6_ifs = self.show_ipv6_interface()["ansible_facts"]["ipv6_interfaces"]

return self.sonichost.active_ip_interfaces(
ip_ifs, tbinfo, self.namespace, intf_num=intf_num, ipv6_ifs=ipv6_ifs
ip_ifs, tbinfo, self.namespace, intf_num=intf_num
)

def bgp_drop_rule(self, ip_version, state="present"):
Expand Down
Loading