mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-19 03:25:05 +00:00
flexible lfclient_port and correct l3 field names
This commit is contained in:
@@ -1091,6 +1091,7 @@ class L3CXProfile(BaseProfile):
|
|||||||
self.created_endp = {}
|
self.created_endp = {}
|
||||||
self.name_prefix = name_prefix_
|
self.name_prefix = name_prefix_
|
||||||
self.number_template = number_template_
|
self.number_template = number_template_
|
||||||
|
self.lfclient_port = lfclient_port
|
||||||
|
|
||||||
def get_cx_names(self):
|
def get_cx_names(self):
|
||||||
return self.created_cx.keys()
|
return self.created_cx.keys()
|
||||||
@@ -1163,12 +1164,11 @@ class L3CXProfile(BaseProfile):
|
|||||||
output_format = report_file.split('.')[-1]
|
output_format = report_file.split('.')[-1]
|
||||||
|
|
||||||
# Step 1, column names . what is this for?
|
# Step 1, column names . what is this for?
|
||||||
fields=None
|
fields=None
|
||||||
if col_names is not None and len(col_names) > 0:
|
if col_names is not None and len(col_names) > 0:
|
||||||
fields = ",".join(col_names)
|
fields = ",".join(col_names)
|
||||||
else:
|
else:
|
||||||
header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys()))
|
header_row=list((list(self.json_get("/endp/all")['endpoint'][0].values())[0].keys()))
|
||||||
print(fields)
|
|
||||||
# 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)
|
||||||
@@ -1181,7 +1181,7 @@ class L3CXProfile(BaseProfile):
|
|||||||
timestamps = []
|
timestamps = []
|
||||||
# for x in range(0,int(round(iterations,0))):
|
# for x in range(0,int(round(iterations,0))):
|
||||||
while datetime.datetime.now() < end_time:
|
while datetime.datetime.now() < end_time:
|
||||||
if fields == None:
|
if fields is None:
|
||||||
response = self.json_get("/endp/all")
|
response = self.json_get("/endp/all")
|
||||||
else:
|
else:
|
||||||
response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields))
|
response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields))
|
||||||
@@ -1224,7 +1224,6 @@ class L3CXProfile(BaseProfile):
|
|||||||
for point in range(0, len(endpoints2)):
|
for point in range(0, len(endpoints2)):
|
||||||
endpoints2[point].insert(0, timestamps2[point])
|
endpoints2[point].insert(0, timestamps2[point])
|
||||||
# step 4 save and close
|
# step 4 save and close
|
||||||
header_row = col_names
|
|
||||||
header_row.insert(0, 'Timestamp')
|
header_row.insert(0, 'Timestamp')
|
||||||
print(header_row)
|
print(header_row)
|
||||||
if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx':
|
if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx':
|
||||||
@@ -1244,9 +1243,9 @@ class L3CXProfile(BaseProfile):
|
|||||||
import requests
|
import requests
|
||||||
import ast
|
import ast
|
||||||
try:
|
try:
|
||||||
systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text)
|
systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text)
|
||||||
except:
|
except:
|
||||||
systeminfo = ast.literal_eval(requests.get('http://localhost:8090').text)
|
systeminfo = ast.literal_eval(requests.get('http://localhost:'+str(self.lfclient_port)).text)
|
||||||
df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion']
|
df['LFGUI Release'] = systeminfo['VersionInfo']['BuildVersion']
|
||||||
df['Script Name'] = script_name
|
df['Script Name'] = script_name
|
||||||
df['Arguments'] = arguments
|
df['Arguments'] = arguments
|
||||||
@@ -1706,20 +1705,20 @@ class L4CXProfile(LFCliBase):
|
|||||||
else:
|
else:
|
||||||
output_format = report_file.split('.')[-1]
|
output_format = report_file.split('.')[-1]
|
||||||
|
|
||||||
# Step 1, column names
|
# Step 1, column names
|
||||||
|
|
||||||
fields=None
|
fields=None
|
||||||
if col_names is not None and len(col_names) > 0:
|
if col_names is not None and len(col_names) > 0:
|
||||||
fields = ",".join(col_names)
|
fields = ",".join(col_names)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print(fields)
|
print(fields)
|
||||||
else:
|
else:
|
||||||
#todo:rename this...
|
#todo:rename this...
|
||||||
header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys()))
|
header_row=list((list(self.json_get("/layer4/all")['endpoint'][0].values())[0].keys()))
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print(header_row)
|
print(header_row)
|
||||||
|
|
||||||
# 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)
|
||||||
@@ -1731,7 +1730,7 @@ class L4CXProfile(LFCliBase):
|
|||||||
for test in range(1+iterations):
|
for test in range(1+iterations):
|
||||||
#while current loop hasn't ended
|
#while current loop hasn't ended
|
||||||
while datetime.datetime.now() < end_time:
|
while datetime.datetime.now() < end_time:
|
||||||
#what does response ? get?
|
#what does response ? get?
|
||||||
response=self.json_get("layer4/all")
|
response=self.json_get("layer4/all")
|
||||||
#response = self.json_get("layer4/list?fields=urls/s")
|
#response = self.json_get("layer4/list?fields=urls/s")
|
||||||
if "endpoint" not in response:
|
if "endpoint" not in response:
|
||||||
@@ -1828,7 +1827,7 @@ class L4CXProfile(LFCliBase):
|
|||||||
exec('df.to_' + x + '("' + report_file + '")')
|
exec('df.to_' + x + '("' + report_file + '")')
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
#end of L4CXProf class
|
#end of L4CXProf class
|
||||||
|
|
||||||
class GenCXProfile(LFCliBase):
|
class GenCXProfile(LFCliBase):
|
||||||
def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False):
|
def __init__(self, lfclient_host, lfclient_port, local_realm, debug_=False):
|
||||||
|
|||||||
@@ -200,8 +200,9 @@ python3 ./test_ipv4_variable_time.py
|
|||||||
num_sta = int(args.num_stations)
|
num_sta = int(args.num_stations)
|
||||||
|
|
||||||
#Create directory
|
#Create directory
|
||||||
homedir=str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time'
|
homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':','-')+'test_ipv4_variable_time'
|
||||||
os.mkdir('/home/lanforge/report_data/'+homedir)
|
path = os.path.join('/home/lanforge/report-data/',homedir)
|
||||||
|
os.mkdir(path)
|
||||||
|
|
||||||
if args.report_file is None:
|
if args.report_file is None:
|
||||||
if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']:
|
if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']:
|
||||||
@@ -265,7 +266,7 @@ python3 ./test_ipv4_variable_time.py
|
|||||||
if ip_var_test.passes():
|
if ip_var_test.passes():
|
||||||
ip_var_test.exit_success()
|
ip_var_test.exit_success()
|
||||||
|
|
||||||
IPV4VariableTime.cx_profile.stop_cx() #is this needed?
|
IPV4VariableTime.cx_profile.stop_cx() #is this needed?
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user