mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-02 03:37:55 +00:00
l3-longevity: Write out per-port csv files.
And a small bit of code cleanup in the realm class. Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
@@ -194,26 +194,20 @@ class Realm(LFCliBase):
|
|||||||
debug_ |= self.debug
|
debug_ |= self.debug
|
||||||
req_url = "/cli-json/rm_vlan"
|
req_url = "/cli-json/rm_vlan"
|
||||||
eid = self.name_to_eid(port_eid)
|
eid = self.name_to_eid(port_eid)
|
||||||
do_rm = True
|
|
||||||
if check_exists:
|
if check_exists:
|
||||||
if not self.port_exists(port_eid):
|
if not self.port_exists(port_eid):
|
||||||
do_rm = False
|
return False
|
||||||
if do_rm:
|
|
||||||
data = {
|
data = {
|
||||||
"shelf": eid[0],
|
"shelf": eid[0],
|
||||||
"resource": eid[1],
|
"resource": eid[1],
|
||||||
"port": eid[2]
|
"port": eid[2]
|
||||||
}
|
}
|
||||||
rsp = self.json_post(req_url, data, debug_=debug_)
|
rsp = self.json_post(req_url, data, debug_=debug_)
|
||||||
return True
|
return True
|
||||||
return False
|
|
||||||
|
|
||||||
def port_exists(self, port_eid):
|
def port_exists(self, port_eid):
|
||||||
data = {}
|
|
||||||
eid = self.name_to_eid(port_eid)
|
eid = self.name_to_eid(port_eid)
|
||||||
data["shelf"] = eid[0]
|
|
||||||
data["resource"] = eid[1]
|
|
||||||
data["port"] = eid[2]
|
|
||||||
current_stations = self.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2]))
|
current_stations = self.json_get("/port/%s/%s/%s?fields=alias" % (eid[0], eid[1], eid[2]))
|
||||||
if not current_stations is None:
|
if not current_stations is None:
|
||||||
return True
|
return True
|
||||||
@@ -450,6 +444,17 @@ class Realm(LFCliBase):
|
|||||||
del response
|
del response
|
||||||
return sta_list
|
return sta_list
|
||||||
|
|
||||||
|
# Returns list of all ports
|
||||||
|
def port_list(self):
|
||||||
|
sta_list = []
|
||||||
|
response = super().json_get("/port/list?fields=all")
|
||||||
|
if (response is None) or ("interfaces" not in response):
|
||||||
|
print("port_list: incomplete response:")
|
||||||
|
pprint(response)
|
||||||
|
return None
|
||||||
|
|
||||||
|
return response['interfaces']
|
||||||
|
|
||||||
# Returns list of all VAPs with "vap" in their name
|
# Returns list of all VAPs with "vap" in their name
|
||||||
def vap_list(self):
|
def vap_list(self):
|
||||||
sta_list = []
|
sta_list = []
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
if sys.version_info[0] != 3:
|
if sys.version_info[0] != 3:
|
||||||
print("This script requires Python 3")
|
print("This script requires Python 3")
|
||||||
@@ -149,6 +150,10 @@ class L3VariableTime(Realm):
|
|||||||
self.cx_profile.side_b_min_bps = side_b_min_rate[0]
|
self.cx_profile.side_b_min_bps = side_b_min_rate[0]
|
||||||
self.cx_profile.side_b_max_bps = side_b_max_rate[0]
|
self.cx_profile.side_b_max_bps = side_b_max_rate[0]
|
||||||
|
|
||||||
|
# Lookup key is port-eid name
|
||||||
|
self.port_csv_files = {}
|
||||||
|
self.port_csv_writers = {}
|
||||||
|
|
||||||
dur = self.duration_time_to_seconds(self.test_duration)
|
dur = self.duration_time_to_seconds(self.test_duration)
|
||||||
|
|
||||||
if (self.polling_interval_seconds > dur + 1):
|
if (self.polling_interval_seconds > dur + 1):
|
||||||
@@ -314,8 +319,11 @@ class L3VariableTime(Realm):
|
|||||||
if not self.csv_started:
|
if not self.csv_started:
|
||||||
csv_header = self.csv_generate_column_headers()
|
csv_header = self.csv_generate_column_headers()
|
||||||
csv_header += csv_rx_headers
|
csv_header += csv_rx_headers
|
||||||
print(csv_header)
|
#print(csv_header)
|
||||||
self.csv_add_column_headers(csv_header)
|
self.csv_add_column_headers(csv_header)
|
||||||
|
port_eids = self.gather_port_eids()
|
||||||
|
for eid_name in port_eids:
|
||||||
|
self.csv_add_port_column_headers(eid_name, self.csv_generate_port_column_headers())
|
||||||
self.csv_started = True
|
self.csv_started = True
|
||||||
|
|
||||||
# need to generate list first to determine worst and best
|
# need to generate list first to determine worst and best
|
||||||
@@ -507,6 +515,14 @@ class L3VariableTime(Realm):
|
|||||||
count += 1
|
count += 1
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
def gather_port_eids(self):
|
||||||
|
rv = [self.side_b]
|
||||||
|
|
||||||
|
for station_profile in self.station_profiles:
|
||||||
|
rv = rv + station_profile.station_names
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
|
||||||
# Create stations and connections/endpoints. If rebuild is true, then
|
# Create stations and connections/endpoints. If rebuild is true, then
|
||||||
# only update connections/endpoints.
|
# only update connections/endpoints.
|
||||||
def build(self, rebuild=False):
|
def build(self, rebuild=False):
|
||||||
@@ -587,6 +603,9 @@ class L3VariableTime(Realm):
|
|||||||
ul = str(int(int(ul) / self.cx_count))
|
ul = str(int(int(ul) / self.cx_count))
|
||||||
dl = str(int(int(dl) / self.cx_count))
|
dl = str(int(int(dl) / self.cx_count))
|
||||||
|
|
||||||
|
dl_pdu_str = dl_pdu
|
||||||
|
ul_pdu_str = ul_pdu
|
||||||
|
|
||||||
if (ul_pdu == "AUTO" or ul_pdu == "MTU"):
|
if (ul_pdu == "AUTO" or ul_pdu == "MTU"):
|
||||||
ul_pdu = "-1"
|
ul_pdu = "-1"
|
||||||
|
|
||||||
@@ -658,7 +677,22 @@ class L3VariableTime(Realm):
|
|||||||
self.__record_rx_dropped_percent(rx_drop_percent)
|
self.__record_rx_dropped_percent(rx_drop_percent)
|
||||||
|
|
||||||
# At end of test step, record KPI information.
|
# At end of test step, record KPI information.
|
||||||
self.record_kpi(len(temp_stations_list), ul, dl, ul_pdu, dl_pdu, atten_val, total_dl_bps, total_ul_bps)
|
self.record_kpi(len(temp_stations_list), ul, dl, ul_pdu_str, dl_pdu_str, atten_val, total_dl_bps, total_ul_bps)
|
||||||
|
|
||||||
|
# Query all of our ports
|
||||||
|
port_eids = self.gather_port_eids()
|
||||||
|
for eid_name in port_eids:
|
||||||
|
eid = self.name_to_eid(eid_name)
|
||||||
|
url = "/port/%s/%s/%s"%(eid[0], eid[1], eid[2])
|
||||||
|
response = self.json_get(url)
|
||||||
|
if (response is None) or ("interface" not in response):
|
||||||
|
print("query-port: %s: incomplete response:"%(url))
|
||||||
|
pprint(response)
|
||||||
|
else:
|
||||||
|
p = response['interface']
|
||||||
|
# p is map of key/values for this port
|
||||||
|
#print("port: ", p)
|
||||||
|
self.write_port_csv(len(temp_stations_list), ul, dl, ul_pdu_str, dl_pdu_str, atten_val, eid_name, p)
|
||||||
|
|
||||||
# Stop connections.
|
# Stop connections.
|
||||||
self.cx_profile.stop_cx();
|
self.cx_profile.stop_cx();
|
||||||
@@ -669,6 +703,22 @@ class L3VariableTime(Realm):
|
|||||||
if passes == expected_passes:
|
if passes == expected_passes:
|
||||||
self._pass("PASS: Requested-Rate: %s <-> %s PDU: %s <-> %s All tests passed" % (ul, dl, ul_pdu, dl_pdu), print_pass)
|
self._pass("PASS: Requested-Rate: %s <-> %s PDU: %s <-> %s All tests passed" % (ul, dl, ul_pdu, dl_pdu), print_pass)
|
||||||
|
|
||||||
|
def write_port_csv(self, sta_count, ul, dl, ul_pdu, dl_pdu, atten, eid_name, port_data):
|
||||||
|
row = [self.epoch_time, self.time_stamp(), sta_count,
|
||||||
|
ul, ul, dl, dl, dl_pdu, dl_pdu, ul_pdu, ul_pdu,
|
||||||
|
atten, eid_name
|
||||||
|
]
|
||||||
|
|
||||||
|
row = row + [port_data['bps rx'], port_data['bps tx'], port_data['rx-rate'], port_data['tx-rate'],
|
||||||
|
port_data['signal'], port_data['ap'], port_data['mode']]
|
||||||
|
|
||||||
|
# TODO: Add in info queried from AP.
|
||||||
|
|
||||||
|
writer = self.port_csv_writers[eid_name]
|
||||||
|
writer.writerow(row)
|
||||||
|
self.port_csv_files[eid_name].flush()
|
||||||
|
|
||||||
|
|
||||||
# Submit data to the influx db if configured to do so.
|
# Submit data to the influx db if configured to do so.
|
||||||
def record_kpi(self, sta_count, ul, dl, ul_pdu, dl_pdu, atten, total_dl_bps, total_ul_bps):
|
def record_kpi(self, sta_count, ul, dl, ul_pdu, dl_pdu, atten, total_dl_bps, total_ul_bps):
|
||||||
if self.influxdb == None:
|
if self.influxdb == None:
|
||||||
@@ -676,7 +726,7 @@ class L3VariableTime(Realm):
|
|||||||
|
|
||||||
tags=dict()
|
tags=dict()
|
||||||
tags['requested-ul-bps'] = ul
|
tags['requested-ul-bps'] = ul
|
||||||
tags['requested-ul-bps'] = dl
|
tags['requested-dl-bps'] = dl
|
||||||
tags['ul-pdu-size'] = ul_pdu
|
tags['ul-pdu-size'] = ul_pdu
|
||||||
tags['dl-pdu-size'] = dl_pdu
|
tags['dl-pdu-size'] = dl_pdu
|
||||||
tags['station-count'] = sta_count
|
tags['station-count'] = sta_count
|
||||||
@@ -710,7 +760,6 @@ class L3VariableTime(Realm):
|
|||||||
for station_profile in self.station_profiles:
|
for station_profile in self.station_profiles:
|
||||||
station_profile.cleanup()
|
station_profile.cleanup()
|
||||||
|
|
||||||
# CSV column headers.
|
|
||||||
def csv_generate_column_headers(self):
|
def csv_generate_column_headers(self):
|
||||||
csv_rx_headers = ['Time epoch','Time','Monitor',
|
csv_rx_headers = ['Time epoch','Time','Monitor',
|
||||||
'UL-Min-Requested','UL-Max-Requested','DL-Min-Requested','DL-Max-Requested',
|
'UL-Min-Requested','UL-Max-Requested','DL-Min-Requested','DL-Max-Requested',
|
||||||
@@ -725,12 +774,33 @@ class L3VariableTime(Realm):
|
|||||||
csv_rx_headers.append("average_rx_data_bytes")
|
csv_rx_headers.append("average_rx_data_bytes")
|
||||||
return csv_rx_headers
|
return csv_rx_headers
|
||||||
|
|
||||||
|
def csv_generate_port_column_headers(self):
|
||||||
|
csv_rx_headers = ['Time epoch', 'Time', 'Station-Count',
|
||||||
|
'UL-Min-Requested','UL-Max-Requested','DL-Min-Requested','DL-Max-Requested',
|
||||||
|
'UL-Min-PDU','UL-Max-PDU','DL-Min-PDU','DL-Max-PDU','Attenuation',
|
||||||
|
'Name', 'Rx-Bps', 'Tx-Bps', 'Rx-Link-Rate', 'Tx-Link-Rate', 'RSSI', 'AP', 'Mode'
|
||||||
|
]
|
||||||
|
return csv_rx_headers
|
||||||
|
|
||||||
# Write initial headers to csv file.
|
# Write initial headers to csv file.
|
||||||
def csv_add_column_headers(self,headers):
|
def csv_add_column_headers(self,headers):
|
||||||
if self.csv_file is not None:
|
if self.csv_file is not None:
|
||||||
self.csv_writer.writerow(headers)
|
self.csv_writer.writerow(headers)
|
||||||
self.csv_file.flush()
|
self.csv_file.flush()
|
||||||
|
|
||||||
|
# Write initial headers to port csv file.
|
||||||
|
def csv_add_port_column_headers(self, eid_name, headers):
|
||||||
|
if self.csv_file is not None:
|
||||||
|
fname = self.outfile[:-4] # Strip '.csv' from file name
|
||||||
|
fname = fname + "-" + eid_name + ".csv"
|
||||||
|
pfile = open(fname, "w")
|
||||||
|
port_csv_writer = csv.writer(pfile, delimiter=",")
|
||||||
|
self.port_csv_files[eid_name] = pfile
|
||||||
|
self.port_csv_writers[eid_name] = port_csv_writer
|
||||||
|
|
||||||
|
port_csv_writer.writerow(headers)
|
||||||
|
pfile.flush()
|
||||||
|
|
||||||
def csv_validate_list(self, csv_list, length):
|
def csv_validate_list(self, csv_list, length):
|
||||||
if len(csv_list) < length:
|
if len(csv_list) < length:
|
||||||
csv_list = csv_list + [('no data','no data')] * (length - len(csv_list))
|
csv_list = csv_list + [('no data','no data')] * (length - len(csv_list))
|
||||||
|
|||||||
Reference in New Issue
Block a user