mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-21 20:45:06 +00:00
l3-longevity: Support setting attenuators
User can specify comma separated list of attenuator EIDS (shelf.resource.atten-id.atten-idx) and a list of attenuation values and the script will iterate through those. Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
@@ -549,8 +549,8 @@ def waitUntilPortsAppear(base_url="http://localhost:8080", port_list=(), debug=F
|
|||||||
"""
|
"""
|
||||||
return wait_until_ports_appear(base_url, port_list, debug=debug)
|
return wait_until_ports_appear(base_url, port_list, debug=debug)
|
||||||
|
|
||||||
def name_to_eid(input):
|
def name_to_eid(input, non_port=False):
|
||||||
rv = [1, 1, ""]
|
rv = [1, 1, "", ""]
|
||||||
info = []
|
info = []
|
||||||
if (input is None) or (input == ""):
|
if (input is None) or (input == ""):
|
||||||
raise ValueError("name_to_eid wants eid like 1.1.sta0 but given[%s]" % input)
|
raise ValueError("name_to_eid wants eid like 1.1.sta0 but given[%s]" % input)
|
||||||
@@ -582,6 +582,15 @@ def name_to_eid(input):
|
|||||||
rv[2] = info[1]+"."+info[2]
|
rv[2] = info[1]+"."+info[2]
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
if non_port:
|
||||||
|
# Maybe attenuator or similar shelf.card.atten.index
|
||||||
|
rv[0] = int(info[0])
|
||||||
|
rv[1] = int(info[1])
|
||||||
|
rv[2] = int(info[2])
|
||||||
|
if (len(info) >= 4):
|
||||||
|
rv[3] = int(info[3])
|
||||||
|
return rv
|
||||||
|
|
||||||
if len(info) == 4: # shelf.resource.port-name.qvlan
|
if len(info) == 4: # shelf.resource.port-name.qvlan
|
||||||
rv[0] = int(info[0])
|
rv[0] = int(info[0])
|
||||||
rv[1] = int(info[1])
|
rv[1] = int(info[1])
|
||||||
|
|||||||
@@ -461,11 +461,29 @@ class Realm(LFCliBase):
|
|||||||
|
|
||||||
return sta_list
|
return sta_list
|
||||||
|
|
||||||
|
# Returns all attenuators
|
||||||
|
def atten_list(self):
|
||||||
|
response = super().json_get("/atten/list")
|
||||||
|
return response['attenuators']
|
||||||
|
|
||||||
|
# EID is shelf.resource.atten-serno.atten-idx
|
||||||
|
def set_atten(self, eid, atten_ddb):
|
||||||
|
eid_toks = self.name_to_eid(eid, non_port=True)
|
||||||
|
req_url = "cli-json/set_attenuator"
|
||||||
|
data = {
|
||||||
|
"shelf": eid_toks[0],
|
||||||
|
"resource": eid_toks[1],
|
||||||
|
"serno": eid_toks[2],
|
||||||
|
"atten_idx":eid_toks[3],
|
||||||
|
"val":atten_ddb,
|
||||||
|
}
|
||||||
|
self.json_post(req_url, data)
|
||||||
|
|
||||||
# removes port by eid/eidpn
|
# removes port by eid/eidpn
|
||||||
def remove_vlan_by_eid(self, eid):
|
def remove_vlan_by_eid(self, eid):
|
||||||
if (eid is None) or ("" == eid):
|
if (eid is None) or ("" == eid):
|
||||||
raise ValueError("removeVlanByEid wants eid like 1.1.sta0 but given[%s]" % eid)
|
raise ValueError("removeVlanByEid wants eid like 1.1.sta0 but given[%s]" % eid)
|
||||||
hunks = eid.split('.')
|
hunks = self.name_to_eid(eid)
|
||||||
# print("- - - - - - - - - - - - - - - - -")
|
# print("- - - - - - - - - - - - - - - - -")
|
||||||
# pprint(hunks)
|
# pprint(hunks)
|
||||||
# pprint(self.lfclient_url)
|
# pprint(self.lfclient_url)
|
||||||
@@ -545,12 +563,12 @@ class Realm(LFCliBase):
|
|||||||
|
|
||||||
return matched_map
|
return matched_map
|
||||||
|
|
||||||
def name_to_eid(self, eid, debug=False):
|
def name_to_eid(self, eid, debug=False, non_port=False):
|
||||||
if debug:
|
if debug:
|
||||||
self.logg(level="debug", mesg="name_to_eid: "+str(eid))
|
self.logg(level="debug", mesg="name_to_eid: "+str(eid))
|
||||||
if (type(eid) is list) or (type(eid) is tuple):
|
if (type(eid) is list) or (type(eid) is tuple):
|
||||||
return eid
|
return eid
|
||||||
return LFUtils.name_to_eid(eid)
|
return LFUtils.name_to_eid(eid, non_port=non_port)
|
||||||
|
|
||||||
def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=360, debug=False):
|
def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=360, debug=False):
|
||||||
if not (ipv4 or ipv6):
|
if not (ipv4 or ipv6):
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ class L3VariableTime(Realm):
|
|||||||
side_a_max_pdu=[0],
|
side_a_max_pdu=[0],
|
||||||
side_b_min_pdu=["MTU"],
|
side_b_min_pdu=["MTU"],
|
||||||
side_b_max_pdu=[0],
|
side_b_max_pdu=[0],
|
||||||
|
attenuators=[],
|
||||||
|
atten_vals=[],
|
||||||
number_template="00",
|
number_template="00",
|
||||||
test_duration="256s",
|
test_duration="256s",
|
||||||
polling_interval="60s",
|
polling_interval="60s",
|
||||||
@@ -118,6 +120,12 @@ class L3VariableTime(Realm):
|
|||||||
self.side_b_min_pdu = side_b_min_pdu
|
self.side_b_min_pdu = side_b_min_pdu
|
||||||
self.side_b_max_pdu = side_b_max_pdu
|
self.side_b_max_pdu = side_b_max_pdu
|
||||||
|
|
||||||
|
self.attenuators = attenuators
|
||||||
|
self.atten_vals = atten_vals
|
||||||
|
if ((len(self.atten_vals) > 0) and (len(self.attenuators) == 0)):
|
||||||
|
print("ERROR: Attenuation values configured, but no Attenuator EIDs specified.\n")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
self.cx_profile.side_a_min_bps = side_a_min_rate[0]
|
self.cx_profile.side_a_min_bps = side_a_min_rate[0]
|
||||||
self.cx_profile.side_a_max_bps = side_a_max_rate[0]
|
self.cx_profile.side_a_max_bps = side_a_max_rate[0]
|
||||||
self.cx_profile.side_b_min_bps = side_b_min_rate[0]
|
self.cx_profile.side_b_min_bps = side_b_min_rate[0]
|
||||||
@@ -560,6 +568,11 @@ class L3VariableTime(Realm):
|
|||||||
# Update connections with the new rate and pdu size config.
|
# Update connections with the new rate and pdu size config.
|
||||||
self.build(rebuild=True)
|
self.build(rebuild=True)
|
||||||
|
|
||||||
|
for atten_val in self.atten_vals:
|
||||||
|
if atten_val != -1:
|
||||||
|
for atten_idx in self.attenuators:
|
||||||
|
self.set_atten(atten_idx, atten_val)
|
||||||
|
|
||||||
self.verify_controller()
|
self.verify_controller()
|
||||||
print("Starting multicast traffic (if any configured)")
|
print("Starting multicast traffic (if any configured)")
|
||||||
self.multicast_profile.start_mc(debug_=self.debug)
|
self.multicast_profile.start_mc(debug_=self.debug)
|
||||||
@@ -620,21 +633,17 @@ class L3VariableTime(Realm):
|
|||||||
if self.influxdb == None:
|
if self.influxdb == None:
|
||||||
return
|
return
|
||||||
|
|
||||||
valuemap=dict()
|
|
||||||
valuemap['requested-ul-bps'] = ul
|
|
||||||
valuemap['requested-ul-bps'] = dl
|
|
||||||
valuemap['ul-pdu-size'] = ul_pdu
|
|
||||||
valuemap['dl-pdu-size'] = dl_pdu
|
|
||||||
valuemap['station-count'] = sta_count
|
|
||||||
for key, value in valuemap.items():
|
|
||||||
tags=dict()
|
tags=dict()
|
||||||
tags["region"] = 'us-west'
|
tags['requested-ul-bps'] = ul
|
||||||
|
tags['requested-ul-bps'] = dl
|
||||||
|
tags['ul-pdu-size'] = ul_pdu
|
||||||
|
tags['dl-pdu-size'] = dl_pdu
|
||||||
|
tags['station-count'] = sta_count
|
||||||
tags["script"] = 'test_l3_longevity'
|
tags["script"] = 'test_l3_longevity'
|
||||||
self.influxdb.post_to_influx(key, value, tags)
|
|
||||||
|
|
||||||
#self.influxdb.post_to_influx("total-download-bps", total_dl_bps, tags)
|
self.influxdb.post_to_influx("total-download-bps", total_dl_bps, tags)
|
||||||
#self.influxdb.post_to_influx("total-upload-bps", total_ul_bps, tags)
|
self.influxdb.post_to_influx("total-upload-bps", total_ul_bps, tags)
|
||||||
#self.influxdb.post_to_influx("total-bi-directional-bps", total_ul_bps + total_dl_bps, tags)
|
self.influxdb.post_to_influx("total-bi-directional-bps", total_ul_bps + total_dl_bps, tags)
|
||||||
|
|
||||||
# Stop traffic and admin down stations.
|
# Stop traffic and admin down stations.
|
||||||
def stop(self):
|
def stop(self):
|
||||||
@@ -864,6 +873,9 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr
|
|||||||
parser.add_argument('-bmr','--side_b_min_bps', help='--side_b_min_bps , upstream min tx rate default 256000', default="256000")
|
parser.add_argument('-bmr','--side_b_min_bps', help='--side_b_min_bps , upstream min tx rate default 256000', default="256000")
|
||||||
parser.add_argument('-bmp','--side_b_min_pdu', help='--side_b_min_pdu , upstream pdu size default 1518', default="MTU")
|
parser.add_argument('-bmp','--side_b_min_pdu', help='--side_b_min_pdu , upstream pdu size default 1518', default="MTU")
|
||||||
|
|
||||||
|
parser.add_argument('--attenuators', help='--attenuators, comma separated list of attenuator module eids: shelf.resource.atten-serno.atten-idx', default="")
|
||||||
|
parser.add_argument('--atten_vals', help='--atten_vals, comma separated list of attenuator settings in ddb units (1/10 of db)', default="")
|
||||||
|
|
||||||
parser.add_argument('--influx_host', help='Hostname for the Influx database')
|
parser.add_argument('--influx_host', help='Hostname for the Influx database')
|
||||||
parser.add_argument('--influx_port', help='IP Port for the Influx database', default=8086)
|
parser.add_argument('--influx_port', help='IP Port for the Influx database', default=8086)
|
||||||
parser.add_argument('--influx_user', help='Username for the Influx database')
|
parser.add_argument('--influx_user', help='Username for the Influx database')
|
||||||
@@ -979,6 +991,14 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr
|
|||||||
dl_rates = args.side_b_min_bps.split(",")
|
dl_rates = args.side_b_min_bps.split(",")
|
||||||
ul_pdus = args.side_a_min_pdu.split(",")
|
ul_pdus = args.side_a_min_pdu.split(",")
|
||||||
dl_pdus = args.side_b_min_pdu.split(",")
|
dl_pdus = args.side_b_min_pdu.split(",")
|
||||||
|
if args.attenuators == "":
|
||||||
|
attenuators = []
|
||||||
|
else:
|
||||||
|
attenuators = args.attenuators.split(",")
|
||||||
|
if (args.atten_vals == ""):
|
||||||
|
atten_vals = []
|
||||||
|
else:
|
||||||
|
atten_vals = args.atten_vals.split(",")
|
||||||
|
|
||||||
if (len(ul_rates) != len(dl_rates)):
|
if (len(ul_rates) != len(dl_rates)):
|
||||||
print("ERROR: ul_rates %s and dl_rates %s arrays must be same length\n" %(len(ul_rates), len(dl_rates)))
|
print("ERROR: ul_rates %s and dl_rates %s arrays must be same length\n" %(len(ul_rates), len(dl_rates)))
|
||||||
@@ -1009,6 +1029,8 @@ python3 test_l3_longevity.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr
|
|||||||
side_b_min_rate=dl_rates,
|
side_b_min_rate=dl_rates,
|
||||||
side_a_min_pdu=ul_pdus,
|
side_a_min_pdu=ul_pdus,
|
||||||
side_b_min_pdu=dl_pdus,
|
side_b_min_pdu=dl_pdus,
|
||||||
|
attenuators=attenuators,
|
||||||
|
atten_vals=atten_vals,
|
||||||
debug=debug,
|
debug=debug,
|
||||||
outfile=csv_outfile,
|
outfile=csv_outfile,
|
||||||
influxdb=influxdb)
|
influxdb=influxdb)
|
||||||
|
|||||||
Reference in New Issue
Block a user