Skip to content

lf_interop_ping.py : Added Real + Virtual and pinging devices / ip's from a particular ip provided(--sta_port)#64

Open
manoj9088 wants to merge 2 commits into
masterfrom
interop_ping_vr
Open

lf_interop_ping.py : Added Real + Virtual and pinging devices / ip's from a particular ip provided(--sta_port)#64
manoj9088 wants to merge 2 commits into
masterfrom
interop_ping_vr

Conversation

@manoj9088
Copy link
Copy Markdown
Collaborator

No description provided.

manoj9088 added 2 commits May 21, 2026 12:44
…-clients_type -> Real Clients, Virtual Stations, Existing Virtual Stations, Real + Virtual Stations"

Signed-off-by: Manoj9088 <manoj.kolluru@candelatech.com>
… clients type Real, Virtual, Existing Station List, Real + Virtual, Real + Existing Station and Added functionality of Pinging different ips from one ip(--sta_port)

VERIFIED CLI:

1.python3 lf_interop_ping.py --mgr 192.168.207.78  --ping_interval 5 --ping_duration 1  --expected_passfail_value 5 --clients_type both --target 8.8.8.8 --num_sta 5 --ssid NETGEAR_5G_wpa2 --passwd Password@123 --security wpa2 --radio 1.1.wiphy1 --use_default_config

2.python3 lf_interop_ping.py --mgr 192.168.207.78  --ping_interval 5 --ping_duration 1  --expected_passfail_value 5 --clients_type real  --sta_to_res --sta_port 1.1.eth1  --use_default_config --res_ip 192.168.204.84 --device_list 1.4,1.15

Signed-off-by: Manoj9088 <manoj.kolluru@candelatech.com>
Comment on lines +185 to +221
if use_existing_sta_list:
logger.info(f"Using existing stations provided in --existing_sta_list: {existing_sta_list}")
lis = existing_sta_list.split(',') if existing_sta_list else []
logger.info(lis)
valid_stations = []
for station in lis:
logger.info(f"Verifying station {station} from the provided --existing_sta_list")
station = station.strip()
rv = station.split('.')
response = self.json_get(f"/port/{rv[0]}/{rv[1]}/{rv[2]}")

try:
if (response['interface']
and response['interface']['ip'] != "0.0.0.0"
and str(response['interface']['down']).lower() == "false"
and str(response['interface']['phantom']).lower() == "false"
and response['interface']['parent dev'] != ""):

logger.info(f"Station {station} exists and will be used for the test")
valid_stations.append(station)
else:
logger.info(f"Station {station} is not up and running")

except Exception:
logger.warning(f"Station {station} does not exist")

lis = valid_stations
if lis == []:
if not self.real:
logger.info("No valid stations found in the provided --existing_sta_list, exiting the test")
exit(1)
else:
logger.info("no valid stations so proceding with the real clients only")
self.virtual = False
self.sta_list = lis
logger.info(f"final station list {self.sta_list}")
self.use_existing_sta_list = use_existing_sta_list
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this is to seperate class function . try to keep __init__ and main() clean.

self.wait_time = wait_time

self.last_written_seq = {}
# self.last_Result_per_Station = {}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unecccesary comments

Comment on lines +427 to +429
def monitor_virtual(self, result_data, ports_data, ping_stats, rtts, rtts_list):
if isinstance(result_data, dict):
for station in self.sta_list:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstring comment to the function describing it's functionality.

temp_last_results = result_data['last results'].split('\n')[0: len(result_data['last results']) - 1]
drop_count = 0 # let dropped = 0 initially
dropped_packets = []
# sample result - 64 bytes from 192.168.1.61: icmp_seq=28 time=3.66 ms *** drop: 0 (0, 0.000) rx: 28 fail: 0 bytes: 1792 min/avg/max: 2.160/3.422/5.190
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in line comments are looking good! it really helps for tracing the code.

self.result_json[station]['rtts'] = {}
self.result_json[station]['rtts'] = rtts[station]
self.result_json[station]['remarks'] = self.generate_remarks(self.result_json[station])
# self.result_json[station]['dropped_packets'] = dropped_packets
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unnecessary comment

Comment thread py-scripts/lf_interop_ping.py Outdated
Comment on lines +591 to +593
# Sets the result json for real stations and also populates ping_stats and rtts which are used for generating remarks and graphs respectively
def monitor_real(self, result_data, Devices, ping_stats, rtts, rtts_list):
devices = self.real_sta_list
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstring comment!

self.result_json[station]['rtts'] = rtts[station]
self.result_json[station]['remarks'] = self.generate_remarks(self.result_json[station])

# logger.info(f"current device data {current_device_data} for station {station}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all unnecessary comments.

Comment on lines +849 to +851
def generate_real_time_csv(self):
csv_dir = "csv_reports"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docstring comment

Comment on lines +1003 to +1005
def get_safe_last_result(self, last_results):
if not last_results or last_results.strip() == "":
return ""
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docstring comment

Comment on lines +1051 to +1052
except Exception:
pass
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing the exception . log some error.

Comment on lines 1077 to +1092
@@ -426,9 +1083,13 @@ def change_port_to_ip(self, upstream_port):
upstream_port = target_port_ip
except Exception:
logging.warning(f'The upstream port is not an ethernet port. Proceeding with the given upstream_port {upstream_port}.')
logging.info(f"Upstream port IP {upstream_port}")
if skip_info_logs:
return ""
if not skip_info_logs:
logging.info(f"Upstream port IP {upstream_port}")
else:
logging.info(f"Upstream port IP {upstream_port}")
if not skip_info_logs:
logging.info(f"Upstream port IP {upstream_port}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these changes should come in sta_to_res commit

# When expected_passfail_val is provided, for pass/fail criteria, the same value will be used for all clients
else:
self.test_input_list = [self.expected_passfail_val for val in range(len(self.device_names))]
lis = self.res_ip_list if self.sta_to_res else self.sta_list
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd commit

Comment on lines +1329 to +1346
if self.sta_to_res:
self.packets_sent.append(int(device_data['sent']))
self.packets_received.append(int(device_data['recv']))
self.packets_dropped.append(int(device_data['dropped']))

# print("device",device)
# device_key = device.split('-')[0]
print(self.cx_dev_map)
print(self.cx_ip_map)
if device in self.cx_dev_map and self.cx_dev_map[device] != "":
device_name = "{}/{}".format(self.cx_dev_map[device], self.cx_ip_map[device])
else:
try:
device_name = self.cx_ip_map[device]
except Exception:
device_name = device
self.device_names.append(device_name) # endpoint key only
self.report_names.append(device_name)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to 2nd commit. since sta_to_res changes are there in 2nd commit

Comment on lines +1941 to +1944
optional.add_argument('--clients_type',
type=str,
help='specify the client type example: real or virtual or both',
default="")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add option of --client_type

ping.stop_generic()
timestamp = (timedelta(minutes=int(ping.duration)) + ping.start_time).strftime("%d/%m/%Y %H:%M:%S")
csv_dir = "csv_reports"
print(f"ping.result_json: \n \n{ping.result_json}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to loggers

Comment on lines +2331 to +2336
# logger.info(ping.result_json)

# station post cleanup
ping.cleanup()

# if args.sta_to_res:
# ping.generate_generic_report()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants