# a list of these objects is not super useful unless localrealm.remove_vlan_by_eid(eid) time.sleep(0.03) # convert station map to plain list del_sta_names = [] try: for eid, value in station_map.items(): #print("jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj") #pprint(eid) #print("rfind: %d" % ) #print("jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj") tname = eid[eid.rfind('.'):] del_sta_names.append(tname) except Exception as x: localrealm.error(x) LFUtils.waitUntilPortsDisappear(resource_id=1, base_url=localrealm.lfclient_url, port_list=del_sta_names, debug=False) print("** Creating Stations **") profile = localrealm.new_station_profile() profile.use_wpa2(True, "jedway-wpa2-x2048-5-1", "jedway-wpa2-x2048-5-1") profile.set_command_flag("add_sta", "80211u_enable", 1) profile.set_number_template("0100") profile.create(1, "wiphy0", 5) try: sta_list = localrealm.station_list() print("%s Stations:" % {len(sta_list)})
class CreateSTA_CX(LFCliBase): def __init__(self, host, port, radio, num_sta, sta_id, ssid, security, password, upstream, protocol, min_bps, max_bps, security_debug_on=True, _exit_on_error=True, _exit_on_fail=True): super().__init__(host, port, _debug=security_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) self.host = host self.port = port self.radio = radio self.num_sta = num_sta self.sta_id = sta_id self.ssid = ssid self.security = security self.password = password self.upstream = upstream self.protocol = protocol self.min_bps = min_bps self.max_bps = max_bps #Creating a Realm Object self.local_realm = Realm(lfclient_host=host, lfclient_port=port) #Creating Profile Objects self.station_profile = self.local_realm.new_station_profile() self.cx_profile = self.local_realm.new_l3_cx_profile() #Setting CX Name self.cx_profile.name_prefix_ = "Connection" self.cx_names = [] self.sta_list = [] self.endp = [] for i in range(sta_id, sta_id + num_sta): self.sta_list.append("sta00") #portDhcpUpRequest ''' upstream_dhcp = LFRequest.LFRequest("http://"+str(host)+":"+str(port)+"/"+"/cli-form/set_port") upstream_dhcp.addPostData( LFUtils.portSetDhcpDownRequest(1, upstream)) upstream_dhcp.formPost() time.sleep(2) upstream_dhcp.addPostData( LFUtils.portUpRequest(1, upstream)) upstream_dhcp.formPost() print(upstream + "Set to DHCP For Cross Connects") ''' def build(self): #Creating Stations of Given Profile Settings self.station_profile.use_security(self.security, self.ssid, passwd=self.password) self.station_profile.create(self.radio, num_stations=self.num_sta, sta_names_=self.sta_list) self.station_profile.admin_up() #Wait for a while time.sleep(15) #Setting up the Parameters for CX self.cx_profile.side_a_min_bps = self.min_bps self.cx_profile.side_b_min_bps = self.min_bps self.cx_profile.side_a_max_bps = self.max_bps self.cx_profile.side_b_max_bps = self.max_bps self.cx_profile.side_a_min_pdu = 'Auto' self.cx_profile.side_b_min_pdu = 'Auto' self.cx_profile.report_timer = 1000 self.cx_profile.side_a_min_pkt = 'Same' self.cx_profile.side_a_max_pkt = 'Same' #Create Connections of Given Parameters self.cx_profile.create(self.protocol, side_a="1.1." + self.upstream, side_b=list( self.local_realm.find_ports_like("sta0+"))) time.sleep(15) # Getting all the Endpoint Names for measuring Throughput Later for i in self.cx_profile.get_cx_names(): self.cx_names.append(i) for j in self.cx_names: x = self.local_realm.json_get("/cx/" + j) self.endp.append(x.get(j).get('endpoints')[1]) #print(self.endp) return 0 def start(self): #self.station_profile.admin_up() self.cx_profile.start_cx() time.sleep(5) return 0 def stop(self): self.cx_profile.stop_cx() time.sleep(5) self.lf_stations.admin_down() time.sleep(5) return 0 def cleanup(self): # Removing Connections self.local_realm.cleanup_cxe_prefix(self.cx_profile.name_prefix) vap = self.local_realm.find_ports_like("vap+") bridges = self.local_realm.find_ports_like("br+") station_map = self.local_realm.find_ports_like("sta+") #Removing Bridges for eid, record in bridges.items(): self.local_realm.remove_vlan_by_eid(eid) time.sleep(0.03) #Removing VAP for eid, record in vap.items(): self.local_realm.remove_vlan_by_eid(eid) time.sleep(0.03) #Removing stations for eid, record in station_map.items(): self.local_realm.remove_vlan_by_eid(eid) time.sleep(0.03) del_sta_names = [] try: for eid, value in station_map.items(): tname = eid[eid.rfind('.'):] del_sta_names.append(tname) except Exception as x: self.local_realm.error(x) try: LFUtils.waitUntilPortsDisappear( base_url=self.local_realm.lfclient_url, port_list=del_sta_names, debug=True) print("Ports Successfully Cleaned up") return 0 except: print("Ports Successfully Cleaned up") time.sleep(5) return 0