example-security-connection: Add exit code logic.

And clean up stations on exit if --noclean was not selected.

Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
Ben Greear
2022-02-01 14:50:08 -08:00
committed by shivam
parent 92f37e3944
commit e0ff9f30a4
2 changed files with 13 additions and 3 deletions

View File

@@ -225,6 +225,7 @@ Command example:
create_vaps.append(create_vap) create_vaps.append(create_vap)
# TODO: Add logic to clean up vap, unless --noclean option is specified. # TODO: Add logic to clean up vap, unless --noclean option is specified.
# TODO: Set radio back to previous channel.
any_failed = False any_failed = False
for v in create_vaps: for v in create_vaps:

View File

@@ -4,15 +4,16 @@ import os
import importlib import importlib
import argparse import argparse
import logging import logging
from time import sleep
logger = logging.getLogger(__name__)
if sys.version_info[0] != 3: if sys.version_info[0] != 3:
print("This script requires Python 3") logger.critical("This script requires Python 3")
exit(1) exit(1)
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../"))) sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
logger = logging.getLogger(__name__)
lf_logger_config = importlib.import_module("py-scripts.lf_logger_config") lf_logger_config = importlib.import_module("py-scripts.lf_logger_config")
LFUtils = importlib.import_module("py-json.LANforge.LFUtils") LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
realm = importlib.import_module("py-json.realm") realm = importlib.import_module("py-json.realm")
@@ -148,6 +149,14 @@ def main():
ip_test.timeout = 60 ip_test.timeout = 60
ip_test.build() ip_test.build()
if not args.noclean:
sleep(5)
ip_test.cleanup(station_list)
if ip_test.passes():
ip_test.exit_success()
else:
ip_test.exit_fail()
if __name__ == "__main__": if __name__ == "__main__":
main() main()