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
4 changes: 2 additions & 2 deletions framework/python/src/net_orc/ip_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ def configure_container_interface(self,
return False
return True

def ping_via_gateway(self, host):
def ping_via_gateway(self, host: str) -> bool:
"""Ping the host trough the gateway container"""
command = f'timeout 3 docker exec tr-ct-gateway ping -W 1 -c 1 {host}'
output = util.run_command(command, supress_error=True)
if '0% packet loss' in output[0]:
if re.search(r'\s0% packet loss', output[0]):
return True
return False

Expand Down
7 changes: 5 additions & 2 deletions framework/python/src/net_orc/network_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import ipaddress
import json
import os
import re
from scapy.all import sniff, wrpcap, BOOTP, AsyncSniffer
from scapy.error import Scapy_Exception
import shutil
Expand Down Expand Up @@ -356,8 +357,10 @@ def _ping(self, net_module):
host = net_module.net_config.ipv4_address
namespace = 'tr-ctns-' + net_module.dir_name
cmd = 'ip netns exec ' + namespace + ' ping -c 1 ' + str(host)
success = util.run_command(cmd, output=False)
return success
out, _ = util.run_command(cmd, supress_error=True)
if re.search(r'\s0% packet loss', out):
return True
return False

def _ci_pre_network_create(self):
""" Stores network properties to restore network after
Expand Down
Loading