diff --git a/lf_libs/lf_libs.py b/lf_libs/lf_libs.py index e7a2b646..084b2bec 100644 --- a/lf_libs/lf_libs.py +++ b/lf_libs/lf_libs.py @@ -1100,12 +1100,13 @@ class lf_libs: data = self.json_get("/radiostatus/all") return data[radio]["max_vifs"] - def add_vlan(self, vlan_ids=[]): + def add_vlan(self, vlan_ids=[], build=True): self.temp_raw_lines = self.default_scenario_raw_lines.copy() data = self.json_get("/port/all") flag = 0 profile_name = "" port_list = [] + vlan_raws = [] # temp_raw_lines = self.default_scenario_raw_lines.copy() for port in self.wan_ports: for vlans in vlan_ids: @@ -1119,53 +1120,60 @@ class lf_libs: elif self.scenario == "dhcp-external": profile_name = "vlan_profile" port_list.append(str(port) + "." + str(vlans)) + vlan_raws.append(["profile_link " + port + " " + profile_name + " 1 " + port + + " NA " + port.split(".")[2] + ",AUTO -1 " + str(vlans)]) self.temp_raw_lines.append(["profile_link " + port + " " + profile_name + " 1 " + port + " NA " + port.split(".")[2] + ",AUTO -1 " + str(vlans)]) - self.chamber_view(raw_lines="custom") - if self.scenario == "dhcp-external": - for port in port_list: - data = { - "shelf": port.split(".")[0], - "resource": port.split(".")[1], - "port": port.split(".")[2] + "." + port.split(".")[3], - "current_flags": 2147483648, - "interest": 16384 - } - self.json_post("/cli-json/set_port", data) - time.sleep(2) - time.sleep(5) - # query and fetch vlan Ip Address - port_data = self.json_get(_req_url="/port?fields=alias,parent+dev,port+type,ip,mac")['interfaces'] - logging.info("Port data: " + str(port_data)) - vlan_table_data = {} - port = [] - ip = [] - parent_dev = [] - not_ip_vlans = [] - vlan_ip_fail = False - for i in port_data: - for item in i: - if i[item]['port type'] == '802.1Q VLAN' and i[item]['ip'] == '0.0.0.0': - vlan_ip_fail = True - logging.error(f"VLAN Interface - {i[item]['alias']} do not have IP") - port.append(item) - ip.append(i[item]['ip']) - not_ip_vlans.append(item) - parent_dev.append(i[item]['parent dev']) - elif i[item]['port type'] == '802.1Q VLAN' and i[item]['ip'] != '0.0.0.0': - port.append(item) - ip.append(i[item]['ip']) - parent_dev.append(i[item]['parent dev']) - # creating dict for vlan table - vlan_table_data["Port"] = port - vlan_table_data["Parent Dev"] = parent_dev - vlan_table_data["ip"] = ip - # Attaching vlan table to allure - self.attach_table_allure(data=vlan_table_data, allure_name="VLAN Table") - if vlan_ip_fail: - # Fail if Vlan don't have IP - pytest.fail("VLAN do not have IP:-" + str(not_ip_vlans)) + if build: + self.chamber_view(raw_lines="custom") + if self.scenario == "dhcp-external": + for port in port_list: + data = { + "shelf": port.split(".")[0], + "resource": port.split(".")[1], + "port": port.split(".")[2] + "." + port.split(".")[3], + "current_flags": 2147483648, + "interest": 16384 + } + self.json_post("/cli-json/set_port", data) + time.sleep(2) + time.sleep(5) + # query and fetch vlan Ip Address + port_data = self.json_get(_req_url="/port?fields=alias,parent+dev,port+type,ip,mac")['interfaces'] + logging.info("Port data: " + str(port_data)) + vlan_table_data = {} + port = [] + ip = [] + parent_dev = [] + not_ip_vlans = [] + vlan_ip_fail = False + for i in port_data: + for item in i: + if i[item]['port type'] == '802.1Q VLAN' and i[item]['ip'] == '0.0.0.0': + vlan_ip_fail = True + logging.error(f"VLAN Interface - {i[item]['alias']} do not have IP") + port.append(item) + ip.append(i[item]['ip']) + not_ip_vlans.append(item) + parent_dev.append(i[item]['parent dev']) + elif i[item]['port type'] == '802.1Q VLAN' and i[item]['ip'] != '0.0.0.0': + port.append(item) + ip.append(i[item]['ip']) + parent_dev.append(i[item]['parent dev']) + # creating dict for vlan table + vlan_table_data["Port"] = port + vlan_table_data["Parent Dev"] = parent_dev + vlan_table_data["ip"] = ip + # Attaching vlan table to allure + self.attach_table_allure(data=vlan_table_data, allure_name="VLAN Table") + if vlan_ip_fail: + # Fail if Vlan don't have IP + pytest.fail("VLAN do not have IP:-" + str(not_ip_vlans)) + return vlan_raws + else: + return vlan_raws + def chamber_view(self, delete_old_scenario=True, raw_lines="default"): """create chamber view. raw_lines values are default | custom""" diff --git a/lf_libs/lf_tests.py b/lf_libs/lf_tests.py index 046b34bc..0a2c4e85 100644 --- a/lf_libs/lf_tests.py +++ b/lf_libs/lf_tests.py @@ -969,6 +969,7 @@ class lf_tests(lf_libs): sort="interleave", raw_lines=[], move_to_influx=False, dut_data={}, ssid_name=None, num_stations={}, add_stations=True): wificapacity_obj_list = [] + vlan_raw_lines = None for dut in self.dut_data: sets = [["DUT_NAME", dut["model"]]] identifier = dut["identifier"] @@ -989,7 +990,7 @@ class lf_tests(lf_libs): logging.error("VLAN ID is Unspecified in the VLAN Case") pytest.skip("VLAN ID is Unspecified in the VLAN Case") else: - self.add_vlan(vlan_ids=[vlan_id]) + vlan_raw_lines = self.add_vlan(vlan_ids=[vlan_id], build=True) ret = self.get_wan_upstream_ports() upstream_port = ret[identifier] + "." + str(vlan_id) logging.info("Upstream data: " + str(upstream_port)) @@ -1028,6 +1029,9 @@ class lf_tests(lf_libs): self.add_stations(band=band_, num_stations=num_stations[band_], ssid_name=ssid_name, dut_data=dut_data, identifier=identifier) + if vlan_raw_lines is not None: + for i in vlan_raw_lines: + self.temp_raw_lines.append(i) self.chamber_view(raw_lines="custom") wificapacity_obj = WiFiCapacityTest(lfclient_host=self.manager_ip, lf_port=self.manager_http_port,