create-cv: Improve --line and --ssid parser.

Use shlex to parse the tokens for each --line and --ssid content.
This fixes using ssid with spaces, for instance.
Fix parser to error out if user inputs invalid data.

Add TODO items for future work.

Fix regression script:  DUT must be created before Scenario tries to use it,
and fix typos and other mistakes in how the regression script tried to
create dut and chamberview.  This part has not been tested yet, but it is
at least closer than before.

Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
Ben Greear
2022-01-31 14:08:47 -08:00
committed by shivam
parent 1cdfbce0e5
commit 7db4c9a329
3 changed files with 36 additions and 16 deletions

View File

@@ -37,6 +37,9 @@ import argparse
import time
import re
from pprint import pprint
import shlex
# TODO: Add logging support.
if sys.version_info[0] != 3:
print("This script requires Python 3")
@@ -102,15 +105,7 @@ class CreateChamberview(cv):
#print("item: ")
#pprint(item)
if " " in item[0]:
item[0] = (re.split(' ', item[0]))
elif "," in item[0]:
item[0] = (re.split(',', item[0]))
else:
print("Wrong arguments entered !")
exit(1)
for sub_item in item[0]:
for sub_item in shlex.split(item[0]):
#print("sub-item: ")
#pprint(sub_item)
@@ -137,6 +132,8 @@ class CreateChamberview(cv):
elif sub_item[0] == "VLAN" or sub_item[0] == "Vlan" or sub_item[0] == "V":
VLAN = sub_item[1]
else:
print("ERROR: Unknown line argument -:%s:-" %(sub_item[0]))
raise ValueError("Un-supported line argument") # Bad user input, terminate script.
continue
self.add_text_blob_line(scenario_name,
@@ -197,6 +194,9 @@ def main():
--raw_line "profile_link 1.1 STA-AC 10 'DUT: temp Radio-1' tcp-dl-6m-vi wiphy0,AUTO -1"
--raw_line "profile_link 1.1 upstream 1 'DUT: temp Radio-1' tcp-dl-6m-vi eth1,AUTO -1"
DUT_Radio is really the last part of the 'maps to' component of the scenario,
so it can also be LAN when using and Upstream profile, for instance.
""")
parser.add_argument(
"-m",
@@ -247,6 +247,14 @@ def main():
raw_line=args.raw_line)
Create_Chamberview.build(args.create_scenario)
# TODO: Build the scenario (cv click the 'Build Scenario' button, wait until build has completed
# TODO: Find and admin up all wlan* and sta* ports,
# TODO: Verify they admin up and get IP address.
if Create_Chamberview.passes():
Create_Chamberview.exit_success()
else:
Create_Chamberview.exit_fail()
if __name__ == "__main__":
main()

View File

@@ -194,9 +194,11 @@ def main():
default="NA",
help="DUT Serial number.")
parser.add_argument("--model_num", default="NA", help="DUT Model Number.")
# TODO: Add example flag options from py-json/LANforge/add_dut.py somehow.
parser.add_argument(
'--dut_flag',
help='station flags to add',
help='DUT flags to add',
default=None,
action='append')

View File

@@ -25,7 +25,7 @@ Help()
HOMEPATH=$(realpath ~)
REPORT_DIR="${HOMEPATH}/html-reports"
while getopts ":h:s:S:p:w:m:r:R:F:B:U:D:H:M:C:e:V:E:" option; do
while getopts ":h:s:S:p:w:m:r:R:F:B:u:U:D:H:M:C:e:V:E:" option; do
case "${option}" in
h) # display Help
Help
@@ -58,7 +58,12 @@ while getopts ":h:s:S:p:w:m:r:R:F:B:U:D:H:M:C:e:V:E:" option; do
B)
BSSID=${OPTARG}
;;
u)
# like eth0
UPSTREAM_BARE=${OPTARG}
;;
U)
# like 1.1.eth0
UPSTREAM=${OPTARG}
;;
D)
@@ -146,8 +151,13 @@ fi
if [[ ${#RADIO2} -eq 0 ]]; then # Allow the user to change the radio they test against
RADIO2="1.1.wiphy0"
fi
if [[ ${#UPSTREAM_BARE} -eq 0 ]]; then
UPSTREAM_BARE="eth1"
fi
if [[ ${#UPSTREAM} -eq 0 ]]; then
UPSTREAM="1.1.eth1"
UPSTREAM=$UPSTREAM_BARE
fi
if [[ ${#BSSID} -eq 0 ]]; then
@@ -220,11 +230,11 @@ function create_station_and_dataplane() {
--local_lf_report_dir ~/html-reports/dataplane_"$NOW"
}
function create_dut_and_chamberview() {
./create_chamberview.py -m $MGR -cs 'regression_test' --delete_scenario \
--line "Resource=$RESOURCE Profile=STA-AC Amount=1 Uses-1=$RADIO_USED Freq=-1 DUT=regression_dut DUT_RADIO=$RADIO_USED Traffic=http" \
--line "Resource=$RESOURCE Profile=upstream Amount=1 Uses-1=$UPSTREAM Uses-2=AUTO Freq=-1 DUT=regression_dut DUT_RADIO=$RADIO_USED Traffic=http"
./create_chamberview_dut.py --lfmgr $MGR --dut_name regression_dut \
--ssid "ssid_idx=0 ssid='$SSID_USED' security='$SECURITY' password='$PASSWD_USED' bssid=$BSSID"
--ssid "ssid_idx=0 ssid='$SSID_USED' security='$SECURITY' password='$PASSWD_USED' bssid=$BSSID"
./create_chamberview.py -m $MGR -cs 'regression_test' --delete_scenario \
--line "Resource=1.$RESOURCE Profile=STA-AC Amount=1 Uses-1=$RADIO_USED Freq=-1 DUT=regression_dut DUT_Radio=$RADIO_USED Traffic=http" \
--line "Resource=1.$RESOURCE Profile=upstream Amount=1 Uses-1=$UPSTREAM_BARE Uses-2=AUTO Freq=-1 DUT=regression_dut DUT_Radio=LAN Traffic=http"
}
function create_station_and_sensitivity {