mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-03 20:27:54 +00:00 
			
		
		
		
	Fixed dut creation and update
Signed-off-by: shivam <shivam.thakur@candelatech.com>
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							@@ -137,26 +137,27 @@ class lf_libs:
 | 
				
			|||||||
        logging.basicConfig(format='%(asctime)s - %(message)s', level=log_level)
 | 
					        logging.basicConfig(format='%(asctime)s - %(message)s', level=log_level)
 | 
				
			||||||
        lf_data = dict(lf_data)
 | 
					        lf_data = dict(lf_data)
 | 
				
			||||||
        self.dut_data = dut_data
 | 
					        self.dut_data = dut_data
 | 
				
			||||||
        try:
 | 
					        # try:
 | 
				
			||||||
            self.lanforge_data = lf_data.get("details")
 | 
					        self.lanforge_data = lf_data.get("details")
 | 
				
			||||||
            self.testbed = lf_data.get("testbed")
 | 
					        self.testbed = lf_data.get("testbed")
 | 
				
			||||||
            self.scenario = lf_data.get("scenario")
 | 
					        self.scenario = lf_data.get("scenario")
 | 
				
			||||||
            self.setup_lf_data()
 | 
					        self.setup_lf_data()
 | 
				
			||||||
            # self.load_scenario()
 | 
					        self.setup_relevent_profiles()
 | 
				
			||||||
            self.setup_metadata()
 | 
					        # self.load_scenario()
 | 
				
			||||||
            if self.scenario == "dhcp-bridge":
 | 
					        # self.setup_metadata()
 | 
				
			||||||
                logging.info("Scenario name: " + str(self.scenario))
 | 
					        if self.scenario == "dhcp-bridge":
 | 
				
			||||||
                # creating default  raw lines for chamberview
 | 
					            logging.info("Scenario name: " + str(self.scenario))
 | 
				
			||||||
                self.create_dhcp_bridge()
 | 
					            # creating default  raw lines for chamberview
 | 
				
			||||||
            elif self.scenario == "dhcp-external":
 | 
					            self.create_dhcp_bridge()
 | 
				
			||||||
                logging.info("Scenario name: " + str(self.scenario))
 | 
					        elif self.scenario == "dhcp-external":
 | 
				
			||||||
                self.create_dhcp_external()
 | 
					            logging.info("Scenario name: " + str(self.scenario))
 | 
				
			||||||
            self.chamber_view(raw_lines=self.default_scenario_raw_lines)
 | 
					            self.create_dhcp_external()
 | 
				
			||||||
            self.setup_relevent_profiles()
 | 
					        self.chamber_view(raw_lines=self.default_scenario_raw_lines)
 | 
				
			||||||
            self.setup_dut()
 | 
					        self.setup_dut()
 | 
				
			||||||
        except Exception as e:
 | 
					
 | 
				
			||||||
            logging.error("lf_data has bad values: " + str(lf_data))
 | 
					    # except Exception as e:
 | 
				
			||||||
            logging.error(e)
 | 
					    #         logging.error("lf_data has bad values: " + str(lf_data))
 | 
				
			||||||
 | 
					    #         logging.error(e)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
        setup_lf_data : used to set object variables that are passed from lab_info.json
 | 
					        setup_lf_data : used to set object variables that are passed from lab_info.json
 | 
				
			||||||
@@ -197,10 +198,6 @@ class lf_libs:
 | 
				
			|||||||
                          serial_num=self.dut_data[index]["identifier"])
 | 
					                          serial_num=self.dut_data[index]["identifier"])
 | 
				
			||||||
            dut_obj.setup()
 | 
					            dut_obj.setup()
 | 
				
			||||||
            dut_obj.add_ssids()
 | 
					            dut_obj.add_ssids()
 | 
				
			||||||
            dut_obj.show_text_blob(None, None, True)  # Show changes on GUI
 | 
					 | 
				
			||||||
            dut_obj.sync_cv()
 | 
					 | 
				
			||||||
            time.sleep(2)
 | 
					 | 
				
			||||||
            dut_obj.sync_cv()
 | 
					 | 
				
			||||||
            print("Creating DUT")
 | 
					            print("Creating DUT")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setup_metadata(self):
 | 
					    def setup_metadata(self):
 | 
				
			||||||
@@ -345,17 +342,18 @@ class lf_libs:
 | 
				
			|||||||
                          lan_port=gateway_ip)
 | 
					                          lan_port=gateway_ip)
 | 
				
			||||||
            dut_obj.setup()
 | 
					            dut_obj.setup()
 | 
				
			||||||
            dut_obj.add_ssids()
 | 
					            dut_obj.add_ssids()
 | 
				
			||||||
            dut_obj.show_text_blob(None, None, True)  # Show changes on GUI
 | 
					            # dut_obj.show_text_blob(None, None, True)  # Show changes on GUI
 | 
				
			||||||
            dut_obj.sync_cv()
 | 
					            # dut_obj.sync_cv()
 | 
				
			||||||
            time.sleep(2)
 | 
					            # time.sleep(2)
 | 
				
			||||||
            dut_obj.sync_cv()
 | 
					            # dut_obj.sync_cv()
 | 
				
			||||||
            self.default_scenario_raw_lines.append(["profile_link " + upstream_resources + " upstream-dhcp 1 NA NA " +
 | 
					            self.default_scenario_raw_lines.append(["profile_link " + upstream_resources + " upstream-dhcp 1 NA NA " +
 | 
				
			||||||
                                                    upstream_port.split(".")[2] + ",AUTO -1 NA"])
 | 
					                                                    upstream_port.split(".")[2] + ",AUTO -1 NA"])
 | 
				
			||||||
            self.default_scenario_raw_lines.append(
 | 
					            self.default_scenario_raw_lines.append(
 | 
				
			||||||
                ["profile_link " + uplink_resources + " uplink-nat 1 'DUT: upstream LAN "
 | 
					                ["profile_link " + uplink_resources + " uplink-nat 1 'DUT: upstream LAN "
 | 
				
			||||||
                 + gateway_ip +
 | 
					                 + gateway_ip
 | 
				
			||||||
                 + "' NA " + uplink_port.split(".")[2] + "," + upstream_port.split(".")[2] + " -1 NA"])
 | 
					                 + "' NA " + uplink_port.split(".")[2] + "," + upstream_port.split(".")[2] + " -1 NA"])
 | 
				
			||||||
        return self.default_scenario_raw_lines
 | 
					        return self.default_scenario_raw_lines
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def create_dhcp_external(self):
 | 
					    def create_dhcp_external(self):
 | 
				
			||||||
        self.setup_connectivity_port(data=self.wan_ports)
 | 
					        self.setup_connectivity_port(data=self.wan_ports)
 | 
				
			||||||
        self.setup_connectivity_port(data=self.lan_ports)
 | 
					        self.setup_connectivity_port(data=self.lan_ports)
 | 
				
			||||||
@@ -365,6 +363,7 @@ class lf_libs:
 | 
				
			|||||||
            self.default_scenario_raw_lines.append(["profile_link " + upstream_resources + " upstream 1 NA NA " +
 | 
					            self.default_scenario_raw_lines.append(["profile_link " + upstream_resources + " upstream 1 NA NA " +
 | 
				
			||||||
                                                    upstream_port.split(".")[2] + ",AUTO -1 NA"])
 | 
					                                                    upstream_port.split(".")[2] + ",AUTO -1 NA"])
 | 
				
			||||||
        return self.default_scenario_raw_lines
 | 
					        return self.default_scenario_raw_lines
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def json_get(self, _req_url="/"):
 | 
					    def json_get(self, _req_url="/"):
 | 
				
			||||||
        cli_base = LFCliBase(_lfjson_host=self.manager_ip, _lfjson_port=self.manager_http_port)
 | 
					        cli_base = LFCliBase(_lfjson_host=self.manager_ip, _lfjson_port=self.manager_http_port)
 | 
				
			||||||
        json_response = cli_base.json_get(_req_url=_req_url)
 | 
					        json_response = cli_base.json_get(_req_url=_req_url)
 | 
				
			||||||
@@ -410,9 +409,14 @@ class lf_libs:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # Create upstream-dhcp and uplink-nat profile if they don't exists
 | 
					        # Create upstream-dhcp and uplink-nat profile if they don't exists
 | 
				
			||||||
        # Checking availability of upstream-dhcp profile
 | 
					        # Checking availability of upstream-dhcp profile
 | 
				
			||||||
        upstream_dhcp = profile_utility_obj.check_profile(profile_name="upstream-dhcp")
 | 
					        try:
 | 
				
			||||||
        # Checking availability of uplink-nat profile
 | 
					            upstream_dhcp = profile_utility_obj.check_profile(profile_name="upstream-dhcp")
 | 
				
			||||||
        uplink_nat = profile_utility_obj.check_profile(profile_name="uplink-nat")
 | 
					            # Checking availability of uplink-nat profile
 | 
				
			||||||
 | 
					            uplink_nat = profile_utility_obj.check_profile(profile_name="uplink-nat")
 | 
				
			||||||
 | 
					        except Exception as e:
 | 
				
			||||||
 | 
					            upstream_dhcp = True
 | 
				
			||||||
 | 
					            uplink_nat = True
 | 
				
			||||||
 | 
					            pass
 | 
				
			||||||
        if upstream_dhcp:
 | 
					        if upstream_dhcp:
 | 
				
			||||||
            logging.info("upstream_dhcp profile: Available")
 | 
					            logging.info("upstream_dhcp profile: Available")
 | 
				
			||||||
            profile_utility_obj.remove_profile(name="upstream-dhcp")
 | 
					            profile_utility_obj.remove_profile(name="upstream-dhcp")
 | 
				
			||||||
@@ -423,13 +427,17 @@ class lf_libs:
 | 
				
			|||||||
                                            profile_flags="DHCP-SERVER")
 | 
					                                            profile_flags="DHCP-SERVER")
 | 
				
			||||||
        if uplink_nat:
 | 
					        if uplink_nat:
 | 
				
			||||||
            profile_utility_obj.remove_profile(name="uplink-nat")
 | 
					            profile_utility_obj.remove_profile(name="uplink-nat")
 | 
				
			||||||
            profile_utility_obj.add_profile(profile_name="uplink-nat", profile_type="uplink", profile_flags=None)
 | 
					            profile_utility_obj.add_profile(profile_name="uplink-nat", profile_type="uplink", profile_flags="NAT")
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            profile_utility_obj.add_profile(profile_name="uplink-nat", profile_type="uplink", profile_flags=None)
 | 
					            profile_utility_obj.add_profile(profile_name="uplink-nat", profile_type="uplink", profile_flags="NAT")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Create VLAN Based profiles
 | 
					        # Create VLAN Based profiles
 | 
				
			||||||
        if self.scenario == "dhcp-bridge":
 | 
					        if self.scenario == "dhcp-bridge":
 | 
				
			||||||
            vlan_dhcp_profile = profile_utility_obj.check_profile(profile_name="vlan_dhcp_profile")
 | 
					            try:
 | 
				
			||||||
 | 
					                vlan_dhcp_profile = profile_utility_obj.check_profile(profile_name="vlan_dhcp_profile")
 | 
				
			||||||
 | 
					            except Exception as e:
 | 
				
			||||||
 | 
					                vlan_dhcp_profile = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if vlan_dhcp_profile:
 | 
					            if vlan_dhcp_profile:
 | 
				
			||||||
                profile_utility_obj.remove_profile(name="vlan_dhcp_profile")
 | 
					                profile_utility_obj.remove_profile(name="vlan_dhcp_profile")
 | 
				
			||||||
                profile_utility_obj.add_profile(profile_name="vlan_dhcp_profile", profile_type="vlan",
 | 
					                profile_utility_obj.add_profile(profile_name="vlan_dhcp_profile", profile_type="vlan",
 | 
				
			||||||
@@ -439,7 +447,10 @@ class lf_libs:
 | 
				
			|||||||
                                                profile_flags="DHCP-SERVER")
 | 
					                                                profile_flags="DHCP-SERVER")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        elif self.scenario == "dhcp-external":
 | 
					        elif self.scenario == "dhcp-external":
 | 
				
			||||||
            vlan_profile = profile_utility_obj.check_profile(profile_name="vlan_profile")
 | 
					            try:
 | 
				
			||||||
 | 
					                vlan_profile = profile_utility_obj.check_profile(profile_name="vlan_profile")
 | 
				
			||||||
 | 
					            except Exception as e:
 | 
				
			||||||
 | 
					                vlan_profile = True
 | 
				
			||||||
            if vlan_profile:
 | 
					            if vlan_profile:
 | 
				
			||||||
                profile_utility_obj.remove_profile(name="vlan_profile")
 | 
					                profile_utility_obj.remove_profile(name="vlan_profile")
 | 
				
			||||||
                profile_utility_obj.add_profile(profile_name="vlan_profile", profile_type="vlan", profile_flags=None)
 | 
					                profile_utility_obj.add_profile(profile_name="vlan_profile", profile_type="vlan", profile_flags=None)
 | 
				
			||||||
@@ -531,8 +542,6 @@ class lf_libs:
 | 
				
			|||||||
                self.json_post("/cli-json/set_port", data)
 | 
					                self.json_post("/cli-json/set_port", data)
 | 
				
			||||||
                time.sleep(2)
 | 
					                time.sleep(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def chamber_view(self, delete_old_scenario=True, raw_lines=[]):
 | 
					    def chamber_view(self, delete_old_scenario=True, raw_lines=[]):
 | 
				
			||||||
        print(self.chamberview_object)
 | 
					        print(self.chamberview_object)
 | 
				
			||||||
        if delete_old_scenario:
 | 
					        if delete_old_scenario:
 | 
				
			||||||
@@ -631,4 +640,3 @@ class SCP_File:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def save_current_scenario(self):
 | 
					    def save_current_scenario(self):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								lf_libs/scan_ssid.csv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								lf_libs/scan_ssid.csv
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					,age,auth,beacon,bss,channel,entity id,frequency,info,signal,ssid
 | 
				
			||||||
 | 
					0,4698,Open,100,00:00:c1:01:88:15,1,1.1.4,2412,2x2 MCS 0-11 AX,-17.0,Maverick-018812
 | 
				
			||||||
 | 
					1,354731974,WPA2 WPA3,100,02:00:c1:01:88:15,1,1.1.4,2412,2x2 MCS 0-11 AX,-22.0,ssid_wpa3_p_m_2g_br
 | 
				
			||||||
 | 
					2,354731972,WPA WPA2,100,06:00:c1:01:88:15,1,1.1.4,2412,2x2 MCS 0-11 AX,-21.0,ssid_wpa_wpa2_p_m_2g_br
 | 
				
			||||||
		
		
			
  | 
							
								
								
									
										0
									
								
								lf_libs/sh-results.csv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								lf_libs/sh-results.csv
									
									
									
									
									
										Normal file
									
								
							| 
		
		
			 | 
							
								
								
									
										
											BIN
										
									
								
								lf_libs/sniff_radio.pcap
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lf_libs/sniff_radio.pcap
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -26,6 +26,7 @@ class cv_dut(LFCliBase):
 | 
				
			|||||||
                 hw_version="NA",
 | 
					                 hw_version="NA",
 | 
				
			||||||
                 serial_num="NA",
 | 
					                 serial_num="NA",
 | 
				
			||||||
                 model_num="NA",
 | 
					                 model_num="NA",
 | 
				
			||||||
 | 
					                 lan_port="BLANK",
 | 
				
			||||||
                 desired_dut_flags=None,
 | 
					                 desired_dut_flags=None,
 | 
				
			||||||
                 desired_dut_flags_mask=None
 | 
					                 desired_dut_flags_mask=None
 | 
				
			||||||
                 ):
 | 
					                 ):
 | 
				
			||||||
@@ -39,7 +40,7 @@ class cv_dut(LFCliBase):
 | 
				
			|||||||
        self.serial_num = serial_num
 | 
					        self.serial_num = serial_num
 | 
				
			||||||
        self.serial_port = "[BLANK]"
 | 
					        self.serial_port = "[BLANK]"
 | 
				
			||||||
        self.wan_port = "[BLANK]"
 | 
					        self.wan_port = "[BLANK]"
 | 
				
			||||||
        self.lan_port = "[BLANK]"
 | 
					        self.lan_port = lan_port
 | 
				
			||||||
        self.api_id = "0"
 | 
					        self.api_id = "0"
 | 
				
			||||||
        self.flags_mask = "NA"
 | 
					        self.flags_mask = "NA"
 | 
				
			||||||
        if desired_dut_flags:
 | 
					        if desired_dut_flags:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,7 +31,7 @@ class ProfileUtility(Realm):
 | 
				
			|||||||
        """Add profile"""
 | 
					        """Add profile"""
 | 
				
			||||||
        profile_type_data = {"as_is": 0, "sta": 1, "bridged_ap": 2, "routed_ap": 3, "upstream": 4, "monitor": 5,
 | 
					        profile_type_data = {"as_is": 0, "sta": 1, "bridged_ap": 2, "routed_ap": 3, "upstream": 4, "monitor": 5,
 | 
				
			||||||
                             "mobile_sta": 6, "rdd": 7, "client": 8, "bond": 9, "peer": 10, "uplink": 11, "vlan": 12}
 | 
					                             "mobile_sta": 6, "rdd": 7, "client": 8, "bond": 9, "peer": 10, "uplink": 11, "vlan": 12}
 | 
				
			||||||
        profile_flags_data = {"DHCP-SERVER": "0x1", "NAT": "0x100"}
 | 
					        profile_flags_data = {"DHCP-SERVER": "0x1", "NAT": "0x100", }
 | 
				
			||||||
        data = {
 | 
					        data = {
 | 
				
			||||||
            "name": None,
 | 
					            "name": None,
 | 
				
			||||||
            "profile_type": None,
 | 
					            "profile_type": None,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -103,7 +103,6 @@ class DUT(dut):
 | 
				
			|||||||
        self.dut_name = dut_name
 | 
					        self.dut_name = dut_name
 | 
				
			||||||
        self.ssid = ssid
 | 
					        self.ssid = ssid
 | 
				
			||||||
        self.lan_port = lan_port
 | 
					        self.lan_port = lan_port
 | 
				
			||||||
        print("JITT")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def setup(self):
 | 
					    def setup(self):
 | 
				
			||||||
        self.create_dut()
 | 
					        self.create_dut()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user