mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 04:07:52 +00:00
layer 3 cx prints data on console in l3cx profile
Signed-off-by: shivamcandela <shivam.thakur@candelatech.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# !/usr/bin/env python3
|
# !/usr/bin/env python3
|
||||||
import pprint
|
import pprint
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
@@ -8,6 +7,7 @@ import pandas as pd
|
|||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
class L3CXProfile(LFCliBase):
|
class L3CXProfile(LFCliBase):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
lfclient_host,
|
lfclient_host,
|
||||||
@@ -140,11 +140,11 @@ class L3CXProfile(LFCliBase):
|
|||||||
raise ValueError("L3CXProfile::monitor wants a list of column names to monitor")
|
raise ValueError("L3CXProfile::monitor wants a list of column names to monitor")
|
||||||
if output_format is not None:
|
if output_format is not None:
|
||||||
if output_format.lower() != report_file.split('.')[-1]:
|
if output_format.lower() != report_file.split('.')[-1]:
|
||||||
raise ValueError('Filename %s has an extension that does not match output format %s .' % (report_file, output_format))
|
raise ValueError('Filename %s has an extension that does not match output format %s .' % (
|
||||||
|
report_file, output_format))
|
||||||
else:
|
else:
|
||||||
output_format = report_file.split('.')[-1]
|
output_format = report_file.split('.')[-1]
|
||||||
|
|
||||||
|
|
||||||
# default save to csv first
|
# default save to csv first
|
||||||
if report_file.split('.')[-1] != 'csv':
|
if report_file.split('.')[-1] != 'csv':
|
||||||
report_file = report_file.replace(str(output_format), 'csv', 1)
|
report_file = report_file.replace(str(output_format), 'csv', 1)
|
||||||
@@ -159,7 +159,6 @@ class L3CXProfile(LFCliBase):
|
|||||||
default_cols.extend(port_mgr_cols)
|
default_cols.extend(port_mgr_cols)
|
||||||
header_row = default_cols
|
header_row = default_cols
|
||||||
|
|
||||||
|
|
||||||
# csvwriter.writerow([systeminfo['VersionInfo']['BuildVersion'], script_name, str(arguments)])
|
# csvwriter.writerow([systeminfo['VersionInfo']['BuildVersion'], script_name, str(arguments)])
|
||||||
|
|
||||||
if port_mgr_cols is not None:
|
if port_mgr_cols is not None:
|
||||||
@@ -172,12 +171,12 @@ class L3CXProfile(LFCliBase):
|
|||||||
header_row.extend(port_mgr_cols_labelled)
|
header_row.extend(port_mgr_cols_labelled)
|
||||||
# create sys info file
|
# create sys info file
|
||||||
systeminfo = self.json_get('/')
|
systeminfo = self.json_get('/')
|
||||||
sysinfo=[str("LANforge GUI Build: " + systeminfo['VersionInfo']['BuildVersion']), str("Script Name: " + script_name), str("Argument input: " + str(arguments))]
|
sysinfo = [str("LANforge GUI Build: " + systeminfo['VersionInfo']['BuildVersion']),
|
||||||
|
str("Script Name: " + script_name), str("Argument input: " + str(arguments))]
|
||||||
with open(systeminfopath, 'w') as filehandle:
|
with open(systeminfopath, 'w') as filehandle:
|
||||||
for listitem in sysinfo:
|
for listitem in sysinfo:
|
||||||
filehandle.write('%s\n' % listitem)
|
filehandle.write('%s\n' % listitem)
|
||||||
|
|
||||||
|
|
||||||
# ================== Step 2, monitor columns
|
# ================== Step 2, monitor columns
|
||||||
start_time = datetime.datetime.now()
|
start_time = datetime.datetime.now()
|
||||||
end_time = start_time + datetime.timedelta(seconds=duration_sec)
|
end_time = start_time + datetime.timedelta(seconds=duration_sec)
|
||||||
@@ -203,9 +202,7 @@ class L3CXProfile(LFCliBase):
|
|||||||
t_to_sec_epoch = int(self.get_seconds(t))
|
t_to_sec_epoch = int(self.get_seconds(t))
|
||||||
time_elapsed = int(self.get_seconds(t)) - int(self.get_seconds(initial_starttime))
|
time_elapsed = int(self.get_seconds(t)) - int(self.get_seconds(initial_starttime))
|
||||||
basecolumns = [timestamp, t_to_millisec_epoch, t_to_sec_epoch, time_elapsed]
|
basecolumns = [timestamp, t_to_millisec_epoch, t_to_sec_epoch, time_elapsed]
|
||||||
|
|
||||||
layer_3_response = self.json_get("/endp/%s?fields=%s" % (created_cx, layer3_fields))
|
layer_3_response = self.json_get("/endp/%s?fields=%s" % (created_cx, layer3_fields))
|
||||||
|
|
||||||
if port_mgr_cols is not None:
|
if port_mgr_cols is not None:
|
||||||
port_mgr_response = self.json_get("/port/1/1/%s?fields=%s" % (sta_list, port_mgr_fields))
|
port_mgr_response = self.json_get("/port/1/1/%s?fields=%s" % (sta_list, port_mgr_fields))
|
||||||
# get info from port manager with list of values from cx_a_side_list
|
# get info from port manager with list of values from cx_a_side_list
|
||||||
@@ -254,13 +251,26 @@ class L3CXProfile(LFCliBase):
|
|||||||
else:
|
else:
|
||||||
self.fail("FAIL: Not all stations increased traffic")
|
self.fail("FAIL: Not all stations increased traffic")
|
||||||
self.exit_fail()
|
self.exit_fail()
|
||||||
old_cx_rx_values = new_cx_rx_values
|
try:
|
||||||
|
cx_data = self.json_get("/cx/all")
|
||||||
|
cx_data.pop("handler")
|
||||||
|
cx_data.pop("uri")
|
||||||
|
for i in self.created_cx.keys():
|
||||||
|
print("cx name: ", i,
|
||||||
|
" bps tx a :", cx_data[i]['bps rx a'], " bps rx a : ", cx_data[i]['bps rx a'],
|
||||||
|
" bps tx b :", cx_data[i]['bps rx a'], " bps rx b : ", cx_data[i]['bps rx a'],
|
||||||
|
" pkt rx a :", cx_data[i]['pkt rx a'], " pkt rx b : ", cx_data[i]['pkt rx b'],
|
||||||
|
" rx drop % a :", cx_data[i]['rx drop % a'], " rx drop % b : ", cx_data[i]['rx drop % b'])
|
||||||
|
print("\n")
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
time.sleep(monitor_interval_ms)
|
time.sleep(monitor_interval_ms)
|
||||||
csvfile.close()
|
csvfile.close()
|
||||||
|
|
||||||
# comparison to last report / report inputted
|
# comparison to last report / report inputted
|
||||||
if compared_report is not None:
|
if compared_report is not None:
|
||||||
compared_df = self.compare_two_df(dataframe_one=self.file_to_df(report_file), dataframe_two=self.file_to_df(compared_report))
|
compared_df = self.compare_two_df(dataframe_one=self.file_to_df(report_file),
|
||||||
|
dataframe_two=self.file_to_df(compared_report))
|
||||||
exit(1)
|
exit(1)
|
||||||
# append compared df to created one
|
# append compared df to created one
|
||||||
if output_format.lower() != 'csv':
|
if output_format.lower() != 'csv':
|
||||||
@@ -269,7 +279,6 @@ class L3CXProfile(LFCliBase):
|
|||||||
if output_format.lower() != 'csv':
|
if output_format.lower() != 'csv':
|
||||||
self.df_to_file(dataframe=pd.read_csv(report_file), output_f=output_format, save_path=report_file)
|
self.df_to_file(dataframe=pd.read_csv(report_file), output_f=output_format, save_path=report_file)
|
||||||
|
|
||||||
|
|
||||||
def refresh_cx(self):
|
def refresh_cx(self):
|
||||||
for cx_name in self.created_cx.keys():
|
for cx_name in self.created_cx.keys():
|
||||||
self.json_post("/cli-json/show_cxe", {
|
self.json_post("/cli-json/show_cxe", {
|
||||||
@@ -400,8 +409,10 @@ class L3CXProfile(LFCliBase):
|
|||||||
# print("1: endp-side-b: ", endp_side_b)
|
# print("1: endp-side-b: ", endp_side_b)
|
||||||
|
|
||||||
url = "/cli-json/add_endp"
|
url = "/cli-json/add_endp"
|
||||||
self.local_realm.json_post(url, endp_side_a, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, endp_side_a, debug_=debug_,
|
||||||
self.local_realm.json_post(url, endp_side_b, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
suppress_related_commands_=suppress_related_commands)
|
||||||
|
self.local_realm.json_post(url, endp_side_b, debug_=debug_,
|
||||||
|
suppress_related_commands_=suppress_related_commands)
|
||||||
# print("napping %f sec"%sleep_time)
|
# print("napping %f sec"%sleep_time)
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
@@ -411,16 +422,20 @@ class L3CXProfile(LFCliBase):
|
|||||||
"flag": "AutoHelper",
|
"flag": "AutoHelper",
|
||||||
"val": 1
|
"val": 1
|
||||||
}
|
}
|
||||||
self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, data, debug_=debug_,
|
||||||
|
suppress_related_commands_=suppress_related_commands)
|
||||||
data["name"] = endp_b_name
|
data["name"] = endp_b_name
|
||||||
self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, data, debug_=debug_,
|
||||||
|
suppress_related_commands_=suppress_related_commands)
|
||||||
|
|
||||||
if (endp_type == "lf_udp") or (endp_type == "udp") or (endp_type == "lf_udp6") or (endp_type == "udp6"):
|
if (endp_type == "lf_udp") or (endp_type == "udp") or (endp_type == "lf_udp6") or (endp_type == "udp6"):
|
||||||
data["name"] = endp_a_name
|
data["name"] = endp_a_name
|
||||||
data["flag"] = "UseAutoNAT"
|
data["flag"] = "UseAutoNAT"
|
||||||
self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, data, debug_=debug_,
|
||||||
|
suppress_related_commands_=suppress_related_commands)
|
||||||
data["name"] = endp_b_name
|
data["name"] = endp_b_name
|
||||||
self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, data, debug_=debug_,
|
||||||
|
suppress_related_commands_=suppress_related_commands)
|
||||||
|
|
||||||
if tos != None:
|
if tos != None:
|
||||||
self.local_realm.set_endp_tos(endp_a_name, tos)
|
self.local_realm.set_endp_tos(endp_a_name, tos)
|
||||||
@@ -495,8 +510,10 @@ class L3CXProfile(LFCliBase):
|
|||||||
# print("2: endp-side-b: ", endp_side_b)
|
# print("2: endp-side-b: ", endp_side_b)
|
||||||
|
|
||||||
url = "/cli-json/add_endp"
|
url = "/cli-json/add_endp"
|
||||||
self.local_realm.json_post(url, endp_side_a, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, endp_side_a, debug_=debug_,
|
||||||
self.local_realm.json_post(url, endp_side_b, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
suppress_related_commands_=suppress_related_commands)
|
||||||
|
self.local_realm.json_post(url, endp_side_b, debug_=debug_,
|
||||||
|
suppress_related_commands_=suppress_related_commands)
|
||||||
# print("napping %f sec" %sleep_time )
|
# print("napping %f sec" %sleep_time )
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
@@ -506,7 +523,8 @@ class L3CXProfile(LFCliBase):
|
|||||||
"flag": "autohelper",
|
"flag": "autohelper",
|
||||||
"val": 1
|
"val": 1
|
||||||
}
|
}
|
||||||
self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, data, debug_=debug_,
|
||||||
|
suppress_related_commands_=suppress_related_commands)
|
||||||
|
|
||||||
url = "cli-json/set_endp_flag"
|
url = "cli-json/set_endp_flag"
|
||||||
data = {
|
data = {
|
||||||
@@ -514,7 +532,8 @@ class L3CXProfile(LFCliBase):
|
|||||||
"flag": "autohelper",
|
"flag": "autohelper",
|
||||||
"val": 1
|
"val": 1
|
||||||
}
|
}
|
||||||
self.local_realm.json_post(url, data, debug_=debug_, suppress_related_commands_=suppress_related_commands)
|
self.local_realm.json_post(url, data, debug_=debug_,
|
||||||
|
suppress_related_commands_=suppress_related_commands)
|
||||||
# print("CXNAME451: %s" % cx_name)
|
# print("CXNAME451: %s" % cx_name)
|
||||||
data = {
|
data = {
|
||||||
"alias": cx_name,
|
"alias": cx_name,
|
||||||
@@ -546,5 +565,3 @@ class L3CXProfile(LFCliBase):
|
|||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
pprint.pprint(self)
|
pprint.pprint(self)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user