mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-10-31 18:58:01 +00:00
Updated function usage, removed start/stop method, renamed to example from test
This commit is contained in:
@@ -153,29 +153,6 @@ def main():
|
|||||||
ip_test.timeout = 60
|
ip_test.timeout = 60
|
||||||
ip_test.build()
|
ip_test.build()
|
||||||
|
|
||||||
if not ip_test.passes() :
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
ip_test.start()
|
|
||||||
|
|
||||||
if not ip_test.passes() :
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
sleep(ip_test.timeout)
|
|
||||||
ip_test.stop()
|
|
||||||
|
|
||||||
if not ip_test.passes() :
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
ip_test.run()
|
|
||||||
print("Full Test Passed: %s" % ip_test.run_test_full())
|
|
||||||
print("Range Test Passed: %s" % ip_test.run_test_custom("00005", "00009"))
|
|
||||||
print("Custom Test Passed: %s" % ip_test.run_test_custom(sta_list=["sta00001", "sta00003", "sta00009", "sta00002"]))
|
|
||||||
|
|
||||||
ip_test.cleanup()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
74
py-scripts/example_wep_connection.py
Executable file
74
py-scripts/example_wep_connection.py
Executable file
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
if sys.version_info[0] != 3:
|
||||||
|
print("This script requires Python 3")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if 'py-json' not in sys.path:
|
||||||
|
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||||
|
import LANforge
|
||||||
|
from LANforge.lfcli_base import LFCliBase
|
||||||
|
from LANforge import LFUtils
|
||||||
|
import realm
|
||||||
|
import time
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
|
||||||
|
class IPv4Test(LFCliBase):
|
||||||
|
def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", _debug_on=False,
|
||||||
|
_exit_on_error=False,
|
||||||
|
_exit_on_fail=False):
|
||||||
|
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
||||||
|
self.host = host
|
||||||
|
self.port = port
|
||||||
|
self.ssid = ssid
|
||||||
|
self.security = security
|
||||||
|
self.password = password
|
||||||
|
self.sta_list = sta_list
|
||||||
|
self.timeout = 120
|
||||||
|
self.number_template = number_template
|
||||||
|
self.debug = _debug_on
|
||||||
|
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||||
|
self.station_profile = self.local_realm.new_station_profile()
|
||||||
|
|
||||||
|
self.station_profile.lfclient_url = self.lfclient_url
|
||||||
|
self.station_profile.ssid = self.ssid
|
||||||
|
self.station_profile.ssid_pass = self.password,
|
||||||
|
self.station_profile.security = self.security
|
||||||
|
self.station_profile.number_template_ = self.number_template
|
||||||
|
self.station_profile.mode = 0
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
# Build stations
|
||||||
|
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||||
|
self.station_profile.set_number_template(self.number_template)
|
||||||
|
print("Creating stations")
|
||||||
|
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||||
|
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||||
|
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||||
|
self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
|
||||||
|
self._pass("PASS: Station build finished")
|
||||||
|
|
||||||
|
def cleanup(self, sta_list):
|
||||||
|
self.station_profile.cleanup(sta_list)
|
||||||
|
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list,
|
||||||
|
debug=self.debug)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
lfjson_host = "localhost"
|
||||||
|
lfjson_port = 8080
|
||||||
|
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
||||||
|
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wep-48", password="0123456789",
|
||||||
|
security="wep", sta_list=station_list)
|
||||||
|
ip_test.cleanup(station_list)
|
||||||
|
ip_test.timeout = 60
|
||||||
|
ip_test.build()
|
||||||
|
time.sleep(30)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
71
py-scripts/example_wpa2_connection.py
Executable file
71
py-scripts/example_wpa2_connection.py
Executable file
@@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
if sys.version_info[0] != 3:
|
||||||
|
print("This script requires Python 3")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if 'py-json' not in sys.path:
|
||||||
|
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||||
|
import LANforge
|
||||||
|
from LANforge.lfcli_base import LFCliBase
|
||||||
|
from LANforge import LFUtils
|
||||||
|
import realm
|
||||||
|
import time
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
|
||||||
|
class IPv4Test(LFCliBase):
|
||||||
|
def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", _debug_on=False,
|
||||||
|
_exit_on_error=False,
|
||||||
|
_exit_on_fail=False):
|
||||||
|
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
||||||
|
self.host = host
|
||||||
|
self.port = port
|
||||||
|
self.ssid = ssid
|
||||||
|
self.security = security
|
||||||
|
self.password = password
|
||||||
|
self.sta_list = sta_list
|
||||||
|
self.timeout = 120
|
||||||
|
self.number_template = number_template
|
||||||
|
self.debug = _debug_on
|
||||||
|
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||||
|
self.station_profile = self.local_realm.new_station_profile()
|
||||||
|
|
||||||
|
self.station_profile.lfclient_url = self.lfclient_url
|
||||||
|
self.station_profile.ssid = self.ssid
|
||||||
|
self.station_profile.ssid_pass = self.password,
|
||||||
|
self.station_profile.security = self.security
|
||||||
|
self.station_profile.number_template_ = self.number_template
|
||||||
|
self.station_profile.mode = 0
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
# Build stations
|
||||||
|
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||||
|
self.station_profile.set_number_template(self.number_template)
|
||||||
|
print("Creating stations")
|
||||||
|
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||||
|
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||||
|
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||||
|
self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
|
||||||
|
self._pass("PASS: Station build finished")
|
||||||
|
|
||||||
|
def cleanup(self, sta_list):
|
||||||
|
self.station_profile.cleanup(sta_list)
|
||||||
|
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list,
|
||||||
|
debug=self.debug)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
lfjson_host = "localhost"
|
||||||
|
lfjson_port = 8080
|
||||||
|
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
||||||
|
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wpa2-x2048-4-4", password="jedway-wpa2-x2048-4-4",
|
||||||
|
security="wpa2", sta_list=station_list)
|
||||||
|
ip_test.cleanup(station_list)
|
||||||
|
ip_test.timeout = 60
|
||||||
|
ip_test.build()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
72
py-scripts/example_wpa3_connection.py
Executable file
72
py-scripts/example_wpa3_connection.py
Executable file
@@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
if sys.version_info[0] != 3:
|
||||||
|
print("This script requires Python 3")
|
||||||
|
exit(1)
|
||||||
|
if 'py-json' not in sys.path:
|
||||||
|
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||||
|
import LANforge
|
||||||
|
from LANforge.lfcli_base import LFCliBase
|
||||||
|
from LANforge import LFUtils
|
||||||
|
import realm
|
||||||
|
import time
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
|
||||||
|
class IPv4Test(LFCliBase):
|
||||||
|
def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", _debug_on=False,
|
||||||
|
_exit_on_error=False,
|
||||||
|
_exit_on_fail=False):
|
||||||
|
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
||||||
|
self.host = host
|
||||||
|
self.port = port
|
||||||
|
self.ssid = ssid
|
||||||
|
self.security = security
|
||||||
|
self.password = password
|
||||||
|
self.sta_list = sta_list
|
||||||
|
self.timeout = 120
|
||||||
|
self.number_template = number_template
|
||||||
|
self.debug = _debug_on
|
||||||
|
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||||
|
self.station_profile = self.local_realm.new_station_profile()
|
||||||
|
|
||||||
|
self.station_profile.lfclient_url = self.lfclient_url
|
||||||
|
self.station_profile.ssid = self.ssid
|
||||||
|
self.station_profile.ssid_pass = self.password,
|
||||||
|
self.station_profile.security = self.security
|
||||||
|
self.station_profile.number_template_ = self.number_template
|
||||||
|
self.station_profile.mode = 0
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
# Build stations
|
||||||
|
#print("We've gotten into the build stations function")
|
||||||
|
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||||
|
self.station_profile.set_number_template(self.number_template)
|
||||||
|
print("Creating stations")
|
||||||
|
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||||
|
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||||
|
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||||
|
self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
|
||||||
|
self._pass("PASS: Station build finished")
|
||||||
|
|
||||||
|
def cleanup(self, sta_list):
|
||||||
|
self.station_profile.cleanup(sta_list)
|
||||||
|
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list,
|
||||||
|
debug=self.debug)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
lfjson_host = "localhost"
|
||||||
|
lfjson_port = 8080
|
||||||
|
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
||||||
|
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wpa3-44", password="jedway-wpa3-44",
|
||||||
|
security="wpa3", sta_list=station_list,_debug_on=False)
|
||||||
|
#print("created IPv4Test object")
|
||||||
|
ip_test.cleanup(station_list)
|
||||||
|
ip_test.timeout = 60
|
||||||
|
ip_test.build()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
70
py-scripts/example_wpa_connection.py
Executable file
70
py-scripts/example_wpa_connection.py
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
if sys.version_info[0] != 3:
|
||||||
|
print("This script requires Python 3")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if 'py-json' not in sys.path:
|
||||||
|
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||||
|
import LANforge
|
||||||
|
from LANforge.lfcli_base import LFCliBase
|
||||||
|
from LANforge import LFUtils
|
||||||
|
import realm
|
||||||
|
import time
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
|
||||||
|
class IPv4Test(LFCliBase):
|
||||||
|
def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", _debug_on=False,
|
||||||
|
_exit_on_error=False,
|
||||||
|
_exit_on_fail=False):
|
||||||
|
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
||||||
|
self.host = host
|
||||||
|
self.port = port
|
||||||
|
self.ssid = ssid
|
||||||
|
self.security = security
|
||||||
|
self.password = password
|
||||||
|
self.sta_list = sta_list
|
||||||
|
self.timeout = 120
|
||||||
|
self.number_template = number_template
|
||||||
|
self.debug = _debug_on
|
||||||
|
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||||
|
self.station_profile = self.local_realm.new_station_profile()
|
||||||
|
|
||||||
|
self.station_profile.lfclient_url = self.lfclient_url
|
||||||
|
self.station_profile.ssid = self.ssid
|
||||||
|
self.station_profile.ssid_pass = self.password,
|
||||||
|
self.station_profile.security = self.security
|
||||||
|
self.station_profile.number_template_ = self.number_template
|
||||||
|
self.station_profile.mode = 0
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
# Build stations
|
||||||
|
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||||
|
self.station_profile.set_number_template(self.number_template)
|
||||||
|
print("Creating stations")
|
||||||
|
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||||
|
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||||
|
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||||
|
self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
|
||||||
|
self._pass("PASS: Station build finished")
|
||||||
|
|
||||||
|
def cleanup(self, sta_list):
|
||||||
|
self.station_profile.cleanup(sta_list)
|
||||||
|
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list,
|
||||||
|
debug=self.debug)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
lfjson_host = "localhost"
|
||||||
|
lfjson_port = 8080
|
||||||
|
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
||||||
|
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wpa-1", password="jedway-wpa-1",
|
||||||
|
security="wpa", sta_list=station_list)
|
||||||
|
ip_test.cleanup(station_list)
|
||||||
|
ip_test.timeout = 60
|
||||||
|
ip_test.build()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
if sys.version_info[0] != 3:
|
|
||||||
print("This script requires Python 3")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if 'py-json' not in sys.path:
|
|
||||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
|
||||||
import LANforge
|
|
||||||
from LANforge.lfcli_base import LFCliBase
|
|
||||||
from LANforge import LFUtils
|
|
||||||
import realm
|
|
||||||
import time
|
|
||||||
import pprint
|
|
||||||
|
|
||||||
|
|
||||||
class IPv4Test(LFCliBase):
|
|
||||||
def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, number_template="00000", _debug_on=False,
|
|
||||||
_exit_on_error=False,
|
|
||||||
_exit_on_fail=False):
|
|
||||||
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
|
||||||
self.host = host
|
|
||||||
self.port = port
|
|
||||||
self.ssid = ssid
|
|
||||||
self.security = security
|
|
||||||
self.password = password
|
|
||||||
self.sta_list = sta_list
|
|
||||||
self.resource = resource
|
|
||||||
self.timeout = 120
|
|
||||||
self.number_template = number_template
|
|
||||||
self.debug = _debug_on
|
|
||||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
|
||||||
self.station_profile = self.local_realm.new_station_profile()
|
|
||||||
|
|
||||||
self.station_profile.lfclient_url = self.lfclient_url
|
|
||||||
self.station_profile.ssid = self.ssid
|
|
||||||
self.station_profile.ssid_pass = self.password,
|
|
||||||
self.station_profile.security = self.security
|
|
||||||
self.station_profile.number_template_ = self.number_template
|
|
||||||
self.station_profile.mode = 0
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
# Build stations
|
|
||||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
|
||||||
self.station_profile.set_number_template(self.number_template)
|
|
||||||
print("Creating stations")
|
|
||||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
|
||||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
|
||||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
|
||||||
self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
|
|
||||||
self._pass("PASS: Station build finished")
|
|
||||||
|
|
||||||
def start(self, sta_list, print_pass, print_fail):
|
|
||||||
self.station_profile.admin_up(1)
|
|
||||||
associated_map = {}
|
|
||||||
ip_map = {}
|
|
||||||
print("Starting test...")
|
|
||||||
for sec in range(self.timeout):
|
|
||||||
for sta_name in sta_list:
|
|
||||||
sta_status = self.json_get("port/1/1/" + sta_name + "?fields=port,alias,ip,ap", debug_=self.debug)
|
|
||||||
# print(sta_status)
|
|
||||||
if sta_status is None or sta_status['interface'] is None or sta_status['interface']['ap'] is None:
|
|
||||||
continue
|
|
||||||
if len(sta_status['interface']['ap']) == 17 and sta_status['interface']['ap'][-3] == ':':
|
|
||||||
# print("Associated", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
|
||||||
associated_map[sta_name] = 1
|
|
||||||
if sta_status['interface']['ip'] != '0.0.0.0':
|
|
||||||
# print("IP", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
|
||||||
ip_map[sta_name] = 1
|
|
||||||
if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)):
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
if self.debug:
|
|
||||||
print("sta_list", len(sta_list), sta_list)
|
|
||||||
print("ip_map", len(ip_map), ip_map)
|
|
||||||
print("associated_map", len(associated_map), associated_map)
|
|
||||||
if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)):
|
|
||||||
self._pass("PASS: All stations associated with IP", print_pass)
|
|
||||||
else:
|
|
||||||
self._fail("FAIL: Not all stations able to associate/get IP", print_fail)
|
|
||||||
print("sta_list", sta_list)
|
|
||||||
print("ip_map", ip_map)
|
|
||||||
print("associated_map", associated_map)
|
|
||||||
|
|
||||||
return self.passes()
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
# Bring stations down
|
|
||||||
for sta_name in self.sta_list:
|
|
||||||
data = LFUtils.portDownRequest(1, sta_name)
|
|
||||||
url = "cli-json/set_port"
|
|
||||||
# print(sta_name)
|
|
||||||
self.json_post(url, data)
|
|
||||||
|
|
||||||
def cleanup(self, sta_list):
|
|
||||||
self.station_profile.cleanup(self.resource, sta_list)
|
|
||||||
LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list,
|
|
||||||
debug=self.debug)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
lfjson_host = "localhost"
|
|
||||||
lfjson_port = 8080
|
|
||||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
|
||||||
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wep-48", password="0123456789",
|
|
||||||
security="wep", sta_list=station_list)
|
|
||||||
ip_test.cleanup(station_list)
|
|
||||||
ip_test.timeout = 60
|
|
||||||
ip_test.build()
|
|
||||||
if not ip_test.passes():
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
ip_test.start(station_list, False, False)
|
|
||||||
ip_test.stop()
|
|
||||||
if not ip_test.passes():
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
time.sleep(30)
|
|
||||||
ip_test.cleanup(station_list)
|
|
||||||
if ip_test.passes():
|
|
||||||
print("Full test passed, all stations associated and got IP")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
if sys.version_info[0] != 3:
|
|
||||||
print("This script requires Python 3")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if 'py-json' not in sys.path:
|
|
||||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
|
||||||
import LANforge
|
|
||||||
from LANforge.lfcli_base import LFCliBase
|
|
||||||
from LANforge import LFUtils
|
|
||||||
import realm
|
|
||||||
import time
|
|
||||||
import pprint
|
|
||||||
|
|
||||||
|
|
||||||
class IPv4Test(LFCliBase):
|
|
||||||
def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, number_template="00000", _debug_on=False,
|
|
||||||
_exit_on_error=False,
|
|
||||||
_exit_on_fail=False):
|
|
||||||
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
|
||||||
self.host = host
|
|
||||||
self.port = port
|
|
||||||
self.ssid = ssid
|
|
||||||
self.security = security
|
|
||||||
self.password = password
|
|
||||||
self.sta_list = sta_list
|
|
||||||
self.resource = resource
|
|
||||||
self.timeout = 120
|
|
||||||
self.number_template = number_template
|
|
||||||
self.debug = _debug_on
|
|
||||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
|
||||||
self.station_profile = self.local_realm.new_station_profile()
|
|
||||||
|
|
||||||
self.station_profile.lfclient_url = self.lfclient_url
|
|
||||||
self.station_profile.ssid = self.ssid
|
|
||||||
self.station_profile.ssid_pass = self.password,
|
|
||||||
self.station_profile.security = self.security
|
|
||||||
self.station_profile.number_template_ = self.number_template
|
|
||||||
self.station_profile.mode = 0
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
# Build stations
|
|
||||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
|
||||||
self.station_profile.set_number_template(self.number_template)
|
|
||||||
print("Creating stations")
|
|
||||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
|
||||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
|
||||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
|
||||||
self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
|
|
||||||
self._pass("PASS: Station build finished")
|
|
||||||
|
|
||||||
def start(self, sta_list, print_pass, print_fail):
|
|
||||||
self.station_profile.admin_up(1)
|
|
||||||
associated_map = {}
|
|
||||||
ip_map = {}
|
|
||||||
print("Starting test...")
|
|
||||||
for sec in range(self.timeout):
|
|
||||||
for sta_name in sta_list:
|
|
||||||
sta_status = self.json_get("port/1/1/" + sta_name + "?fields=port,alias,ip,ap", debug_=self.debug)
|
|
||||||
# print(sta_status)
|
|
||||||
if sta_status is None or sta_status['interface'] is None or sta_status['interface']['ap'] is None:
|
|
||||||
continue
|
|
||||||
if len(sta_status['interface']['ap']) == 17 and sta_status['interface']['ap'][-3] == ':':
|
|
||||||
# print("Associated", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
|
||||||
associated_map[sta_name] = 1
|
|
||||||
if sta_status['interface']['ip'] != '0.0.0.0':
|
|
||||||
# print("IP", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
|
||||||
ip_map[sta_name] = 1
|
|
||||||
if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)):
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
if self.debug:
|
|
||||||
print("sta_list", len(sta_list), sta_list)
|
|
||||||
print("ip_map", len(ip_map), ip_map)
|
|
||||||
print("associated_map", len(associated_map), associated_map)
|
|
||||||
if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)):
|
|
||||||
self._pass("PASS: All stations associated with IP", print_pass)
|
|
||||||
else:
|
|
||||||
self._fail("FAIL: Not all stations able to associate/get IP", print_fail)
|
|
||||||
print("sta_list", sta_list)
|
|
||||||
print("ip_map", ip_map)
|
|
||||||
print("associated_map", associated_map)
|
|
||||||
|
|
||||||
return self.passes()
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
# Bring stations down
|
|
||||||
for sta_name in self.sta_list:
|
|
||||||
data = LFUtils.portDownRequest(1, sta_name)
|
|
||||||
url = "cli-json/set_port"
|
|
||||||
# print(sta_name)
|
|
||||||
self.json_post(url, data)
|
|
||||||
|
|
||||||
def cleanup(self, sta_list):
|
|
||||||
self.station_profile.cleanup(self.resource, sta_list)
|
|
||||||
LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list,
|
|
||||||
debug=self.debug)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
lfjson_host = "localhost"
|
|
||||||
lfjson_port = 8080
|
|
||||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
|
||||||
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wpa2-x2048-4-4", password="jedway-wpa2-x2048-4-4",
|
|
||||||
security="wpa2", sta_list=station_list)
|
|
||||||
ip_test.cleanup(station_list)
|
|
||||||
ip_test.timeout = 60
|
|
||||||
ip_test.build()
|
|
||||||
if not ip_test.passes():
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
ip_test.start(station_list, False, False)
|
|
||||||
ip_test.stop()
|
|
||||||
if not ip_test.passes():
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
time.sleep(30)
|
|
||||||
ip_test.cleanup(station_list)
|
|
||||||
if ip_test.passes():
|
|
||||||
print("Full test passed, all stations associated and got IP")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
if sys.version_info[0] != 3:
|
|
||||||
print("This script requires Python 3")
|
|
||||||
exit(1)
|
|
||||||
if 'py-json' not in sys.path:
|
|
||||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
|
||||||
import LANforge
|
|
||||||
from LANforge.lfcli_base import LFCliBase
|
|
||||||
from LANforge import LFUtils
|
|
||||||
import realm
|
|
||||||
import time
|
|
||||||
import pprint
|
|
||||||
|
|
||||||
|
|
||||||
class IPv4Test(LFCliBase):
|
|
||||||
def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, number_template="00000", _debug_on=False,
|
|
||||||
_exit_on_error=False,
|
|
||||||
_exit_on_fail=False):
|
|
||||||
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
|
||||||
self.host = host
|
|
||||||
self.port = port
|
|
||||||
self.ssid = ssid
|
|
||||||
self.security = security
|
|
||||||
self.password = password
|
|
||||||
self.sta_list = sta_list
|
|
||||||
self.resource = resource
|
|
||||||
self.timeout = 120
|
|
||||||
self.number_template = number_template
|
|
||||||
self.debug = _debug_on
|
|
||||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
|
||||||
self.station_profile = self.local_realm.new_station_profile()
|
|
||||||
|
|
||||||
self.station_profile.lfclient_url = self.lfclient_url
|
|
||||||
self.station_profile.ssid = self.ssid
|
|
||||||
self.station_profile.ssid_pass = self.password,
|
|
||||||
self.station_profile.security = self.security
|
|
||||||
self.station_profile.number_template_ = self.number_template
|
|
||||||
self.station_profile.mode = 0
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
# Build stations
|
|
||||||
#print("We've gotten into the build stations function")
|
|
||||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
|
||||||
self.station_profile.set_number_template(self.number_template)
|
|
||||||
print("Creating stations")
|
|
||||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
|
||||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
|
||||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
|
||||||
self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
|
|
||||||
self._pass("PASS: Station build finished")
|
|
||||||
|
|
||||||
def start(self, sta_list, print_pass, print_fail):
|
|
||||||
self.station_profile.admin_up(1)
|
|
||||||
associated_map = {}
|
|
||||||
ip_map = {}
|
|
||||||
print("Starting test...")
|
|
||||||
for sec in range(self.timeout):
|
|
||||||
for sta_name in sta_list:
|
|
||||||
sta_status = self.json_get("port/1/1/" + sta_name + "?fields=port,alias,ip,ap", debug_=self.debug)
|
|
||||||
# print(sta_status)
|
|
||||||
if sta_status is None or sta_status['interface'] is None or sta_status['interface']['ap'] is None:
|
|
||||||
continue
|
|
||||||
if len(sta_status['interface']['ap']) == 17 and sta_status['interface']['ap'][-3] == ':':
|
|
||||||
# print("Associated", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
|
||||||
associated_map[sta_name] = 1
|
|
||||||
if sta_status['interface']['ip'] != '0.0.0.0':
|
|
||||||
# print("IP", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
|
||||||
ip_map[sta_name] = 1
|
|
||||||
if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)):
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
if self.debug:
|
|
||||||
print("sta_list", len(sta_list), sta_list)
|
|
||||||
print("ip_map", len(ip_map), ip_map)
|
|
||||||
print("associated_map", len(associated_map), associated_map)
|
|
||||||
if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)):
|
|
||||||
self._pass("PASS: All stations associated with IP", print_pass)
|
|
||||||
else:
|
|
||||||
self._fail("FAIL: Not all stations able to associate/get IP", print_fail)
|
|
||||||
print("sta_list", sta_list)
|
|
||||||
print("ip_map", ip_map)
|
|
||||||
print("associated_map", associated_map)
|
|
||||||
|
|
||||||
return self.passes()
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
# Bring stations down
|
|
||||||
for sta_name in self.sta_list:
|
|
||||||
data = LFUtils.portDownRequest(1, sta_name)
|
|
||||||
url = "cli-json/set_port"
|
|
||||||
# print(sta_name)
|
|
||||||
self.json_post(url, data)
|
|
||||||
|
|
||||||
def cleanup(self, sta_list):
|
|
||||||
self.station_profile.cleanup(self.resource, sta_list)
|
|
||||||
LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list,
|
|
||||||
debug=self.debug)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
lfjson_host = "localhost"
|
|
||||||
lfjson_port = 8080
|
|
||||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
|
||||||
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wpa3-44", password="jedway-wpa3-44",
|
|
||||||
security="wpa3", sta_list=station_list,_debug_on=False)
|
|
||||||
#print("created IPv4Test object")
|
|
||||||
ip_test.cleanup(station_list)
|
|
||||||
ip_test.timeout = 60
|
|
||||||
ip_test.build()
|
|
||||||
if not ip_test.passes():
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
ip_test.start(station_list, False, False)
|
|
||||||
ip_test.stop()
|
|
||||||
if not ip_test.passes():
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
time.sleep(30)
|
|
||||||
ip_test.cleanup(station_list)
|
|
||||||
if ip_test.passes():
|
|
||||||
print("Full test passed, all stations associated and got IP")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
if sys.version_info[0] != 3:
|
|
||||||
print("This script requires Python 3")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if 'py-json' not in sys.path:
|
|
||||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
|
||||||
import LANforge
|
|
||||||
from LANforge.lfcli_base import LFCliBase
|
|
||||||
from LANforge import LFUtils
|
|
||||||
import realm
|
|
||||||
import time
|
|
||||||
import pprint
|
|
||||||
|
|
||||||
|
|
||||||
class IPv4Test(LFCliBase):
|
|
||||||
def __init__(self, host, port, ssid, security, password, resource=1, sta_list=None, number_template="00000", _debug_on=False,
|
|
||||||
_exit_on_error=False,
|
|
||||||
_exit_on_fail=False):
|
|
||||||
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
|
|
||||||
self.host = host
|
|
||||||
self.port = port
|
|
||||||
self.ssid = ssid
|
|
||||||
self.security = security
|
|
||||||
self.password = password
|
|
||||||
self.sta_list = sta_list
|
|
||||||
self.resource = resource
|
|
||||||
self.timeout = 120
|
|
||||||
self.number_template = number_template
|
|
||||||
self.debug = _debug_on
|
|
||||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
|
||||||
self.station_profile = self.local_realm.new_station_profile()
|
|
||||||
|
|
||||||
self.station_profile.lfclient_url = self.lfclient_url
|
|
||||||
self.station_profile.ssid = self.ssid
|
|
||||||
self.station_profile.ssid_pass = self.password,
|
|
||||||
self.station_profile.security = self.security
|
|
||||||
self.station_profile.number_template_ = self.number_template
|
|
||||||
self.station_profile.mode = 0
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
# Build stations
|
|
||||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
|
||||||
self.station_profile.set_number_template(self.number_template)
|
|
||||||
print("Creating stations")
|
|
||||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
|
||||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
|
||||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
|
||||||
self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
|
|
||||||
self._pass("PASS: Station build finished")
|
|
||||||
|
|
||||||
def start(self, sta_list, print_pass, print_fail):
|
|
||||||
self.station_profile.admin_up(1)
|
|
||||||
associated_map = {}
|
|
||||||
ip_map = {}
|
|
||||||
print("Starting test...")
|
|
||||||
for sec in range(self.timeout):
|
|
||||||
for sta_name in sta_list:
|
|
||||||
sta_status = self.json_get("port/1/1/" + sta_name + "?fields=port,alias,ip,ap", debug_=self.debug)
|
|
||||||
# print(sta_status)
|
|
||||||
if sta_status is None or sta_status['interface'] is None or sta_status['interface']['ap'] is None:
|
|
||||||
continue
|
|
||||||
if len(sta_status['interface']['ap']) == 17 and sta_status['interface']['ap'][-3] == ':':
|
|
||||||
# print("Associated", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
|
||||||
associated_map[sta_name] = 1
|
|
||||||
if sta_status['interface']['ip'] != '0.0.0.0':
|
|
||||||
# print("IP", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
|
||||||
ip_map[sta_name] = 1
|
|
||||||
if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)):
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
if self.debug:
|
|
||||||
print("sta_list", len(sta_list), sta_list)
|
|
||||||
print("ip_map", len(ip_map), ip_map)
|
|
||||||
print("associated_map", len(associated_map), associated_map)
|
|
||||||
if (len(sta_list) == len(ip_map)) and (len(sta_list) == len(associated_map)):
|
|
||||||
self._pass("PASS: All stations associated with IP", print_pass)
|
|
||||||
else:
|
|
||||||
self._fail("FAIL: Not all stations able to associate/get IP", print_fail)
|
|
||||||
print("sta_list", sta_list)
|
|
||||||
print("ip_map", ip_map)
|
|
||||||
print("associated_map", associated_map)
|
|
||||||
|
|
||||||
return self.passes()
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
# Bring stations down
|
|
||||||
for sta_name in self.sta_list:
|
|
||||||
data = LFUtils.portDownRequest(1, sta_name)
|
|
||||||
url = "cli-json/set_port"
|
|
||||||
# print(sta_name)
|
|
||||||
self.json_post(url, data)
|
|
||||||
|
|
||||||
def cleanup(self, sta_list):
|
|
||||||
self.station_profile.cleanup(self.resource, sta_list)
|
|
||||||
LFUtils.wait_until_ports_disappear(resource_id=self.resource, base_url=self.lfclient_url, port_list=sta_list,
|
|
||||||
debug=self.debug)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
lfjson_host = "localhost"
|
|
||||||
lfjson_port = 8080
|
|
||||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=1, padding_number_=10000)
|
|
||||||
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid="jedway-wpa-1", password="jedway-wpa-1",
|
|
||||||
security="wpa", sta_list=station_list)
|
|
||||||
ip_test.cleanup(station_list)
|
|
||||||
ip_test.timeout = 60
|
|
||||||
ip_test.build()
|
|
||||||
if not ip_test.passes():
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
ip_test.start(station_list, False, False)
|
|
||||||
ip_test.stop()
|
|
||||||
if not ip_test.passes():
|
|
||||||
print(ip_test.get_fail_message())
|
|
||||||
exit(1)
|
|
||||||
time.sleep(30)
|
|
||||||
ip_test.cleanup(station_list)
|
|
||||||
if ip_test.passes():
|
|
||||||
print("Full test passed, all stations associated and got IP")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user