mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 04:07:52 +00:00
Realm monitor
This commit is contained in:
502
check_large_files.bash
Executable file
502
check_large_files.bash
Executable file
@@ -0,0 +1,502 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
# Check for large files and purge many of the most inconsequencial #
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
# set -x
|
||||||
|
# set -e
|
||||||
|
# these are default selections
|
||||||
|
selections=()
|
||||||
|
deletion_targets=()
|
||||||
|
show_menu=1
|
||||||
|
verbose=0
|
||||||
|
quiet=0
|
||||||
|
|
||||||
|
USAGE="$0 # Check for large files and purge many of the most inconsequencial
|
||||||
|
-a # automatic: disable menu and clean automatically
|
||||||
|
-b # remove extra kernels and modules
|
||||||
|
-c # remove all core files
|
||||||
|
-d # remove old LANforge downloads
|
||||||
|
-h # help
|
||||||
|
-k # remove ath10k crash files
|
||||||
|
-l # remove old files from /var/log, truncate /var/log/messages
|
||||||
|
-m # remove orphaned fileio items in /mnt/lf
|
||||||
|
-q # quiet
|
||||||
|
-r # compress .csv data in /home/lanforge
|
||||||
|
-t # remove /var/tmp files
|
||||||
|
-v # verbose
|
||||||
|
|
||||||
|
"
|
||||||
|
|
||||||
|
eyedee=`id -u`
|
||||||
|
if (( eyedee != 0 )); then
|
||||||
|
echo "$0: Please become root to use this script, bye"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
debug() {
|
||||||
|
if [[ x$verbose = x ]] || (( $verbose < 1 )); then return; fi
|
||||||
|
echo ": $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
note() {
|
||||||
|
if (( $quiet > 0 )); then return; fi
|
||||||
|
echo "# $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function contains () {
|
||||||
|
if [[ x$1 = x ]] || [[ x$2 = x ]]; then
|
||||||
|
echo "contains wants ARRAY and ITEM arguments: if contains name joe; then... }$"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# these two lines below are important to not modify
|
||||||
|
local tmp="${1}[@]"
|
||||||
|
local array=( ${!tmp} )
|
||||||
|
|
||||||
|
# if [[ x$verbose = x1 ]]; then
|
||||||
|
# printf "contains array %s\n" "${array[@]}"
|
||||||
|
# fi
|
||||||
|
if (( ${#array[@]} < 1 )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
local item
|
||||||
|
for item in "${array[@]}"; do
|
||||||
|
# debug "contains testing $2 == $item"
|
||||||
|
[[ "$2" = "$item" ]] && return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#opts=""
|
||||||
|
opts="abcdhklmqrtv"
|
||||||
|
while getopts $opts opt; do
|
||||||
|
case "$opt" in
|
||||||
|
a)
|
||||||
|
verbose=0
|
||||||
|
quiet=1
|
||||||
|
selections+=($opt)
|
||||||
|
show_menu=0
|
||||||
|
;;
|
||||||
|
b)
|
||||||
|
selections+=($opt)
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
selections+=($opt)
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
selections+=($opt)
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
k)
|
||||||
|
selections+=($opt)
|
||||||
|
;;
|
||||||
|
l)
|
||||||
|
selections+=($opt)
|
||||||
|
;;
|
||||||
|
m)
|
||||||
|
selections+=($opt)
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
selections+=($opt)
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
quiet=1
|
||||||
|
verbose=0
|
||||||
|
;;
|
||||||
|
t)
|
||||||
|
selections+=($opt)
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
quiet=0
|
||||||
|
verbose=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unknown option: $opt"
|
||||||
|
echo "$USAGE"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
#if (( ${#selections} < 1 )); then
|
||||||
|
# echo "$USAGE"
|
||||||
|
# exit 0
|
||||||
|
#fi
|
||||||
|
|
||||||
|
HR=" ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----"
|
||||||
|
function hr() {
|
||||||
|
echo "$HR"
|
||||||
|
}
|
||||||
|
|
||||||
|
declare -A totals=(
|
||||||
|
[b]=0
|
||||||
|
[c]=0
|
||||||
|
[d]=0
|
||||||
|
[k]=0
|
||||||
|
[l]=0
|
||||||
|
[m]=0
|
||||||
|
[r]=0
|
||||||
|
[t]=0
|
||||||
|
)
|
||||||
|
declare -A desc=(
|
||||||
|
[b]="kernel files"
|
||||||
|
[c]="core files"
|
||||||
|
[d]="lf downloads"
|
||||||
|
[k]="lf/ath10 files"
|
||||||
|
[l]="/var/log"
|
||||||
|
[m]="/mnt/lf files"
|
||||||
|
[r]="lf/report_data"
|
||||||
|
[t]="/var/tmp"
|
||||||
|
)
|
||||||
|
declare -A surveyors_map=(
|
||||||
|
[b]="survey_kernel_files"
|
||||||
|
[c]="survey_core_files"
|
||||||
|
[d]="survey_lf_downloads"
|
||||||
|
[k]="survey_ath10_files"
|
||||||
|
[l]="survey_var_log"
|
||||||
|
[m]="survey_mnt_lf_files"
|
||||||
|
[r]="survey_report_data"
|
||||||
|
[t]="survey_var_tmp"
|
||||||
|
)
|
||||||
|
|
||||||
|
declare -A cleaners_map=(
|
||||||
|
[b]="clean_old_kernels"
|
||||||
|
[c]="clean_core_files"
|
||||||
|
[d]="clean_lf_downloads"
|
||||||
|
[k]="clean_ath10_files"
|
||||||
|
[l]="clean_var_log"
|
||||||
|
[m]="clean_mnt_lf_files"
|
||||||
|
[r]="compress_report_data"
|
||||||
|
[t]="clean_var_tmp"
|
||||||
|
)
|
||||||
|
|
||||||
|
clean_old_kernels() {
|
||||||
|
note "Cleaning old kernels WIP"
|
||||||
|
local pkg
|
||||||
|
local k_pkgs=()
|
||||||
|
local selected_k=()
|
||||||
|
local k_series=()
|
||||||
|
# need to avoid most recent fedora kernel
|
||||||
|
|
||||||
|
if [ -x /usr/bin/rpm ]; then
|
||||||
|
local kern_pkgs=( $( rpm -qa 'kernel*' | sort ) )
|
||||||
|
local pkg
|
||||||
|
for pkg in "${kern_pkgs[@]}"; do
|
||||||
|
if [[ $pkg = kernel-tools-* ]] \
|
||||||
|
|| [[ $pkg = kernel-headers-* ]] \
|
||||||
|
|| [[ $pkg = kernel-devel-* ]] ; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
k_pkgs+=( $pkg )
|
||||||
|
done
|
||||||
|
for pkg in "${k_pkgs[@]}"; do
|
||||||
|
pkg=${pkg##kernel-modules-extra-}
|
||||||
|
pkg=${pkg##kernel-modules-}
|
||||||
|
pkg=${pkg##kernel-core-}
|
||||||
|
kernel_series=${pkg##kernel-}
|
||||||
|
#debug "K SER: $kernel_series"
|
||||||
|
if contains k_series $kernel_series; then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
k_series+=( $kernel_series )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS=$'\n' k_series=($(sort <<<"${k_series[*]}" | uniq)); unset IFS
|
||||||
|
for pkg in "${k_series[@]}"; do
|
||||||
|
debug "series $pkg"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
set +x
|
||||||
|
if (( ${#selected_k[@]} < 1 )); then
|
||||||
|
note "No kernels selected for removal"
|
||||||
|
fi
|
||||||
|
if (( $quiet < 1 )); then
|
||||||
|
printf "Would remove %s\n" "${selected_k[@]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_core_files() {
|
||||||
|
note "Cleaning core files WIP"
|
||||||
|
if (( $verbose > 0 )); then
|
||||||
|
printf "%s\n" "${core_files[@]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_lf_downloads() {
|
||||||
|
note "Clean LF downloads WIP"
|
||||||
|
if (( $verbose > 0 )); then
|
||||||
|
printf "%s\n" "${lf_downloads[@]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_ath10_files() {
|
||||||
|
note "clean_ath10_files WIP"
|
||||||
|
if (( $verbose > 0 )); then
|
||||||
|
printf "%s\n" "${ath10_files[@]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_var_log() {
|
||||||
|
note "Clean var log WIP"
|
||||||
|
if (( $verbose > 0 )); then
|
||||||
|
printf "%s\n" "${var_log_files[@]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_mnt_fl_files() {
|
||||||
|
note "clean mnt lf files WIP"
|
||||||
|
if (( $verbose > 0 )); then
|
||||||
|
printf "%s\n" "${mnt_lf_files[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
compress_report_data() {
|
||||||
|
note "compress report data WIP"
|
||||||
|
if (( $verbose > 0 )); then
|
||||||
|
printf "%s\n" "${report_data_dirs[@]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_var_tmp() {
|
||||||
|
note "clean var tmp"
|
||||||
|
if (( $verbose > 0 )); then
|
||||||
|
printf "%s\n" "${var_tmp_files[@]}"
|
||||||
|
fi
|
||||||
|
rf -f "${var_tmp_files[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kernel_files=()
|
||||||
|
survey_kernel_files() {
|
||||||
|
debug "Surveying Kernel files"
|
||||||
|
mapfile -t kernel_files < <(ls /boot/* /lib/modules/* 2>/dev/null)
|
||||||
|
totals[b]=$(du -hc "$kernel_files" | awk '/total/{print $1}')
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find core files
|
||||||
|
core_files=()
|
||||||
|
survey_core_files() {
|
||||||
|
debug "Surveying core files"
|
||||||
|
cd /
|
||||||
|
#set -x
|
||||||
|
mapfile -t core_files < <(ls /core* /home/lanforge/core* 2>/dev/null) 2>/dev/null
|
||||||
|
if [[ $verbose = 1 ]]; then
|
||||||
|
printf "%s\n" "${core_files[@]}"
|
||||||
|
fi
|
||||||
|
if (( ${#core_files[@]} > 0 )); then
|
||||||
|
totals[c]=$(du -hc "${core_files[@]}" | awk '/total/{print $1}')
|
||||||
|
fi
|
||||||
|
#set +x
|
||||||
|
[[ x${totals[c]} = x ]] && totals[c]=0
|
||||||
|
}
|
||||||
|
|
||||||
|
# downloads
|
||||||
|
downloads=()
|
||||||
|
survey_lf_downloads() {
|
||||||
|
debug "Surveying /home/lanforge downloads"
|
||||||
|
cd /home/lanforge/Downloads || return 1
|
||||||
|
mapfile -t downloads < <(ls *gz *z2 *-Installer.exe *firmware* kinst_* *Docs* 2>/dev/null)
|
||||||
|
totals[d]=$(du -hc "${downloads[@]}" | awk '/total/{print $1}')
|
||||||
|
[[ x${totals[d]} = x ]] && totals[d]=0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find ath10k crash residue
|
||||||
|
ath10_files=()
|
||||||
|
survey_ath10_files() {
|
||||||
|
debug "Sureyinig ath10 crash files"
|
||||||
|
mapfile -t ath10_files < <(ls /home/lanforge/ath10* 2>/dev/null)
|
||||||
|
totals[k]=$(du -hc "${ath10_files}" 2>/dev/null | awk '/total/{print $1}')
|
||||||
|
[[ x${totals[k]} = x ]] && totals[k]=0
|
||||||
|
}
|
||||||
|
|
||||||
|
# stuff in var log
|
||||||
|
var_log_files=()
|
||||||
|
survey_var_log() {
|
||||||
|
debug "Surveying var log"
|
||||||
|
mapfile -t var_log_files < <(find /var/log -type f -size +10M 2>/dev/null)
|
||||||
|
totals[l]=$(du -hc "${var_log_files}" 2>/dev/null | awk '/total/{print $1}' )
|
||||||
|
[[ x${totals[l]} = x ]] && totals[l]=0
|
||||||
|
}
|
||||||
|
|
||||||
|
# stuff in var tmp
|
||||||
|
var_tmp_files=()
|
||||||
|
survey_var_tmp() {
|
||||||
|
#set -x
|
||||||
|
debug "Surveying var tmp"
|
||||||
|
mapfile -t var_tmp_files < <(find /var/tmp -type f 2>/dev/null)
|
||||||
|
totals[t]=$(du -sh "${var_tmp_files}" 2>/dev/null | awk '/total/{print $1}' )
|
||||||
|
[[ x${totals[t]} = x ]] && totals[t]=0
|
||||||
|
#set +x
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find size of /mnt/lf that is not mounted
|
||||||
|
mnt_lf_files=()
|
||||||
|
survey_mnt_lf_files() {
|
||||||
|
[ ! -d /mnt/lf ] && return 0
|
||||||
|
debug "Surveying mnt lf"
|
||||||
|
mapfile -t mnt_lf_files < <(find /mnt/lf -type f --one_filesystem 2>/dev/null)
|
||||||
|
totals[m]=$(du -xhc "${mnt_lf_files[@]}" 2>/dev/null | awk '/total/{print $1}')
|
||||||
|
[[ x${totals[m]} = x ]] && totals[m]=0
|
||||||
|
}
|
||||||
|
|
||||||
|
## Find size of /lib/modules
|
||||||
|
# cd /lib/modules
|
||||||
|
# mapfile -t usage_libmod < <(du -sh *)
|
||||||
|
|
||||||
|
# Find how many kernels are installed
|
||||||
|
# cd /boot
|
||||||
|
# mapfile -t boot_kernels < <(ls init*)
|
||||||
|
# boot_usage=`du -sh .`
|
||||||
|
|
||||||
|
report_files=()
|
||||||
|
survey_report_data() {
|
||||||
|
debug "Surveying for lanforge report data"
|
||||||
|
cd /home/lanforge
|
||||||
|
#set -x
|
||||||
|
local fnum=$( find -type f -name '*.csv' 2>/dev/null | wc -l )
|
||||||
|
local fsiz=$( find -type f -name '*.csv' 2>/dev/null | xargs du -hc | awk '/total/{print $1}')
|
||||||
|
totals[r]="$fsiz"
|
||||||
|
[[ x${totals[r]} = x ]] && totals[r]=0
|
||||||
|
report_files=("CSV files: $fnum tt $fsiz")
|
||||||
|
#set +x
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
# gather usage areas
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
survey_areas() {
|
||||||
|
local area
|
||||||
|
note "Surveying..."
|
||||||
|
for area in "${!surveyors_map[@]}"; do
|
||||||
|
if (( $quiet < 1 )) && (( $verbose < 1 )); then
|
||||||
|
note -n "#"
|
||||||
|
fi
|
||||||
|
${surveyors_map[$area]}
|
||||||
|
done
|
||||||
|
if (( $quiet < 1 )) && (( $verbose < 1 )); then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
# report sizes here #
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
disk_usage_report() {
|
||||||
|
for k in "${!totals[@]}"; do
|
||||||
|
echo -e "\t${desc[$k]}:\t${totals[$k]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
survey_areas
|
||||||
|
disk_usage_report
|
||||||
|
|
||||||
|
if (( ${#core_files[@]} > 0 )); then
|
||||||
|
note "Core Files detected:"
|
||||||
|
hr
|
||||||
|
#printf ' %s\n' "${core_files[@]}"
|
||||||
|
for core in "${core_files[@]}"; do
|
||||||
|
file $core
|
||||||
|
done
|
||||||
|
hr
|
||||||
|
selections+=("c")
|
||||||
|
fi
|
||||||
|
|
||||||
|
#echo "Usage of /mnt: $usage_mnt"
|
||||||
|
#echo "Usage of /lib/modules: $usage_libmod"
|
||||||
|
#echo "Boot usage: $boot_usage"
|
||||||
|
|
||||||
|
#if (( ${#boot_kernels[@]} > 1 )); then
|
||||||
|
# echo "Boot ramdisks:"
|
||||||
|
# hr
|
||||||
|
# printf ' %s\n' "${boot_kernels[@]}"
|
||||||
|
# hr
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
# delete extra things now #
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
#set -x
|
||||||
|
if contains "selections" "a" ; then
|
||||||
|
note "Automatic deletion will include: "
|
||||||
|
printf "%s\n" "${selections[@]}"
|
||||||
|
debug "Doing automatic cleanup"
|
||||||
|
for z in "${selections[@]}"; do
|
||||||
|
debug "Will perform ${desc[$z]}"
|
||||||
|
${cleaners_map[$z]}
|
||||||
|
done
|
||||||
|
survey_areas
|
||||||
|
disk_usage_report
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( ${#selections[@]} > 0 )) ; then
|
||||||
|
debug "Doing selected cleanup"
|
||||||
|
for z in "${selections[@]}"; do
|
||||||
|
debug "Will perform ${desc[$z]}"
|
||||||
|
${cleaners_map[$z]}
|
||||||
|
selections=("${selections[@]/$z}")
|
||||||
|
done
|
||||||
|
survey_areas
|
||||||
|
disk_usage_report
|
||||||
|
fi
|
||||||
|
set +x
|
||||||
|
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
# ask for things to remove if we are interactive #
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- #
|
||||||
|
choice=""
|
||||||
|
while [[ $choice != q ]]; do
|
||||||
|
hr
|
||||||
|
#abcdhklmqrtv
|
||||||
|
echo "Would you like to delete? "
|
||||||
|
echo " b) old kernels ${totals[b]}"
|
||||||
|
echo " c) core crash files ${totals[c]}"
|
||||||
|
echo " d) old LANforge downloads ${totals[d]}"
|
||||||
|
echo " k) ath10k crash files ${totals[k]}"
|
||||||
|
echo " l) old /var/log files ${totals[l]}"
|
||||||
|
echo " m) orphaned /mnt/lf files ${totals[m]}"
|
||||||
|
echo " r) compress .csv report files ${totals[r]}"
|
||||||
|
echo " t) clean /var/tmp ${totals[t]}"
|
||||||
|
read -p "[1-5] or q ? " choice
|
||||||
|
|
||||||
|
case "$choice" in
|
||||||
|
b )
|
||||||
|
clean_old_kernels
|
||||||
|
;;
|
||||||
|
c )
|
||||||
|
clean_core_files
|
||||||
|
;;
|
||||||
|
d )
|
||||||
|
clean_lf_downloads
|
||||||
|
;;
|
||||||
|
k )
|
||||||
|
clean_ath10_files
|
||||||
|
;;
|
||||||
|
l )
|
||||||
|
clean_var_log
|
||||||
|
;;
|
||||||
|
m )
|
||||||
|
clean_mnt_lf_files
|
||||||
|
;;
|
||||||
|
r )
|
||||||
|
compress_report_data
|
||||||
|
;;
|
||||||
|
t )
|
||||||
|
clean_var_tmp
|
||||||
|
;;
|
||||||
|
q )
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo "not an option [$choice]"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
survey_areas
|
||||||
|
disk_usage_report
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
echo bye
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -x
|
|
||||||
set -e
|
|
||||||
eyedee=`id -u`
|
|
||||||
if (( eyedee != 0 )); then
|
|
||||||
echo "Please become root to use this script"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Find core files
|
|
||||||
core_files=()
|
|
||||||
cd /
|
|
||||||
while read F; do
|
|
||||||
core_files+=("$F")
|
|
||||||
done < <(ls /core* /home/lanforge/core* 2>/dev/null)
|
|
||||||
|
|
||||||
|
|
||||||
# Find ath10k crash residue
|
|
||||||
ath10_files=()
|
|
||||||
while read F; do
|
|
||||||
ath10_files+=("$F")
|
|
||||||
done < <(ls /home/lanforge/ath10* 2>/dev/null)
|
|
||||||
|
|
||||||
# Find size of /mnt/lf that is not mounted
|
|
||||||
cd /mnt
|
|
||||||
usage_mnt=`du -shxc .`
|
|
||||||
|
|
||||||
# Find size of /lib/modules
|
|
||||||
cd /lib/modules
|
|
||||||
usage_libmod=`du -sh *`
|
|
||||||
|
|
||||||
# Find how many kernels are installed
|
|
||||||
cd /boot
|
|
||||||
boot_kernels=(`ls init*`)
|
|
||||||
boot_usage=`du -sh .`
|
|
||||||
|
|
||||||
HR="---------------------------------------"
|
|
||||||
# #
|
|
||||||
# report sizes here #
|
|
||||||
# #
|
|
||||||
if (( ${#core_files[@]} > 0 )); then
|
|
||||||
echo "Core Files:"
|
|
||||||
echo "$HR"
|
|
||||||
printf '%s\n' "${core_files[@]}"
|
|
||||||
echo "$HR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Usage of /mnt: $usage_mnt"
|
|
||||||
echo "Usage of /lib/modules: $usage_libmod"
|
|
||||||
echo "Boot usage: $boot_usage"
|
|
||||||
|
|
||||||
if (( ${#boot_kernels[@]} > 4 )); then
|
|
||||||
echo "Boot ramdisks:"
|
|
||||||
echo "$HR"
|
|
||||||
printf '%s\n' "${boot_kernels[@]}"
|
|
||||||
echo "$HR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# delete extra things now #
|
|
||||||
|
|
||||||
# remove
|
|
||||||
11
lf_icemod.pl
11
lf_icemod.pl
@@ -163,19 +163,10 @@ $t->waitfor("/btbits\>\>/");
|
|||||||
my $dt = "";
|
my $dt = "";
|
||||||
|
|
||||||
my $utils = new LANforge::Utils();
|
my $utils = new LANforge::Utils();
|
||||||
$utils->telnet($t);
|
$utils->connect($lfmgr_host, $lfmgr_port);
|
||||||
$utils->cli_send_silent(0); # Show input to CLI
|
|
||||||
if ($quiet & 0x1) {
|
|
||||||
$utils->cli_rcv_silent(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$utils->cli_rcv_silent(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
# $utils->doCmd("log_level 63");
|
|
||||||
my $cmd;
|
my $cmd;
|
||||||
|
|
||||||
|
|
||||||
$speed = "NA" if ($speed eq "");
|
$speed = "NA" if ($speed eq "");
|
||||||
$latency = "NA" if ($latency eq "");
|
$latency = "NA" if ($latency eq "");
|
||||||
$max_jitter = "NA" if ($max_jitter eq "");
|
$max_jitter = "NA" if ($max_jitter eq "");
|
||||||
|
|||||||
@@ -8,9 +8,12 @@ if sys.version_info[0] != 3:
|
|||||||
exit()
|
exit()
|
||||||
|
|
||||||
import pprint
|
import pprint
|
||||||
import urllib.request
|
import urllib
|
||||||
import urllib.error
|
import time
|
||||||
import urllib.parse
|
from urllib import request
|
||||||
|
from urllib import error
|
||||||
|
from urllib import parse
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from LANforge import LFUtils
|
from LANforge import LFUtils
|
||||||
|
|
||||||
@@ -33,11 +36,27 @@ class LFRequest:
|
|||||||
|
|
||||||
# please see this discussion on ProxyHandlers:
|
# please see this discussion on ProxyHandlers:
|
||||||
# https://docs.python.org/3/library/urllib.request.html#urllib.request.ProxyHandler
|
# https://docs.python.org/3/library/urllib.request.html#urllib.request.ProxyHandler
|
||||||
if proxies_ is not None:
|
# but this makes much more sense:
|
||||||
# check to see if proxy has some fields
|
# https://gist.github.com/aleiphoenix/4159510
|
||||||
if ("host" not in proxies_) or ("user" not in proxies_):
|
|
||||||
raise ValueError("HTTP proxy requires, host, user, pass values.")
|
# if debug_:
|
||||||
self.proxies = proxies_;
|
# if proxies_ is None:
|
||||||
|
# print("LFRequest_init_: no proxies_")
|
||||||
|
# else:
|
||||||
|
# print("LFRequest: proxies_: ")
|
||||||
|
# pprint.pprint(proxies_)
|
||||||
|
|
||||||
|
if (proxies_ is not None) and (len(proxies_) > 0):
|
||||||
|
if ("http" not in proxies_) and ("https" not in proxies_):
|
||||||
|
raise ValueError("Neither http or https set in proxy definitions. Expects proxy={'http':, 'https':, }")
|
||||||
|
self.proxies = proxies_
|
||||||
|
|
||||||
|
# if debug_:
|
||||||
|
# if self.proxies is None:
|
||||||
|
# print("LFRequest_init_: no proxies")
|
||||||
|
# else:
|
||||||
|
# print("LFRequest: proxies: ")
|
||||||
|
# pprint.pprint(self.proxies)
|
||||||
|
|
||||||
if not url.startswith("http://") and not url.startswith("https://"):
|
if not url.startswith("http://") and not url.startswith("https://"):
|
||||||
print("No http:// or https:// found, prepending http:// to "+url)
|
print("No http:// or https:// found, prepending http:// to "+url)
|
||||||
@@ -50,7 +69,7 @@ class LFRequest:
|
|||||||
self.requested_url = url
|
self.requested_url = url
|
||||||
|
|
||||||
if self.requested_url is None:
|
if self.requested_url is None:
|
||||||
raise Exception("Bad LFRequest of url[%s] uri[%s] -> None" % url, uri)
|
raise Exception("Bad LFRequest of url[%s] uri[%s] -> None" % (url, uri))
|
||||||
|
|
||||||
if self.requested_url.find('//'):
|
if self.requested_url.find('//'):
|
||||||
protopos = self.requested_url.find("://")
|
protopos = self.requested_url.find("://")
|
||||||
@@ -65,14 +84,6 @@ class LFRequest:
|
|||||||
if self.debug:
|
if self.debug:
|
||||||
print("new LFRequest[%s]" % self.requested_url )
|
print("new LFRequest[%s]" % self.requested_url )
|
||||||
|
|
||||||
def update_proxies(self, request):
|
|
||||||
if (request is None) or (self.proxies is None):
|
|
||||||
return
|
|
||||||
|
|
||||||
for (proto, host) in self.proxies.items():
|
|
||||||
request.set_proxy(host, proto)
|
|
||||||
|
|
||||||
|
|
||||||
# request first url on stack
|
# request first url on stack
|
||||||
def formPost(self, show_error=True, debug=False, die_on_error_=False):
|
def formPost(self, show_error=True, debug=False, die_on_error_=False):
|
||||||
return self.form_post(show_error=show_error, debug=debug, die_on_error_=die_on_error_)
|
return self.form_post(show_error=show_error, debug=debug, die_on_error_=die_on_error_)
|
||||||
@@ -84,6 +95,13 @@ class LFRequest:
|
|||||||
debug = True
|
debug = True
|
||||||
responses = []
|
responses = []
|
||||||
urlenc_data = ""
|
urlenc_data = ""
|
||||||
|
# https://stackoverflow.com/a/59635684/11014343
|
||||||
|
if (self.proxies is not None) and (len(self.proxies) > 0):
|
||||||
|
# https://stackoverflow.com/a/59635684/11014343
|
||||||
|
opener = request.build_opener(request.ProxyHandler(self.proxies))
|
||||||
|
request.install_opener(opener)
|
||||||
|
|
||||||
|
|
||||||
if (debug):
|
if (debug):
|
||||||
print("formPost: url: "+self.requested_url)
|
print("formPost: url: "+self.requested_url)
|
||||||
if ((self.post_data != None) and (self.post_data is not self.No_Data)):
|
if ((self.post_data != None) and (self.post_data is not self.No_Data)):
|
||||||
@@ -91,32 +109,31 @@ class LFRequest:
|
|||||||
if (debug):
|
if (debug):
|
||||||
print("formPost: data looks like:" + str(urlenc_data))
|
print("formPost: data looks like:" + str(urlenc_data))
|
||||||
print("formPost: url: "+self.requested_url)
|
print("formPost: url: "+self.requested_url)
|
||||||
request = urllib.request.Request(url=self.requested_url,
|
myrequest = request.Request(url=self.requested_url,
|
||||||
data=urlenc_data,
|
data=urlenc_data,
|
||||||
headers=self.default_headers)
|
headers=self.default_headers)
|
||||||
else:
|
else:
|
||||||
request = urllib.request.Request(url=self.requested_url, headers=self.default_headers)
|
myrequest = request.Request(url=self.requested_url, headers=self.default_headers)
|
||||||
print("No data for this formPost?")
|
print("No data for this formPost?")
|
||||||
|
|
||||||
self.update_proxies(request)
|
myrequest.headers['Content-type'] = 'application/x-www-form-urlencoded'
|
||||||
|
|
||||||
request.headers['Content-type'] = 'application/x-www-form-urlencoded'
|
|
||||||
resp = ''
|
resp = ''
|
||||||
try:
|
try:
|
||||||
resp = urllib.request.urlopen(request)
|
resp = urllib.request.urlopen(myrequest)
|
||||||
responses.append(resp)
|
responses.append(resp)
|
||||||
return responses[0]
|
return responses[0]
|
||||||
except urllib.error.HTTPError as error:
|
except urllib.error.HTTPError as error:
|
||||||
if (show_error):
|
if (show_error):
|
||||||
print("----- LFRequest::formPost:76 HTTPError: --------------------------------------------")
|
print("----- LFRequest::formPost:76 HTTPError: --------------------------------------------")
|
||||||
print("%s: %s; URL: %s"%(error.code, error.reason, request.get_full_url()))
|
print("%s: %s; URL: %s"%(error.code, error.reason, myrequest.get_full_url()))
|
||||||
LFUtils.debug_printer.pprint(error.headers)
|
LFUtils.debug_printer.pprint(error.headers)
|
||||||
#print("Error: ", sys.exc_info()[0])
|
#print("Error: ", sys.exc_info()[0])
|
||||||
#print("Request URL:", request.get_full_url())
|
#print("Request URL:", request.get_full_url())
|
||||||
print("Request Content-type:", request.get_header('Content-type'))
|
print("Request Content-type:", myrequest.get_header('Content-type'))
|
||||||
print("Request Accept:", request.get_header('Accept'))
|
print("Request Accept:", myrequest.get_header('Accept'))
|
||||||
print("Request Data:")
|
print("Request Data:")
|
||||||
LFUtils.debug_printer.pprint(request.data)
|
LFUtils.debug_printer.pprint(myrequest.data)
|
||||||
if (len(responses) > 0):
|
if (len(responses) > 0):
|
||||||
print("----- Response: --------------------------------------------------------")
|
print("----- Response: --------------------------------------------------------")
|
||||||
LFUtils.debug_printer.pprint(responses[0].reason)
|
LFUtils.debug_printer.pprint(responses[0].reason)
|
||||||
@@ -127,7 +144,7 @@ class LFRequest:
|
|||||||
except urllib.error.URLError as uerror:
|
except urllib.error.URLError as uerror:
|
||||||
if show_error:
|
if show_error:
|
||||||
print("----- LFRequest::formPost:94 URLError: ---------------------------------------------")
|
print("----- LFRequest::formPost:94 URLError: ---------------------------------------------")
|
||||||
print("Reason: %s; URL: %s"%(uerror.reason, request.get_full_url()))
|
print("Reason: %s; URL: %s"%(uerror.reason, myrequest.get_full_url()))
|
||||||
print("------------------------------------------------------------------------")
|
print("------------------------------------------------------------------------")
|
||||||
if (die_on_error_ == True) or (self.die_on_error == True):
|
if (die_on_error_ == True) or (self.die_on_error == True):
|
||||||
exit(1)
|
exit(1)
|
||||||
@@ -142,18 +159,25 @@ class LFRequest:
|
|||||||
if self.die_on_error:
|
if self.die_on_error:
|
||||||
die_on_error_ = True
|
die_on_error_ = True
|
||||||
responses = []
|
responses = []
|
||||||
|
if (self.proxies is not None) and (len(self.proxies) > 0):
|
||||||
|
opener = request.build_opener(request.ProxyHandler(self.proxies))
|
||||||
|
request.install_opener(opener)
|
||||||
|
|
||||||
if ((self.post_data != None) and (self.post_data is not self.No_Data)):
|
if ((self.post_data != None) and (self.post_data is not self.No_Data)):
|
||||||
request = urllib.request.Request(url=self.requested_url,
|
myrequest = request.Request(url=self.requested_url,
|
||||||
method=method_,
|
method=method_,
|
||||||
data=json.dumps(self.post_data).encode("utf-8"),
|
data=json.dumps(self.post_data).encode("utf-8"),
|
||||||
headers=self.default_headers)
|
headers=self.default_headers)
|
||||||
else:
|
else:
|
||||||
request = urllib.request.Request(url=self.requested_url, headers=self.default_headers)
|
myrequest = request.Request(url=self.requested_url, headers=self.default_headers)
|
||||||
print("No data for this jsonPost?")
|
print("No data for this jsonPost?")
|
||||||
|
|
||||||
request.headers['Content-type'] = 'application/json'
|
myrequest.headers['Content-type'] = 'application/json'
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/59635684/11014343
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = urllib.request.urlopen(request)
|
resp = request.urlopen(myrequest)
|
||||||
resp_data = resp.read().decode('utf-8')
|
resp_data = resp.read().decode('utf-8')
|
||||||
if (debug):
|
if (debug):
|
||||||
print("----- LFRequest::json_post:128 debug: --------------------------------------------")
|
print("----- LFRequest::json_post:128 debug: --------------------------------------------")
|
||||||
@@ -176,14 +200,14 @@ class LFRequest:
|
|||||||
except urllib.error.HTTPError as error:
|
except urllib.error.HTTPError as error:
|
||||||
if show_error or die_on_error_ or (error.code != 404):
|
if show_error or die_on_error_ or (error.code != 404):
|
||||||
print("----- LFRequest::json_post:147 HTTPError: --------------------------------------------")
|
print("----- LFRequest::json_post:147 HTTPError: --------------------------------------------")
|
||||||
print("<%s> HTTP %s: %s" % (request.get_full_url(), error.code, error.reason ))
|
print("<%s> HTTP %s: %s" % (myrequest.get_full_url(), error.code, error.reason ))
|
||||||
|
|
||||||
print("Error: ", sys.exc_info()[0])
|
print("Error: ", sys.exc_info()[0])
|
||||||
print("Request URL:", request.get_full_url())
|
print("Request URL:", myrequest.get_full_url())
|
||||||
print("Request Content-type:", request.get_header('Content-type'))
|
print("Request Content-type:", myrequest.get_header('Content-type'))
|
||||||
print("Request Accept:", request.get_header('Accept'))
|
print("Request Accept:", myrequest.get_header('Accept'))
|
||||||
print("Request Data:")
|
print("Request Data:")
|
||||||
LFUtils.debug_printer.pprint(request.data)
|
LFUtils.debug_printer.pprint(myrequest.data)
|
||||||
|
|
||||||
if error.headers:
|
if error.headers:
|
||||||
# the HTTPError is of type HTTPMessage a subclass of email.message
|
# the HTTPError is of type HTTPMessage a subclass of email.message
|
||||||
@@ -200,7 +224,7 @@ class LFRequest:
|
|||||||
except urllib.error.URLError as uerror:
|
except urllib.error.URLError as uerror:
|
||||||
if show_error:
|
if show_error:
|
||||||
print("----- LFRequest::json_post:171 URLError: ---------------------------------------------")
|
print("----- LFRequest::json_post:171 URLError: ---------------------------------------------")
|
||||||
print("Reason: %s; URL: %s"%(uerror.reason, request.get_full_url()))
|
print("Reason: %s; URL: %s"%(uerror.reason, myrequest.get_full_url()))
|
||||||
print("------------------------------------------------------------------------")
|
print("------------------------------------------------------------------------")
|
||||||
if (die_on_error_ == True) or (self.die_on_error == True):
|
if (die_on_error_ == True) or (self.die_on_error == True):
|
||||||
exit(1)
|
exit(1)
|
||||||
@@ -225,13 +249,21 @@ class LFRequest:
|
|||||||
die_on_error_ = True
|
die_on_error_ = True
|
||||||
if debug:
|
if debug:
|
||||||
print("LFUtils.get: url: "+self.requested_url)
|
print("LFUtils.get: url: "+self.requested_url)
|
||||||
myrequest = urllib.request.Request(url=self.requested_url,
|
|
||||||
|
# https://stackoverflow.com/a/59635684/11014343
|
||||||
|
if (self.proxies is not None) and (len(self.proxies) > 0):
|
||||||
|
opener = request.build_opener(request.ProxyHandler(self.proxies))
|
||||||
|
#opener = urllib.request.build_opener(myrequest.ProxyHandler(self.proxies))
|
||||||
|
request.install_opener(opener)
|
||||||
|
|
||||||
|
myrequest = request.Request(url=self.requested_url,
|
||||||
headers=self.default_headers,
|
headers=self.default_headers,
|
||||||
method=method_)
|
method=method_)
|
||||||
self.update_proxies(myrequest)
|
|
||||||
|
|
||||||
myresponses = []
|
myresponses = []
|
||||||
try:
|
try:
|
||||||
myresponses.append(urllib.request.urlopen(myrequest))
|
myresponses.append(request.urlopen(myrequest))
|
||||||
return myresponses[0]
|
return myresponses[0]
|
||||||
except urllib.error.HTTPError as error:
|
except urllib.error.HTTPError as error:
|
||||||
if debug:
|
if debug:
|
||||||
@@ -290,12 +322,25 @@ class LFRequest:
|
|||||||
self.post_data = data
|
self.post_data = data
|
||||||
|
|
||||||
|
|
||||||
def plain_get(url_=None, debug_=False, die_on_error_=False):
|
def plain_get(url_=None, debug_=False, die_on_error_=False, proxies_=None):
|
||||||
myrequest = urllib.request.Request(url=url_)
|
"""
|
||||||
|
This static method does not respect LFRequest.proxy, it is not set in scope here
|
||||||
|
:param url_:
|
||||||
|
:param debug_:
|
||||||
|
:param die_on_error_:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
myrequest = request.Request(url=url_)
|
||||||
myresponses = []
|
myresponses = []
|
||||||
try:
|
try:
|
||||||
myresponses.append(urllib.request.urlopen(myrequest))
|
if (proxies_ is not None) and (len(proxies_) > 0):
|
||||||
|
# https://stackoverflow.com/a/59635684/11014343
|
||||||
|
opener = myrequest.build_opener(myrequest.ProxyHandler(proxies_))
|
||||||
|
myrequest.install_opener(opener)
|
||||||
|
|
||||||
|
myresponses.append(request.urlopen(myrequest))
|
||||||
return myresponses[0]
|
return myresponses[0]
|
||||||
|
|
||||||
except urllib.error.HTTPError as error:
|
except urllib.error.HTTPError as error:
|
||||||
if debug_:
|
if debug_:
|
||||||
print("----- LFRequest::get:181 HTTPError: --------------------------------------------")
|
print("----- LFRequest::get:181 HTTPError: --------------------------------------------")
|
||||||
|
|||||||
@@ -445,7 +445,10 @@ def waitUntilPortsDisappear(base_url="http://localhost:8080", port_list=[], debu
|
|||||||
def wait_until_ports_disappear(base_url="http://localhost:8080", port_list=[], debug=False):
|
def wait_until_ports_disappear(base_url="http://localhost:8080", port_list=[], debug=False):
|
||||||
print("Waiting until ports disappear...")
|
print("Waiting until ports disappear...")
|
||||||
url = "/port/1"
|
url = "/port/1"
|
||||||
|
if isinstance(port_list, list):
|
||||||
found_stations = port_list.copy()
|
found_stations = port_list.copy()
|
||||||
|
else:
|
||||||
|
found_stations = [port_list]
|
||||||
|
|
||||||
while len(found_stations) > 0:
|
while len(found_stations) > 0:
|
||||||
found_stations = []
|
found_stations = []
|
||||||
@@ -459,7 +462,7 @@ def wait_until_ports_disappear(base_url="http://localhost:8080", port_list=[], d
|
|||||||
if debug:
|
if debug:
|
||||||
print("checking:" + check_url)
|
print("checking:" + check_url)
|
||||||
lf_r = LFRequest.LFRequest(base_url, check_url)
|
lf_r = LFRequest.LFRequest(base_url, check_url)
|
||||||
json_response = lf_r.getAsJson(debug_=debug)
|
json_response = lf_r.get_as_json(debug_=debug)
|
||||||
if (json_response != None):
|
if (json_response != None):
|
||||||
found_stations.append(port_name)
|
found_stations.append(port_name)
|
||||||
if len(found_stations) > 0:
|
if len(found_stations) > 0:
|
||||||
|
|||||||
@@ -27,15 +27,23 @@ class LFCliBase:
|
|||||||
_exit_on_error=False,
|
_exit_on_error=False,
|
||||||
_exit_on_fail=False,
|
_exit_on_fail=False,
|
||||||
_local_realm=None,
|
_local_realm=None,
|
||||||
|
_proxy_str=None,
|
||||||
_capture_signal_list=[]):
|
_capture_signal_list=[]):
|
||||||
self.fail_pref = "FAILED: "
|
self.fail_pref = "FAILED: "
|
||||||
self.pass_pref = "PASSED: "
|
self.pass_pref = "PASSED: "
|
||||||
self.lfclient_host = _lfjson_host
|
self.lfclient_host = _lfjson_host
|
||||||
self.lfclient_port = _lfjson_port
|
self.lfclient_port = _lfjson_port
|
||||||
self.debug = _debug
|
self.debug = _debug
|
||||||
|
# if (_debug):
|
||||||
|
# print("LFCliBase._proxy_str: %s" % _proxy_str)
|
||||||
|
self.proxy = {}
|
||||||
|
self.adjust_proxy(_proxy_str)
|
||||||
|
|
||||||
if (_local_realm is not None):
|
if (_local_realm is not None):
|
||||||
self.local_realm = _local_realm
|
self.local_realm = _local_realm
|
||||||
|
|
||||||
|
# if (_debug):
|
||||||
|
# print("LFCliBase._proxy_str: %s" % _proxy_str)
|
||||||
self.lfclient_url = "http://%s:%s" % (self.lfclient_host, self.lfclient_port)
|
self.lfclient_url = "http://%s:%s" % (self.lfclient_host, self.lfclient_port)
|
||||||
self.test_results = []
|
self.test_results = []
|
||||||
self.halt_on_error = _halt_on_error
|
self.halt_on_error = _halt_on_error
|
||||||
@@ -145,7 +153,6 @@ class LFCliBase:
|
|||||||
if self.debug:
|
if self.debug:
|
||||||
print("subclass ignored signal")
|
print("subclass ignored signal")
|
||||||
|
|
||||||
|
|
||||||
def clear_test_results(self):
|
def clear_test_results(self):
|
||||||
self.test_results.clear()
|
self.test_results.clear()
|
||||||
|
|
||||||
@@ -160,8 +167,13 @@ class LFCliBase:
|
|||||||
:return: http response object
|
:return: http response object
|
||||||
"""
|
"""
|
||||||
json_response = None
|
json_response = None
|
||||||
|
debug_ |= self.debug
|
||||||
try:
|
try:
|
||||||
lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url, debug_=self.debug, die_on_error_=self.exit_on_error)
|
lf_r = LFRequest.LFRequest(url=self.lfclient_url,
|
||||||
|
uri=_req_url,
|
||||||
|
proxies_=self.proxy,
|
||||||
|
debug_=debug_,
|
||||||
|
die_on_error_=self.exit_on_error)
|
||||||
if suppress_related_commands_ is None:
|
if suppress_related_commands_ is None:
|
||||||
if 'suppress_preexec_cli' in _data:
|
if 'suppress_preexec_cli' in _data:
|
||||||
del _data['suppress_preexec_cli']
|
del _data['suppress_preexec_cli']
|
||||||
@@ -183,16 +195,16 @@ class LFCliBase:
|
|||||||
_data['suppress_postexec_method'] = True
|
_data['suppress_postexec_method'] = True
|
||||||
|
|
||||||
lf_r.addPostData(_data)
|
lf_r.addPostData(_data)
|
||||||
if debug_ or self.debug:
|
if debug_:
|
||||||
LANforge.LFUtils.debug_printer.pprint(_data)
|
LANforge.LFUtils.debug_printer.pprint(_data)
|
||||||
json_response = lf_r.jsonPost(show_error=self.debug,
|
json_response = lf_r.json_post(show_error=debug_,
|
||||||
debug=(self.debug or debug_),
|
debug=debug_,
|
||||||
response_json_list_=response_json_list_,
|
response_json_list_=response_json_list_,
|
||||||
die_on_error_=self.exit_on_error)
|
die_on_error_=self.exit_on_error)
|
||||||
if debug_ and (response_json_list_ is not None):
|
if debug_ and (response_json_list_ is not None):
|
||||||
pprint.pprint(response_json_list_)
|
pprint.pprint(response_json_list_)
|
||||||
except Exception as x:
|
except Exception as x:
|
||||||
if self.debug or self.halt_on_error or self.exit_on_error:
|
if debug_ or self.halt_on_error or self.exit_on_error:
|
||||||
print("json_post posted to %s" % _req_url)
|
print("json_post posted to %s" % _req_url)
|
||||||
pprint.pprint(_data)
|
pprint.pprint(_data)
|
||||||
print("Exception %s:" % x)
|
print("Exception %s:" % x)
|
||||||
@@ -212,20 +224,25 @@ class LFCliBase:
|
|||||||
:param response_json_list_: array for json results in the response object, (alternative return method)
|
:param response_json_list_: array for json results in the response object, (alternative return method)
|
||||||
:return: http response object
|
:return: http response object
|
||||||
"""
|
"""
|
||||||
|
debug_ |= self.debug
|
||||||
json_response = None
|
json_response = None
|
||||||
try:
|
try:
|
||||||
lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url, debug_=self.debug, die_on_error_=self.exit_on_error)
|
lf_r = LFRequest.LFRequest(url=self.lfclient_url,
|
||||||
|
uri=_req_url,
|
||||||
|
proxies_=self.proxy,
|
||||||
|
debug_=debug_,
|
||||||
|
die_on_error_=self.exit_on_error)
|
||||||
lf_r.addPostData(_data)
|
lf_r.addPostData(_data)
|
||||||
if debug_ or self.debug:
|
if debug_:
|
||||||
LANforge.LFUtils.debug_printer.pprint(_data)
|
LANforge.LFUtils.debug_printer.pprint(_data)
|
||||||
json_response = lf_r.json_put(show_error=self.debug,
|
json_response = lf_r.json_put(show_error=self.debug,
|
||||||
debug=(self.debug or debug_),
|
debug=debug_,
|
||||||
response_json_list_=response_json_list_,
|
response_json_list_=response_json_list_,
|
||||||
die_on_error_=self.exit_on_error)
|
die_on_error_=self.exit_on_error)
|
||||||
if debug_ and (response_json_list_ is not None):
|
if debug_ and (response_json_list_ is not None):
|
||||||
pprint.pprint(response_json_list_)
|
pprint.pprint(response_json_list_)
|
||||||
except Exception as x:
|
except Exception as x:
|
||||||
if self.debug or self.halt_on_error or self.exit_on_error:
|
if debug_ or self.halt_on_error or self.exit_on_error:
|
||||||
print("json_put submitted to %s" % _req_url)
|
print("json_put submitted to %s" % _req_url)
|
||||||
pprint.pprint(_data)
|
pprint.pprint(_data)
|
||||||
print("Exception %s:" % x)
|
print("Exception %s:" % x)
|
||||||
@@ -235,19 +252,26 @@ class LFCliBase:
|
|||||||
return json_response
|
return json_response
|
||||||
|
|
||||||
def json_get(self, _req_url, debug_=False):
|
def json_get(self, _req_url, debug_=False):
|
||||||
if self.debug or debug_:
|
debug_ |= self.debug
|
||||||
print("GET: "+_req_url)
|
# if debug_:
|
||||||
|
# print("json_get: "+_req_url)
|
||||||
|
# print("json_get: proxies:")
|
||||||
|
# pprint.pprint(self.proxy)
|
||||||
json_response = None
|
json_response = None
|
||||||
# print("----- GET ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ")
|
# print("----- GET ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ")
|
||||||
try:
|
try:
|
||||||
lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url, debug_=(self.debug or debug_), die_on_error_=self.exit_on_error)
|
lf_r = LFRequest.LFRequest(url=self.lfclient_url,
|
||||||
json_response = lf_r.get_as_json(debug_=self.debug, die_on_error_=self.halt_on_error)
|
uri=_req_url,
|
||||||
|
proxies_=self.proxy,
|
||||||
|
debug_=debug_,
|
||||||
|
die_on_error_=self.exit_on_error)
|
||||||
|
json_response = lf_r.get_as_json(debug_=debug_, die_on_error_=self.halt_on_error)
|
||||||
#debug_printer.pprint(json_response)
|
#debug_printer.pprint(json_response)
|
||||||
if (json_response is None) and (self.debug or debug_):
|
if (json_response is None) and debug_:
|
||||||
print("LFCliBase.json_get: no entity/response, probabily status 404")
|
print("LFCliBase.json_get: no entity/response, probabily status 404")
|
||||||
return None
|
return None
|
||||||
except ValueError as ve:
|
except ValueError as ve:
|
||||||
if self.debug or self.halt_on_error or self.exit_on_error:
|
if debug_ or self.halt_on_error or self.exit_on_error:
|
||||||
print("jsonGet asked for " + _req_url)
|
print("jsonGet asked for " + _req_url)
|
||||||
print("Exception %s:" % ve)
|
print("Exception %s:" % ve)
|
||||||
traceback.print_exception(ValueError, ve, ve.__traceback__, chain=True)
|
traceback.print_exception(ValueError, ve, ve.__traceback__, chain=True)
|
||||||
@@ -257,22 +281,24 @@ class LFCliBase:
|
|||||||
return json_response
|
return json_response
|
||||||
|
|
||||||
def json_delete(self, _req_url, debug_=False):
|
def json_delete(self, _req_url, debug_=False):
|
||||||
if self.debug or debug_:
|
debug_ |= self.debug
|
||||||
|
if debug_:
|
||||||
print("DELETE: "+_req_url)
|
print("DELETE: "+_req_url)
|
||||||
json_response = None
|
json_response = None
|
||||||
try:
|
try:
|
||||||
# print("----- DELETE ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ")
|
# print("----- DELETE ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ")
|
||||||
lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url,
|
lf_r = LFRequest.LFRequest(url=self.lfclient_url,
|
||||||
debug_=(self.debug or debug_),
|
uri=_req_url,
|
||||||
|
proxies_=self.proxy,
|
||||||
|
debug_=debug_,
|
||||||
die_on_error_=self.exit_on_error)
|
die_on_error_=self.exit_on_error)
|
||||||
json_response = lf_r.json_delete(debug=self.debug,
|
json_response = lf_r.json_delete(debug=debug_, die_on_error_=self.halt_on_error)
|
||||||
die_on_error_=self.halt_on_error)
|
|
||||||
#debug_printer.pprint(json_response)
|
#debug_printer.pprint(json_response)
|
||||||
if (json_response is None) and (self.debug or debug_):
|
if (json_response is None) and debug_:
|
||||||
print("LFCliBase.json_delete: no entity/response, probabily status 404")
|
print("LFCliBase.json_delete: no entity/response, probabily status 404")
|
||||||
return None
|
return None
|
||||||
except ValueError as ve:
|
except ValueError as ve:
|
||||||
if self.debug or self.halt_on_error or self.exit_on_error:
|
if debug_ or self.halt_on_error or self.exit_on_error:
|
||||||
print("json_delete asked for " + _req_url)
|
print("json_delete asked for " + _req_url)
|
||||||
print("Exception %s:" % ve)
|
print("Exception %s:" % ve)
|
||||||
traceback.print_exception(ValueError, ve, ve.__traceback__, chain=True)
|
traceback.print_exception(ValueError, ve, ve.__traceback__, chain=True)
|
||||||
@@ -356,17 +382,14 @@ class LFCliBase:
|
|||||||
pass_list.append(result)
|
pass_list.append(result)
|
||||||
return pass_list
|
return pass_list
|
||||||
|
|
||||||
|
|
||||||
def get_pass_message(self):
|
def get_pass_message(self):
|
||||||
pass_messages = self.get_passed_result_list()
|
pass_messages = self.get_passed_result_list()
|
||||||
return "\n".join(pass_messages)
|
return "\n".join(pass_messages)
|
||||||
|
|
||||||
|
|
||||||
def get_fail_message(self):
|
def get_fail_message(self):
|
||||||
fail_messages = self.get_failed_result_list()
|
fail_messages = self.get_failed_result_list()
|
||||||
return "\n".join(fail_messages)
|
return "\n".join(fail_messages)
|
||||||
|
|
||||||
|
|
||||||
def get_all_message(self):
|
def get_all_message(self):
|
||||||
return "\n".join(self.test_results)
|
return "\n".join(self.test_results)
|
||||||
|
|
||||||
@@ -390,7 +413,6 @@ class LFCliBase:
|
|||||||
print(message %(fail_len,total_len))
|
print(message %(fail_len,total_len))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
# use this inside the class to log a failure result and print it if wished
|
# use this inside the class to log a failure result and print it if wished
|
||||||
def _fail(self, message, print_=False):
|
def _fail(self, message, print_=False):
|
||||||
self.test_results.append(self.fail_pref + message)
|
self.test_results.append(self.fail_pref + message)
|
||||||
@@ -406,13 +428,38 @@ class LFCliBase:
|
|||||||
print(message %(num_passing,num_total))
|
print(message %(num_passing,num_total))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
# use this inside the class to log a pass result and print if wished.
|
# use this inside the class to log a pass result and print if wished.
|
||||||
def _pass(self, message, print_=False):
|
def _pass(self, message, print_=False):
|
||||||
self.test_results.append(self.pass_pref + message)
|
self.test_results.append(self.pass_pref + message)
|
||||||
if print_:
|
if print_:
|
||||||
print(self.pass_pref + message)
|
print(self.pass_pref + message)
|
||||||
#Create argparse with radio, securiy, ssid and passwd required
|
|
||||||
|
def adjust_proxy(self, proxy_str):
|
||||||
|
# if self.debug:
|
||||||
|
# print("lfclibase.adjust_proxy: %s" % proxy_str)
|
||||||
|
if (proxy_str is None) or (proxy_str == ""):
|
||||||
|
return
|
||||||
|
if self.proxy is None:
|
||||||
|
self.proxy = {}
|
||||||
|
|
||||||
|
if proxy_str.find("http:") > -1:
|
||||||
|
self.proxy["http"] = proxy_str
|
||||||
|
if proxy_str.find("https:") > -1:
|
||||||
|
self.proxy["https"] = proxy_str
|
||||||
|
# if self.debug:
|
||||||
|
# print("lfclibase::self.proxy: ")
|
||||||
|
# pprint.pprint(self.proxy)
|
||||||
|
|
||||||
|
|
||||||
|
# This style of Action subclass for argparse can't do much unless we incorporate
|
||||||
|
# our argparse as a member of LFCliBase. Then we can do something like automatically
|
||||||
|
# parse our proxy string without using _init_ arguments
|
||||||
|
# class ProxyAction(argparse.Action, zelf):
|
||||||
|
# def __init__(self, outter_):
|
||||||
|
# pass
|
||||||
|
# def __call__(self, parser, namespace, values, option_string=None):
|
||||||
|
# zelf.adjust_proxy(values)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_bare_argparse(prog=None, formatter_class=None, epilog=None, description=None):
|
def create_bare_argparse(prog=None, formatter_class=None, epilog=None, description=None):
|
||||||
if (prog is not None) or (formatter_class is not None) or (epilog is not None) or (description is not None):
|
if (prog is not None) or (formatter_class is not None) or (epilog is not None) or (description is not None):
|
||||||
@@ -428,14 +475,22 @@ class LFCliBase:
|
|||||||
optional.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost')
|
optional.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost')
|
||||||
optional.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080)
|
optional.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080)
|
||||||
optional.add_argument('--debug', help='Enable debugging', default=False, action="store_true")
|
optional.add_argument('--debug', help='Enable debugging', default=False, action="store_true")
|
||||||
|
optional.add_argument('--proxy', nargs='?', default=None, # action=ProxyAction,
|
||||||
|
help='Connection proxy like http://proxy.localnet:80 or https://user:pass@proxy.localnet:3128')
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
# Create argparse with radio, securiy, ssid and passwd required
|
# Create argparse with radio, securiy, ssid and passwd required
|
||||||
|
# TODO: show example of how to add required or optional arguments from calling class
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_basic_argparse(prog=None, formatter_class=None, epilog=None, description=None):
|
def create_basic_argparse(prog=None,
|
||||||
|
formatter_class=None,
|
||||||
|
epilog=None,
|
||||||
|
description=None):
|
||||||
if (prog is not None) or (formatter_class is not None) or (epilog is not None) or (description is not None):
|
if (prog is not None) or (formatter_class is not None) or (epilog is not None) or (description is not None):
|
||||||
parser = argparse.ArgumentParser(prog=prog, formatter_class=formatter_class, epilog=epilog,
|
parser = argparse.ArgumentParser(prog=prog,
|
||||||
|
formatter_class=formatter_class,
|
||||||
|
epilog=epilog,
|
||||||
description=description)
|
description=description)
|
||||||
else:
|
else:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
@@ -450,10 +505,13 @@ class LFCliBase:
|
|||||||
optional.add_argument('--num_stations', help='Number of stations to create', default=0)
|
optional.add_argument('--num_stations', help='Number of stations to create', default=0)
|
||||||
optional.add_argument('--test_id', help='Test ID (intended to use for ws events)', default="webconsole")
|
optional.add_argument('--test_id', help='Test ID (intended to use for ws events)', default="webconsole")
|
||||||
optional.add_argument('--debug', help='Enable debugging', default=False, action="store_true")
|
optional.add_argument('--debug', help='Enable debugging', default=False, action="store_true")
|
||||||
|
optional.add_argument('--proxy', nargs='?', default=None,
|
||||||
|
help='Connection proxy like http://proxy.localnet:80 or https://user:pass@proxy.localnet:3128')
|
||||||
#Required Args
|
#Required Args
|
||||||
required.add_argument('--radio', help='radio EID, e.g: 1.wiphy2', required=True)
|
required.add_argument('--radio', help='radio EID, e.g: 1.wiphy2')
|
||||||
required.add_argument('--ssid', help='SSID for stations to associate to', required=True)
|
required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >')
|
||||||
required.add_argument('--passwd', '--password' ,'--key', help='WiFi passphrase/password/key', required=True)
|
required.add_argument('--ssid', help='WiFi SSID for script objects to associate to')
|
||||||
|
required.add_argument('--passwd', '--password' ,'--key', help='WiFi passphrase/password/key')
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@@ -467,4 +525,21 @@ class LFCliBase:
|
|||||||
}
|
}
|
||||||
self.json_post("/cli-json/add_event", data, debug_=debug_)
|
self.json_post("/cli-json/add_event", data, debug_=debug_)
|
||||||
|
|
||||||
|
Help_Mode = """Station WiFi modes: use the number value below:
|
||||||
|
auto : 0,
|
||||||
|
a : 1,
|
||||||
|
b : 2,
|
||||||
|
g : 3,
|
||||||
|
abg : 4,
|
||||||
|
abgn : 5,
|
||||||
|
bgn : 6,
|
||||||
|
bg : 7,
|
||||||
|
abgnAC : 8,
|
||||||
|
anAC : 9,
|
||||||
|
an : 10,
|
||||||
|
bgnAC : 11,
|
||||||
|
abgnAX : 12,
|
||||||
|
bgnAX : 13
|
||||||
|
"""
|
||||||
|
|
||||||
# ~class
|
# ~class
|
||||||
|
|||||||
@@ -45,10 +45,39 @@ def wpa_ent_list():
|
|||||||
]
|
]
|
||||||
|
|
||||||
class Realm(LFCliBase):
|
class Realm(LFCliBase):
|
||||||
def __init__(self, lfclient_host="localhost", lfclient_port=8080, debug_=False, halt_on_error_=False):
|
def __init__(self,
|
||||||
super().__init__(_lfjson_host=lfclient_host, _lfjson_port=lfclient_port, _debug=debug_, _halt_on_error=halt_on_error_)
|
lfclient_host="localhost",
|
||||||
|
lfclient_port=8080,
|
||||||
|
debug_=False,
|
||||||
|
halt_on_error_=False,
|
||||||
|
_exit_on_error=False,
|
||||||
|
_exit_on_fail=False,
|
||||||
|
_local_realm=None,
|
||||||
|
_proxy_str=None,
|
||||||
|
_capture_signal_list=[]):
|
||||||
|
super().__init__(_lfjson_host=lfclient_host,
|
||||||
|
_lfjson_port=lfclient_port,
|
||||||
|
_debug=debug_,
|
||||||
|
_halt_on_error=halt_on_error_,
|
||||||
|
_exit_on_error=_exit_on_error,
|
||||||
|
_exit_on_fail=_exit_on_fail,
|
||||||
|
_proxy_str=_proxy_str,
|
||||||
|
_capture_signal_list=_capture_signal_list)
|
||||||
# self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port)
|
# self.lfclient_url = "http://%s:%s" % (lfclient_host, lfclient_port)
|
||||||
|
super().__init__(lfclient_host,
|
||||||
|
lfclient_port,
|
||||||
|
_debug=debug_,
|
||||||
|
_halt_on_error=halt_on_error_,
|
||||||
|
_exit_on_error=_exit_on_error,
|
||||||
|
_exit_on_fail=_exit_on_fail,
|
||||||
|
#_local_realm=self,
|
||||||
|
_proxy_str=_proxy_str,
|
||||||
|
_capture_signal_list=_capture_signal_list)
|
||||||
|
|
||||||
self.debug = debug_
|
self.debug = debug_
|
||||||
|
# if debug_:
|
||||||
|
# print("Realm _proxy_str: %s" % _proxy_str)
|
||||||
|
# pprint(_proxy_str)
|
||||||
self.check_connect()
|
self.check_connect()
|
||||||
self.chan_to_freq = {}
|
self.chan_to_freq = {}
|
||||||
self.freq_to_chan = {}
|
self.freq_to_chan = {}
|
||||||
@@ -2504,9 +2533,10 @@ class FIOEndpProfile(LFCliBase):
|
|||||||
self.json_post(req_url, data)
|
self.json_post(req_url, data)
|
||||||
#pprint(data)
|
#pprint(data)
|
||||||
|
|
||||||
def create(self, ports=[], sleep_time=.5, debug_=False, suppress_related_commands_=None):
|
def create(self, ports=[], connections_per_port=1, sleep_time=.5, debug_=False, suppress_related_commands_=None):
|
||||||
cx_post_data = []
|
cx_post_data = []
|
||||||
for port_name in ports:
|
for port_name in ports:
|
||||||
|
for num_connection in range(connections_per_port):
|
||||||
if len(self.local_realm.name_to_eid(port_name)) == 3:
|
if len(self.local_realm.name_to_eid(port_name)) == 3:
|
||||||
shelf = self.local_realm.name_to_eid(port_name)[0]
|
shelf = self.local_realm.name_to_eid(port_name)[0]
|
||||||
resource = self.local_realm.name_to_eid(port_name)[1]
|
resource = self.local_realm.name_to_eid(port_name)[1]
|
||||||
@@ -2516,7 +2546,7 @@ class FIOEndpProfile(LFCliBase):
|
|||||||
if self.directory is None or self.server_mount is None or self.fs_type is None:
|
if self.directory is None or self.server_mount is None or self.fs_type is None:
|
||||||
raise ValueError("directory [%s], server_mount [%s], and type [%s] must not be None" % (self.directory, self.server_mount, self.fs_type))
|
raise ValueError("directory [%s], server_mount [%s], and type [%s] must not be None" % (self.directory, self.server_mount, self.fs_type))
|
||||||
endp_data = {
|
endp_data = {
|
||||||
"alias": self.cx_prefix + name + "_fio",
|
"alias": self.cx_prefix + name + "_" + str(num_connection) + "_fio" ,
|
||||||
"shelf": shelf,
|
"shelf": shelf,
|
||||||
"resource": resource,
|
"resource": resource,
|
||||||
"port": name,
|
"port": name,
|
||||||
@@ -2534,15 +2564,15 @@ class FIOEndpProfile(LFCliBase):
|
|||||||
}
|
}
|
||||||
# Read direction is copy of write only directory
|
# Read direction is copy of write only directory
|
||||||
if self.io_direction == "read":
|
if self.io_direction == "read":
|
||||||
endp_data["prefix"] = "wo_" + name + "_fio"
|
endp_data["prefix"] = "wo_" + name + "_" + str(num_connection) + "_fio"
|
||||||
endp_data["directory"] = "/mnt/lf/wo_" + name + "_fio"
|
endp_data["directory"] = "/mnt/lf/wo_" + name + "_" + str(num_connection) + "_fio"
|
||||||
|
|
||||||
url = "cli-json/add_file_endp"
|
url = "cli-json/add_file_endp"
|
||||||
self.local_realm.json_post(url, endp_data, debug_=True, suppress_related_commands_=suppress_related_commands_)
|
self.local_realm.json_post(url, endp_data, debug_=False, suppress_related_commands_=suppress_related_commands_)
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"name": self.cx_prefix + name + "_fio",
|
"name": self.cx_prefix + name + "_" + str(num_connection) + "_fio" ,
|
||||||
"io_direction": self.io_direction,
|
"io_direction": self.io_direction,
|
||||||
"num_files": 5
|
"num_files": 5
|
||||||
}
|
}
|
||||||
@@ -2551,21 +2581,21 @@ class FIOEndpProfile(LFCliBase):
|
|||||||
|
|
||||||
self.local_realm.json_post("/cli-json/nc_show_endpoints", {"endpoint": "all"})
|
self.local_realm.json_post("/cli-json/nc_show_endpoints", {"endpoint": "all"})
|
||||||
for port_name in ports:
|
for port_name in ports:
|
||||||
|
for num_connection in range(connections_per_port):
|
||||||
if len(self.local_realm.name_to_eid(port_name)) == 3:
|
if len(self.local_realm.name_to_eid(port_name)) == 3:
|
||||||
shelf = self.local_realm.name_to_eid(port_name)[0]
|
shelf = self.local_realm.name_to_eid(port_name)[0]
|
||||||
resource = self.local_realm.name_to_eid(port_name)[1]
|
resource = self.local_realm.name_to_eid(port_name)[1]
|
||||||
name = self.local_realm.name_to_eid(port_name)[2]
|
name = self.local_realm.name_to_eid(port_name)[2]
|
||||||
|
|
||||||
endp_data = {
|
endp_data = {
|
||||||
"alias": "CX_" + self.cx_prefix + name + "_fio",
|
"alias": "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio" ,
|
||||||
"test_mgr": "default_tm",
|
"test_mgr": "default_tm",
|
||||||
"tx_endp": self.cx_prefix + name + "_fio",
|
"tx_endp": self.cx_prefix + name + "_" + str(num_connection) + "_fio" ,
|
||||||
"rx_endp": "NA"
|
"rx_endp": "NA"
|
||||||
}
|
}
|
||||||
cx_post_data.append(endp_data)
|
cx_post_data.append(endp_data)
|
||||||
self.created_cx[self.cx_prefix + name + "_fio"] = "CX_" + self.cx_prefix + name + "_fio"
|
self.created_cx[self.cx_prefix + name + "_" + str(num_connection) + "_fio" ] = "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio"
|
||||||
|
|
||||||
# time.sleep(3)
|
|
||||||
for cx_data in cx_post_data:
|
for cx_data in cx_post_data:
|
||||||
url = "/cli-json/add_cx"
|
url = "/cli-json/add_cx"
|
||||||
self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_)
|
self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
if sys.version_info[0] != 3:
|
if sys.version_info[0] != 3:
|
||||||
@@ -76,49 +77,37 @@ def main():
|
|||||||
prog='example_security_connection.py',
|
prog='example_security_connection.py',
|
||||||
formatter_class=argparse.RawTextHelpFormatter,
|
formatter_class=argparse.RawTextHelpFormatter,
|
||||||
epilog='''\
|
epilog='''\
|
||||||
Example flags and command line input to run the script.
|
This python script creates an inputted number of stations using user-inputted security. This verifies that the most basic form of security works with the LANforge device.
|
||||||
''',
|
''',
|
||||||
|
|
||||||
description='''\
|
description='''\
|
||||||
example_security_connection.py
|
example_security_connection.py
|
||||||
--------------------
|
---------------------------------------------------------------------------
|
||||||
This python script creates an inputted number of stations using user-inputted security. This verifies that the most basic form of security works with the LANforge device.
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
Generic command example:
|
Example of command line to run:
|
||||||
python3 ./example_security_connection.py
|
./example_security_connection.py
|
||||||
--mgr localhost
|
--mgr localhost
|
||||||
--mgr_port 8080
|
--mgr_port 8080
|
||||||
--num_stations 6
|
--num_stations 6
|
||||||
--mode 1
|
--mode 1
|
||||||
{"auto" : "0",
|
|
||||||
"a" : "1",
|
|
||||||
"b" : "2",
|
|
||||||
"g" : "3",
|
|
||||||
"abg" : "4",
|
|
||||||
"abgn" : "5",
|
|
||||||
"bgn" : "6",
|
|
||||||
"bg" : "7",
|
|
||||||
"abgnAC" : "8",
|
|
||||||
"anAC" : "9",
|
|
||||||
"an" : "10",
|
|
||||||
"bgnAC" : "11",
|
|
||||||
"abgnAX" : "12",
|
|
||||||
"bgnAX" : "13",
|
|
||||||
"anAX" : "14"}
|
|
||||||
--radio wiphy2
|
--radio wiphy2
|
||||||
--security {open|wep|wpa|wpa2|wpa3}
|
--security {open|wep|wpa|wpa2|wpa3}
|
||||||
--ssid netgear-wpa3
|
--ssid netgear-wpa3
|
||||||
--ap "00:0e:8e:78:e1:76"
|
--ap "00:0e:8e:78:e1:76"
|
||||||
--passwd admin123-wpa3
|
--passwd admin123-wpa3
|
||||||
--debug
|
--debug
|
||||||
|
|
||||||
''')
|
''')
|
||||||
optional = parser.add_argument_group('optional arguments')
|
required=None
|
||||||
required = parser.add_argument_group('required arguments')
|
for agroup in parser._action_groups:
|
||||||
required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True)
|
if agroup.title == "required arguments":
|
||||||
optional.add_argument('--mode',help='Used to force mode of stations')
|
required = agroup
|
||||||
optional.add_argument('--ap',help='Used to force a connection to a particular AP')
|
#if required is not None:
|
||||||
|
optional = None
|
||||||
|
for agroup in parser._action_groups:
|
||||||
|
if agroup.title == "optional arguments":
|
||||||
|
optional = agroup
|
||||||
|
if optional is not None:
|
||||||
|
optional.add_argument('--mode',help=LFCliBase.Help_Mode)
|
||||||
|
optional.add_argument('--ap',help='Add BSSID of access point to connect to')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
num_sta = 2
|
num_sta = 2
|
||||||
@@ -131,8 +120,11 @@ def main():
|
|||||||
end_id_=num_sta-1,
|
end_id_=num_sta-1,
|
||||||
padding_number_=10000,
|
padding_number_=10000,
|
||||||
radio=args.radio)
|
radio=args.radio)
|
||||||
ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, mode= args.mode,
|
ip_test = IPv4Test(host=args.mgr, port=args.mgr_port,
|
||||||
security=args.security, sta_list=station_list, ap=args.ap)
|
ssid=args.ssid, password=args.passwd,
|
||||||
|
radio=args.radio, mode= args.mode,
|
||||||
|
security=args.security, sta_list=station_list,
|
||||||
|
ap=args.ap)
|
||||||
ip_test.cleanup(station_list)
|
ip_test.cleanup(station_list)
|
||||||
ip_test.timeout = 60
|
ip_test.timeout = 60
|
||||||
ip_test.build()
|
ip_test.build()
|
||||||
|
|||||||
@@ -622,11 +622,12 @@ class cisco_():
|
|||||||
|
|
||||||
class L3VariableTime(LFCliBase):
|
class L3VariableTime(LFCliBase):
|
||||||
def __init__(self, host, port, endp_type, args, tos, side_b, radio_name_list, number_of_stations_per_radio_list,
|
def __init__(self, host, port, endp_type, args, tos, side_b, radio_name_list, number_of_stations_per_radio_list,
|
||||||
ssid_list, ssid_password_list, ssid_security_list, wifimode_list,station_lists, name_prefix, debug_on, outfile,
|
ssid_list, ssid_password_list, ssid_security_list, wifimode_list,station_lists, name_prefix, debug_on, outfile, results,
|
||||||
test_keys,test_config,
|
test_keys,test_config,
|
||||||
reset_port_enable_list,
|
reset_port_enable_list,
|
||||||
reset_port_time_min_list,
|
reset_port_time_min_list,
|
||||||
reset_port_time_max_list,
|
reset_port_time_max_list,
|
||||||
|
csv_started=False,
|
||||||
side_a_min_bps=560000, side_a_max_bps=0,
|
side_a_min_bps=560000, side_a_max_bps=0,
|
||||||
side_a_min_pdu=1518,side_a_max_pdu=0,
|
side_a_min_pdu=1518,side_a_max_pdu=0,
|
||||||
side_b_min_bps=560000, side_b_max_bps=0,
|
side_b_min_bps=560000, side_b_max_bps=0,
|
||||||
@@ -662,7 +663,8 @@ class L3VariableTime(LFCliBase):
|
|||||||
self.station_profiles = []
|
self.station_profiles = []
|
||||||
self.args = args
|
self.args = args
|
||||||
self.outfile = outfile
|
self.outfile = outfile
|
||||||
self.csv_started = False
|
self.results = results
|
||||||
|
self.csv_started = csv_started
|
||||||
self.epoch_time = int(time.time())
|
self.epoch_time = int(time.time())
|
||||||
self.debug = debug_on
|
self.debug = debug_on
|
||||||
self.test_keys = test_keys
|
self.test_keys = test_keys
|
||||||
@@ -676,6 +678,10 @@ class L3VariableTime(LFCliBase):
|
|||||||
self.csv_file = open(self.outfile, "a+")
|
self.csv_file = open(self.outfile, "a+")
|
||||||
self.csv_writer = csv.writer(self.csv_file, delimiter=",")
|
self.csv_writer = csv.writer(self.csv_file, delimiter=",")
|
||||||
|
|
||||||
|
if self.results is not None:
|
||||||
|
self.csv_results = open(self.results, "a+")
|
||||||
|
self.csv_results_writer = csv.writer(self.csv_results, delimiter=",")
|
||||||
|
|
||||||
for (radio_, ssid_, ssid_password_, ssid_security_, wifimode_,\
|
for (radio_, ssid_, ssid_password_, ssid_security_, wifimode_,\
|
||||||
reset_port_enable_, reset_port_time_min_, reset_port_time_max_) \
|
reset_port_enable_, reset_port_time_min_, reset_port_time_max_) \
|
||||||
in zip(radio_name_list, ssid_list, ssid_password_list, ssid_security_list, wifimode_list,\
|
in zip(radio_name_list, ssid_list, ssid_password_list, ssid_security_list, wifimode_list,\
|
||||||
@@ -766,6 +772,7 @@ class L3VariableTime(LFCliBase):
|
|||||||
csv_rx_drop_percent_data.append(rx_drop_percent[item])
|
csv_rx_drop_percent_data.append(rx_drop_percent[item])
|
||||||
|
|
||||||
self.csv_add_row(csv_rx_drop_percent_data,self.csv_writer,self.csv_file)
|
self.csv_add_row(csv_rx_drop_percent_data,self.csv_writer,self.csv_file)
|
||||||
|
self.csv_add_row(csv_rx_drop_percent_data,self.csv_results_writer,self.csv_results)
|
||||||
|
|
||||||
def __compare_vals(self, old_list, new_list):
|
def __compare_vals(self, old_list, new_list):
|
||||||
passes = 0
|
passes = 0
|
||||||
@@ -773,12 +780,14 @@ class L3VariableTime(LFCliBase):
|
|||||||
csv_performance_values = []
|
csv_performance_values = []
|
||||||
csv_rx_headers = []
|
csv_rx_headers = []
|
||||||
csv_rx_row_data = []
|
csv_rx_row_data = []
|
||||||
|
csv_result_row_data = []
|
||||||
csv_rx_delta_row_data = []
|
csv_rx_delta_row_data = []
|
||||||
csv_rx_delta_dict = {}
|
csv_rx_delta_dict = {}
|
||||||
|
test_id = ""
|
||||||
|
|
||||||
for key in self.test_keys:
|
#for key in self.test_keys:
|
||||||
csv_rx_row_data.append(self.test_config_dict[key])
|
# csv_rx_row_data.append(self.test_config_dict[key])
|
||||||
csv_rx_delta_row_data.append(self.test_config_dict[key])
|
# csv_rx_delta_row_data.append(self.test_config_dict[key])
|
||||||
|
|
||||||
|
|
||||||
for key in [key for key in old_list if "mtx" in key]: del old_list[key]
|
for key in [key for key in old_list if "mtx" in key]: del old_list[key]
|
||||||
@@ -787,8 +796,6 @@ class L3VariableTime(LFCliBase):
|
|||||||
filtered_values = [v for _, v in new_list.items() if v !=0]
|
filtered_values = [v for _, v in new_list.items() if v !=0]
|
||||||
average_rx= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0
|
average_rx= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# only evaluate upstream or downstream
|
# only evaluate upstream or downstream
|
||||||
new_evaluate_list = new_list.copy()
|
new_evaluate_list = new_list.copy()
|
||||||
print("new_evaluate_list before",new_evaluate_list)
|
print("new_evaluate_list before",new_evaluate_list)
|
||||||
@@ -798,6 +805,7 @@ class L3VariableTime(LFCliBase):
|
|||||||
elif "downstream" in self.test_config_dict.values():
|
elif "downstream" in self.test_config_dict.values():
|
||||||
for key in [key for key in new_evaluate_list if "-B" in key]: del new_evaluate_list[key]
|
for key in [key for key in new_evaluate_list if "-B" in key]: del new_evaluate_list[key]
|
||||||
print("downstream in dictionary values")
|
print("downstream in dictionary values")
|
||||||
|
#follow code left in for now, provides the best 5 worst 5
|
||||||
'''print("new_evaluate_list after",new_evaluate_list)
|
'''print("new_evaluate_list after",new_evaluate_list)
|
||||||
csv_performance_values=sorted(new_evaluate_list.items(), key=lambda x: (x[1],x[0]), reverse=False)
|
csv_performance_values=sorted(new_evaluate_list.items(), key=lambda x: (x[1],x[0]), reverse=False)
|
||||||
csv_performance_values=self.csv_validate_list(csv_performance_values,5)
|
csv_performance_values=self.csv_validate_list(csv_performance_values,5)
|
||||||
@@ -819,6 +827,7 @@ class L3VariableTime(LFCliBase):
|
|||||||
if len(old_evaluate_list) == len(new_evaluate_list):
|
if len(old_evaluate_list) == len(new_evaluate_list):
|
||||||
for item, value in old_evaluate_list.items():
|
for item, value in old_evaluate_list.items():
|
||||||
expected_passes +=1
|
expected_passes +=1
|
||||||
|
print("ITEM: {} VALUE: {}".format(item, value))
|
||||||
if new_evaluate_list[item] > old_evaluate_list[item]:
|
if new_evaluate_list[item] > old_evaluate_list[item]:
|
||||||
passes += 1
|
passes += 1
|
||||||
#if self.debug: logg.info(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item])
|
#if self.debug: logg.info(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item])
|
||||||
@@ -835,26 +844,54 @@ class L3VariableTime(LFCliBase):
|
|||||||
csv_header += csv_rx_headers
|
csv_header += csv_rx_headers
|
||||||
logg.info(csv_header)
|
logg.info(csv_header)
|
||||||
self.csv_add_column_headers(csv_header)
|
self.csv_add_column_headers(csv_header)
|
||||||
|
csv_results = self.csv_generate_column_results_headers()
|
||||||
|
#csv_results += csv_rx_headers
|
||||||
|
self.csv_add_column_headers_results(csv_results)
|
||||||
|
print("###################################")
|
||||||
|
print(csv_results)
|
||||||
|
print("###################################")
|
||||||
|
|
||||||
self.csv_started = True
|
self.csv_started = True
|
||||||
|
|
||||||
# need to generate list first to determine worst and best
|
# need to generate list first to determine worst and best
|
||||||
filtered_values = [v for _, v in csv_rx_delta_dict.items() if v !=0]
|
filtered_values = [v for _, v in csv_rx_delta_dict.items() if v !=0]
|
||||||
#average_rx_delta= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0
|
#average_rx_delta= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0
|
||||||
|
for key in self.test_keys:
|
||||||
|
csv_rx_row_data.append(self.test_config_dict[key])
|
||||||
|
csv_result_row_data.append(self.test_config_dict[key])
|
||||||
|
csv_rx_delta_row_data.append(self.test_config_dict[key])
|
||||||
|
|
||||||
max_tp_mbps = sum(filtered_values)
|
max_tp_mbps = sum(filtered_values)
|
||||||
csv_rx_row_data.append(max_tp_mbps)
|
csv_rx_row_data.append(max_tp_mbps)
|
||||||
|
csv_result_row_data.append(max_tp_mbps)
|
||||||
|
|
||||||
#To do needs to be read or passed in based on test type
|
#To do needs to be read or passed in based on test type
|
||||||
expected_tp_mbps = max_tp_mbps
|
expected_tp_mbps = max_tp_mbps
|
||||||
csv_rx_row_data.append(expected_tp_mbps)
|
csv_rx_row_data.append(expected_tp_mbps)
|
||||||
|
csv_result_row_data.append(expected_tp_mbps)
|
||||||
|
|
||||||
|
|
||||||
|
#Generate TestID
|
||||||
|
for key in self.test_keys:
|
||||||
|
test_id = test_id + "_" + self.test_config_dict[key]
|
||||||
|
|
||||||
|
print("test_id: {}".format(test_id))
|
||||||
|
csv_rx_row_data.append(test_id)
|
||||||
|
csv_result_row_data.append(test_id)
|
||||||
|
|
||||||
# Todo pass or fail
|
# Todo pass or fail
|
||||||
if max_tp_mbps == expected_tp_mbps:
|
if max_tp_mbps == expected_tp_mbps:
|
||||||
csv_rx_row_data.append("pass")
|
csv_rx_row_data.append("pass")
|
||||||
|
csv_result_row_data.append("pass")
|
||||||
else:
|
else:
|
||||||
csv_rx_row_data.append("fail")
|
csv_rx_row_data.append("fail")
|
||||||
|
csv_result_row_data.append("fail")
|
||||||
|
|
||||||
csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta'])
|
csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta'])
|
||||||
|
csv_result_row_data.extend([self.epoch_time, self.time_stamp()])
|
||||||
|
|
||||||
|
print("csv_rx_row_data {}".format(csv_rx_row_data))
|
||||||
|
#TODO: may want to pass in the information that needs to be in the csv file into the class
|
||||||
'''
|
'''
|
||||||
csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx'])
|
csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx'])
|
||||||
csv_rx_delta_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta'])
|
csv_rx_delta_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta'])
|
||||||
@@ -880,20 +917,23 @@ class L3VariableTime(LFCliBase):
|
|||||||
csv_rx_headers.append(item)
|
csv_rx_headers.append(item)
|
||||||
# note need to have all upstream and downstream in the csv table thus new_list and old_list
|
# note need to have all upstream and downstream in the csv table thus new_list and old_list
|
||||||
#csv_rx_row_data.append(new_list[item])
|
#csv_rx_row_data.append(new_list[item])
|
||||||
|
# provide delta
|
||||||
csv_rx_row_data.append(new_list[item] - old_list[item])
|
csv_rx_row_data.append(new_list[item] - old_list[item])
|
||||||
|
|
||||||
self.csv_add_row(csv_rx_row_data,self.csv_writer,self.csv_file)
|
self.csv_add_row(csv_rx_row_data,self.csv_writer,self.csv_file)
|
||||||
|
#self.csv_add_row(csv_rx_row_data,self.csv_results_writer,self.csv_results)
|
||||||
|
|
||||||
#self.csv_add_row(csv_rx_delta_row_data,self.csv_writer,self.csv_file)
|
#self.csv_add_row(csv_rx_delta_row_data,self.csv_writer,self.csv_file)
|
||||||
|
|
||||||
if passes == expected_passes:
|
if passes == expected_passes:
|
||||||
return True
|
return True, max_tp_mbps, csv_result_row_data
|
||||||
else:
|
else:
|
||||||
return False
|
return False, max_tp_mbps, csv_result_row_data
|
||||||
else:
|
else:
|
||||||
print("Old-list length: %i new: %i does not match in compare-vals."%(len(old_list), len(new_list)))
|
print("Old-list length: %i new: %i does not match in compare-vals."%(len(old_list), len(new_list)))
|
||||||
print("old-list:",old_list)
|
print("old-list:",old_list)
|
||||||
print("new-list:",new_list)
|
print("new-list:",new_list)
|
||||||
return False
|
return False, None, None # check to see if this is valid
|
||||||
|
|
||||||
def verify_controller(self):
|
def verify_controller(self):
|
||||||
if self.args == None:
|
if self.args == None:
|
||||||
@@ -1002,6 +1042,11 @@ class L3VariableTime(LFCliBase):
|
|||||||
self._pass("PASS: Stations build finished")
|
self._pass("PASS: Stations build finished")
|
||||||
|
|
||||||
def start(self, print_pass=False, print_fail=False):
|
def start(self, print_pass=False, print_fail=False):
|
||||||
|
best_max_tp_mbps = 0
|
||||||
|
best_csv_rx_row_data = " "
|
||||||
|
max_tp_mbps = 0
|
||||||
|
csv_rx_row_data = " "
|
||||||
|
Result = False
|
||||||
logg.info("Bringing up stations")
|
logg.info("Bringing up stations")
|
||||||
self.local_realm.admin_up(self.side_b)
|
self.local_realm.admin_up(self.side_b)
|
||||||
for station_profile in self.station_profiles:
|
for station_profile in self.station_profiles:
|
||||||
@@ -1052,7 +1097,23 @@ class L3VariableTime(LFCliBase):
|
|||||||
new_rx_values, rx_drop_percent = self.__get_rx_values()
|
new_rx_values, rx_drop_percent = self.__get_rx_values()
|
||||||
|
|
||||||
expected_passes += 1
|
expected_passes += 1
|
||||||
if self.__compare_vals(old_rx_values, new_rx_values):
|
'''
|
||||||
|
#self.csv_add_row(csv_rx_row_data,self.csv_results_writer,self.csv_results)
|
||||||
|
|
||||||
|
|
||||||
|
if passes == expected_passes:
|
||||||
|
return True, max_tp_mbps, csv_rx_row_data
|
||||||
|
else:
|
||||||
|
return False, max_tp_mbps, csv_rx_row_data
|
||||||
|
'''
|
||||||
|
# __compare_vals - does the calculations
|
||||||
|
Result, max_tp_mbps, csv_rx_row_data = self.__compare_vals(old_rx_values, new_rx_values)
|
||||||
|
if max_tp_mbps > best_max_tp_mbps:
|
||||||
|
best_max_tp_mbps = max_tp_mbps
|
||||||
|
best_csv_rx_row_data = csv_rx_row_data
|
||||||
|
|
||||||
|
# need to check the expected max_tp_mbps
|
||||||
|
if Result:
|
||||||
passes += 1
|
passes += 1
|
||||||
else:
|
else:
|
||||||
self._fail("FAIL: Not all stations increased traffic", print_fail)
|
self._fail("FAIL: Not all stations increased traffic", print_fail)
|
||||||
@@ -1062,7 +1123,7 @@ class L3VariableTime(LFCliBase):
|
|||||||
#self.__record_rx_dropped_percent(rx_drop_percent)
|
#self.__record_rx_dropped_percent(rx_drop_percent)
|
||||||
|
|
||||||
cur_time = datetime.datetime.now()
|
cur_time = datetime.datetime.now()
|
||||||
|
self.csv_add_row(best_csv_rx_row_data,self.csv_results_writer,self.csv_results)
|
||||||
if passes == expected_passes:
|
if passes == expected_passes:
|
||||||
self._pass("PASS: All tests passed", print_pass)
|
self._pass("PASS: All tests passed", print_pass)
|
||||||
|
|
||||||
@@ -1083,7 +1144,7 @@ class L3VariableTime(LFCliBase):
|
|||||||
def csv_generate_column_headers(self):
|
def csv_generate_column_headers(self):
|
||||||
csv_rx_headers = self.test_keys.copy()
|
csv_rx_headers = self.test_keys.copy()
|
||||||
csv_rx_headers.extend
|
csv_rx_headers.extend
|
||||||
csv_rx_headers.extend(['Max TP Mbps','Expected TP','Pass Fail','Time epoch','Time','Monitor'])
|
csv_rx_headers.extend(['max_tp_mbps','expected_tp','test_id','pass_fail','epoch_time','time','monitor'])
|
||||||
'''for i in range(1,6):
|
'''for i in range(1,6):
|
||||||
csv_rx_headers.append("least_rx_data {}".format(i))
|
csv_rx_headers.append("least_rx_data {}".format(i))
|
||||||
for i in range(1,6):
|
for i in range(1,6):
|
||||||
@@ -1091,18 +1152,35 @@ class L3VariableTime(LFCliBase):
|
|||||||
csv_rx_headers.append("average_rx_data")'''
|
csv_rx_headers.append("average_rx_data")'''
|
||||||
return csv_rx_headers
|
return csv_rx_headers
|
||||||
|
|
||||||
|
def csv_generate_column_results_headers(self):
|
||||||
|
csv_rx_headers = self.test_keys.copy()
|
||||||
|
csv_rx_headers.extend
|
||||||
|
csv_rx_headers.extend(['max_tp_mbps','expected_tp','test_id','pass_fail','epoch_time','time'])
|
||||||
|
'''for i in range(1,6):
|
||||||
|
csv_rx_headers.append("least_rx_data {}".format(i))
|
||||||
|
for i in range(1,6):
|
||||||
|
csv_rx_headers.append("most_rx_data_{}".format(i))
|
||||||
|
csv_rx_headers.append("average_rx_data")'''
|
||||||
|
return csv_rx_headers
|
||||||
|
|
||||||
|
|
||||||
def csv_add_column_headers(self,headers):
|
def csv_add_column_headers(self,headers):
|
||||||
if self.csv_file is not None:
|
if self.csv_file is not None:
|
||||||
self.csv_writer.writerow(headers)
|
self.csv_writer.writerow(headers)
|
||||||
self.csv_file.flush()
|
self.csv_file.flush()
|
||||||
|
|
||||||
|
def csv_add_column_headers_results(self,headers):
|
||||||
|
if self.csv_results is not None:
|
||||||
|
self.csv_results_writer.writerow(headers)
|
||||||
|
self.csv_results.flush()
|
||||||
|
|
||||||
def csv_validate_list(self, csv_list, length):
|
def csv_validate_list(self, csv_list, length):
|
||||||
if len(csv_list) < length:
|
if len(csv_list) < length:
|
||||||
csv_list = csv_list + [('no data','no data')] * (length - len(csv_list))
|
csv_list = csv_list + [('no data','no data')] * (length - len(csv_list))
|
||||||
return csv_list
|
return csv_list
|
||||||
|
|
||||||
def csv_add_row(self,row,writer,csv_file):
|
def csv_add_row(self,row,writer,csv_file): # can make two calls eventually
|
||||||
if self.csv_file is not None:
|
if csv_file is not None:
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
csv_file.flush()
|
csv_file.flush()
|
||||||
|
|
||||||
@@ -1466,6 +1544,7 @@ Eventual Realm at Cisco
|
|||||||
if args.csv_outfile != None:
|
if args.csv_outfile != None:
|
||||||
current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime())
|
current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime())
|
||||||
csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time)
|
csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time)
|
||||||
|
csv_results = "results_{}_{}.csv".format(args.csv_outfile,current_time)
|
||||||
print("csv output file : {}".format(csv_outfile))
|
print("csv output file : {}".format(csv_outfile))
|
||||||
|
|
||||||
if args.log:
|
if args.log:
|
||||||
@@ -1707,13 +1786,13 @@ Eventual Realm at Cisco
|
|||||||
cisco_chan_widths = "20".split()
|
cisco_chan_widths = "20".split()
|
||||||
cisco_ap_modes = "local".split()
|
cisco_ap_modes = "local".split()
|
||||||
cisco_data_encryptions = "disable".split()
|
cisco_data_encryptions = "disable".split()
|
||||||
cisco_packet_types = "lf_udp lf_tcp".split()
|
#cisco_packet_types = "lf_udp lf_tcp".split()
|
||||||
#cisco_packet_types = "lf_udp".split()
|
cisco_packet_types = "lf_udp".split()
|
||||||
#cisco_directions = "upstream downstream".split()
|
#cisco_directions = "upstream downstream".split()
|
||||||
cisco_directions = "upstream downstream".split()
|
cisco_directions = "upstream downstream".split()
|
||||||
cisco_packet_sizes = "88 512 1370 1518".split()
|
#cisco_packet_sizes = "88 512 1370 1518".split()
|
||||||
#cisco_packet_sizes = "1518".split()
|
cisco_packet_sizes = "1518".split()
|
||||||
cisco_client_densities = "1".split()
|
cisco_client_densities = "10".split()
|
||||||
cisco_data_encryptions = "disable".split()
|
cisco_data_encryptions = "disable".split()
|
||||||
|
|
||||||
cisco_side_a_min_bps = 500000000
|
cisco_side_a_min_bps = 500000000
|
||||||
@@ -1760,11 +1839,12 @@ Eventual Realm at Cisco
|
|||||||
logg.info(cisco_client_densities)
|
logg.info(cisco_client_densities)
|
||||||
logg.info(cisco_data_encryptions)
|
logg.info(cisco_data_encryptions)
|
||||||
|
|
||||||
ap_set = None
|
__ap_set = None
|
||||||
band_set = None
|
__band_set = None
|
||||||
chan_width_set = None
|
__chan_width_set = None
|
||||||
ap_mode_set = None
|
__ap_mode_set = None
|
||||||
tx_power_set = None
|
__tx_power_set = None
|
||||||
|
__csv_started = False
|
||||||
|
|
||||||
for cisco_ap in cisco_aps:
|
for cisco_ap in cisco_aps:
|
||||||
for cisco_band in cisco_bands: # frequency
|
for cisco_band in cisco_bands: # frequency
|
||||||
@@ -1788,26 +1868,27 @@ Eventual Realm at Cisco
|
|||||||
cisco_band,cisco_wifimode,cisco_chan_width,cisco_data_encryption,cisco_ap_mode,cisco_client_density,
|
cisco_band,cisco_wifimode,cisco_chan_width,cisco_data_encryption,cisco_ap_mode,cisco_client_density,
|
||||||
cisco_packet_type,cisco_direction,cisco_packet_size)
|
cisco_packet_type,cisco_direction,cisco_packet_size)
|
||||||
test_keys = ['AP','Band','wifi_mode','BW','encryption','ap_mode','clients','packet_type','direction','packet_size']
|
test_keys = ['AP','Band','wifi_mode','BW','encryption','ap_mode','clients','packet_type','direction','packet_size']
|
||||||
|
|
||||||
logg.info("# Cisco run settings: {}".format(test_config))
|
logg.info("# Cisco run settings: {}".format(test_config))
|
||||||
if(args.no_controller):
|
if(args.no_controller):
|
||||||
logg.info("################################################")
|
logg.info("################################################")
|
||||||
logg.info("# NO CONTROLLER SET , TEST MODE")
|
logg.info("# NO CONTROLLER SET , TEST MODE")
|
||||||
logg.info("################################################")
|
logg.info("################################################")
|
||||||
else:
|
else:
|
||||||
if( cisco_ap != ap_set or
|
if( cisco_ap != __ap_set or
|
||||||
cisco_band != band_set or
|
cisco_band != __band_set or
|
||||||
cisco_chan_width != chan_width_set or
|
cisco_chan_width != __chan_width_set or
|
||||||
cisco_ap_mode != ap_mode_set or
|
cisco_ap_mode != __ap_mode_set or
|
||||||
cisco_tx_power != tx_power_set
|
cisco_tx_power != __tx_power_set
|
||||||
):
|
):
|
||||||
logg.info("###############################################")
|
logg.info("###############################################")
|
||||||
logg.info("# NEW CONTROLLER CONFIG")
|
logg.info("# NEW CONTROLLER CONFIG")
|
||||||
logg.info("###############################################")
|
logg.info("###############################################")
|
||||||
ap_set = cisco_ap
|
__ap_set = cisco_ap
|
||||||
band_set = cisco_band
|
__band_set = cisco_band
|
||||||
chan_width_set = cisco_chan_width
|
__chan_width_set = cisco_chan_width
|
||||||
ap_mode_set = cisco_ap_mode
|
__ap_mode_set = cisco_ap_mode
|
||||||
tx_power_set = cisco_tx_power
|
__tx_power_set = cisco_tx_power
|
||||||
#############################################
|
#############################################
|
||||||
# configure cisco controller
|
# configure cisco controller
|
||||||
#############################################
|
#############################################
|
||||||
@@ -1969,8 +2050,11 @@ Eventual Realm at Cisco
|
|||||||
side_b_min_pdu =cisco_packet_size,
|
side_b_min_pdu =cisco_packet_size,
|
||||||
debug_on=debug_on,
|
debug_on=debug_on,
|
||||||
outfile=csv_outfile,
|
outfile=csv_outfile,
|
||||||
|
results=csv_results,
|
||||||
test_keys=test_keys,
|
test_keys=test_keys,
|
||||||
test_config=test_config)
|
test_config=test_config,
|
||||||
|
csv_started=__csv_started )
|
||||||
|
__csv_started = True
|
||||||
ip_var_test.pre_cleanup()
|
ip_var_test.pre_cleanup()
|
||||||
ip_var_test.build()
|
ip_var_test.build()
|
||||||
if not ip_var_test.passes():
|
if not ip_var_test.passes():
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ SSID_USED="jedway-wpa2-x2048-5-3"
|
|||||||
PASSWD_USED="jedway-wpa2-x2048-5-3"
|
PASSWD_USED="jedway-wpa2-x2048-5-3"
|
||||||
RADIO_USED="wiphy1"
|
RADIO_USED="wiphy1"
|
||||||
SECURITY="wpa2"
|
SECURITY="wpa2"
|
||||||
CURR_TEST_NAME="BLANK"
|
|
||||||
CURR_TEST_NUM=0
|
|
||||||
STOP_NUM=9
|
|
||||||
START_NUM=0
|
START_NUM=0
|
||||||
|
CURR_TEST_NUM=0
|
||||||
|
CURR_TEST_NAME="BLANK"
|
||||||
|
STOP_NUM=9
|
||||||
|
|
||||||
#Test array
|
#Test array
|
||||||
testCommands=("./example_wpa_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa"
|
testCommands=("./example_wpa_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa"
|
||||||
"./example_wpa2_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2"
|
"./example_wpa2_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2"
|
||||||
@@ -24,28 +26,19 @@ testCommands=("./example_wpa_connection.py --num_stations $NUM_STA --ssid jedway
|
|||||||
"./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m"
|
"./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m"
|
||||||
"./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug"
|
"./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug"
|
||||||
)
|
)
|
||||||
function ret_case_num(){
|
declare -A name_to_num
|
||||||
case $1 in
|
name_to_num=(
|
||||||
"example_wpa_connection")
|
["example_wpa_connection"]=1
|
||||||
echo 1 ;;
|
["example_wpa2_connection"]=2
|
||||||
"example_wpa2_connection")
|
["example_wpa3_connection"]=4
|
||||||
echo 2 ;;
|
["example_wep_connection"]=3
|
||||||
"example_wpa3_connection")
|
["test_ipv4_connection"]=5
|
||||||
echo 4 ;;
|
["test_generic"]=6
|
||||||
"example_wep_connection")
|
["test_ipv4_l4_urls_per_ten"]=7
|
||||||
echo 3 ;;
|
["test_ipv4_l4_wifi"]=8
|
||||||
"test_ipv4_connection")
|
["test_ipv4_l4"]=9
|
||||||
echo 5 ;;
|
)
|
||||||
"test_generic")
|
|
||||||
echo 6 ;;
|
|
||||||
"test_ipv4_l4_urls_per_ten")
|
|
||||||
echo 7 ;;
|
|
||||||
"test_ipv4_l4_wifi")
|
|
||||||
echo 8 ;;
|
|
||||||
"test_ipv4_l4")
|
|
||||||
echo 9 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
function blank_db() {
|
function blank_db() {
|
||||||
echo "Loading blank scenario..." >>~/test_all_output_file.txt
|
echo "Loading blank scenario..." >>~/test_all_output_file.txt
|
||||||
./scenario.py --load BLANK >>~/test_all_output_file.txt
|
./scenario.py --load BLANK >>~/test_all_output_file.txt
|
||||||
@@ -58,15 +51,20 @@ function run_test(){
|
|||||||
for i in "${testCommands[@]}"; do
|
for i in "${testCommands[@]}"; do
|
||||||
CURR_TEST_NAME=${i%%.py*}
|
CURR_TEST_NAME=${i%%.py*}
|
||||||
CURR_TEST_NAME=${CURR_TEST_NAME#./*}
|
CURR_TEST_NAME=${CURR_TEST_NAME#./*}
|
||||||
CURR_TEST_NUM=$(ret_case_num $CURR_TEST_NAME)
|
CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}"
|
||||||
if [[ $CURR_TEST_NUM -gt $STOP_NUM ]] || [[ $STOP_NUM -eq $CURR_NUM && $STOP_NUM -ne 0 ]]; then
|
echo "$CURR_TEST_NAME $CURR_TEST_NUM"
|
||||||
|
|
||||||
|
if (( $CURR_TEST_NUM > $STOP_NUM )) || (( $STOP_NUM == $CURR_TEST_NUM )) && (( $STOP_NUM != 0 )); then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ $CURR_TEST_NUM -gt $START_NUM ]] || [[ $CURR_TEST_NUM -eq $START_NUM ]]; then
|
if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then
|
||||||
echo_print
|
echo_print
|
||||||
|
echo "$i"
|
||||||
|
[[ x$DEBUG != x ]] && sleep 2
|
||||||
eval $i >>~/test_all_output_file.txt
|
eval $i >>~/test_all_output_file.txt
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo $CURR_TEST_NAME failure
|
echo $CURR_TEST_NAME failure
|
||||||
|
[[ x$DEBUG != x ]] && exit 1
|
||||||
else
|
else
|
||||||
echo $CURR_TEST_NAME success
|
echo $CURR_TEST_NAME success
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class FileIOTest(LFCliBase):
|
|||||||
read_only_test_group=None,
|
read_only_test_group=None,
|
||||||
port_list=[],
|
port_list=[],
|
||||||
ip_list=None,
|
ip_list=None,
|
||||||
|
connections_per_port=1,
|
||||||
mode="both",
|
mode="both",
|
||||||
update_group_args={"name": None, "action": None, "cxs": None},
|
update_group_args={"name": None, "action": None, "cxs": None},
|
||||||
_debug_on=False,
|
_debug_on=False,
|
||||||
@@ -66,6 +67,7 @@ class FileIOTest(LFCliBase):
|
|||||||
self.number_template = number_template
|
self.number_template = number_template
|
||||||
self.test_duration = test_duration
|
self.test_duration = test_duration
|
||||||
self.port_list = []
|
self.port_list = []
|
||||||
|
self.connections_per_port = connections_per_port
|
||||||
self.use_macvlans = use_macvlans
|
self.use_macvlans = use_macvlans
|
||||||
self.mode = mode.lower()
|
self.mode = mode.lower()
|
||||||
self.ip_list = ip_list
|
self.ip_list = ip_list
|
||||||
@@ -131,6 +133,7 @@ class FileIOTest(LFCliBase):
|
|||||||
self.wo_profile.max_write_rate_bps = LFUtils.parse_size(max_write_rate_bps)
|
self.wo_profile.max_write_rate_bps = LFUtils.parse_size(max_write_rate_bps)
|
||||||
self.wo_profile.directory = directory
|
self.wo_profile.directory = directory
|
||||||
self.wo_profile.server_mount = server_mount
|
self.wo_profile.server_mount = server_mount
|
||||||
|
self.wo_profile.num_connections_per_port = connections_per_port
|
||||||
|
|
||||||
self.ro_profile = self.wo_profile.create_ro_profile()
|
self.ro_profile = self.wo_profile.create_ro_profile()
|
||||||
|
|
||||||
@@ -280,9 +283,10 @@ class FileIOTest(LFCliBase):
|
|||||||
self.created_ports += self.station_profile.station_names
|
self.created_ports += self.station_profile.station_names
|
||||||
|
|
||||||
if len(self.ip_list) > 0:
|
if len(self.ip_list) > 0:
|
||||||
if self.gateway is not None and self.netmask is not None:
|
# print("++++++++++++++++\n", self.ip_list, "++++++++++++++++\n")
|
||||||
print("++++++++++++++++\n", self.ip_list, "++++++++++++++++\n")
|
|
||||||
for num_port in range(len(self.port_list)):
|
for num_port in range(len(self.port_list)):
|
||||||
|
if self.ip_list[num_port] != 0:
|
||||||
|
if self.gateway is not None and self.netmask is not None:
|
||||||
shelf = self.local_realm.name_to_eid(self.port_list[num_port])[0]
|
shelf = self.local_realm.name_to_eid(self.port_list[num_port])[0]
|
||||||
resource = self.local_realm.name_to_eid(self.port_list[num_port])[1]
|
resource = self.local_realm.name_to_eid(self.port_list[num_port])[1]
|
||||||
port = self.local_realm.name_to_eid(self.port_list[num_port])[2]
|
port = self.local_realm.name_to_eid(self.port_list[num_port])[2]
|
||||||
@@ -310,7 +314,8 @@ class FileIOTest(LFCliBase):
|
|||||||
if self.wo_tg_exists:
|
if self.wo_tg_exists:
|
||||||
if not self.wo_tg_cx_exists:
|
if not self.wo_tg_cx_exists:
|
||||||
print("Creating Write Only CXs")
|
print("Creating Write Only CXs")
|
||||||
self.wo_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.wo_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Adding cxs to %s" % self.wo_tg_profile.group_name)
|
print("Adding cxs to %s" % self.wo_tg_profile.group_name)
|
||||||
@@ -318,7 +323,8 @@ class FileIOTest(LFCliBase):
|
|||||||
self.wo_tg_profile.add_cx(cx)
|
self.wo_tg_profile.add_cx(cx)
|
||||||
else:
|
else:
|
||||||
print("Creating Write Only CXs")
|
print("Creating Write Only CXs")
|
||||||
self.wo_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.wo_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Creating Write Only test group")
|
print("Creating Write Only test group")
|
||||||
@@ -330,7 +336,8 @@ class FileIOTest(LFCliBase):
|
|||||||
if self.ro_tg_exists:
|
if self.ro_tg_exists:
|
||||||
if not self.ro_tg_cx_exists:
|
if not self.ro_tg_cx_exists:
|
||||||
print("Creating Read Only CXs")
|
print("Creating Read Only CXs")
|
||||||
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.ro_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Adding cxs to %s" % self.ro_tg_profile.group_name)
|
print("Adding cxs to %s" % self.ro_tg_profile.group_name)
|
||||||
@@ -338,7 +345,8 @@ class FileIOTest(LFCliBase):
|
|||||||
self.ro_tg_profile.add_cx(cx)
|
self.ro_tg_profile.add_cx(cx)
|
||||||
else:
|
else:
|
||||||
print("Creating Read Only CXs")
|
print("Creating Read Only CXs")
|
||||||
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.ro_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Creating Read Only test group")
|
print("Creating Read Only test group")
|
||||||
@@ -350,7 +358,8 @@ class FileIOTest(LFCliBase):
|
|||||||
if self.wo_tg_exists:
|
if self.wo_tg_exists:
|
||||||
if not self.wo_tg_cx_exists:
|
if not self.wo_tg_cx_exists:
|
||||||
print("Creating Write Only CXs")
|
print("Creating Write Only CXs")
|
||||||
self.wo_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.wo_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Adding cxs to %s" % self.wo_tg_profile.group_name)
|
print("Adding cxs to %s" % self.wo_tg_profile.group_name)
|
||||||
@@ -358,7 +367,8 @@ class FileIOTest(LFCliBase):
|
|||||||
self.wo_tg_profile.add_cx(cx)
|
self.wo_tg_profile.add_cx(cx)
|
||||||
else:
|
else:
|
||||||
print("Creating Write Only CXs")
|
print("Creating Write Only CXs")
|
||||||
self.wo_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.wo_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Creating Write Only test group")
|
print("Creating Write Only test group")
|
||||||
@@ -369,7 +379,8 @@ class FileIOTest(LFCliBase):
|
|||||||
if self.ro_tg_exists:
|
if self.ro_tg_exists:
|
||||||
if not self.ro_tg_cx_exists:
|
if not self.ro_tg_cx_exists:
|
||||||
print("Creating Read Only CXs")
|
print("Creating Read Only CXs")
|
||||||
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.ro_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Adding cxs to %s" % self.ro_tg_profile.group_name)
|
print("Adding cxs to %s" % self.ro_tg_profile.group_name)
|
||||||
@@ -377,7 +388,8 @@ class FileIOTest(LFCliBase):
|
|||||||
self.ro_tg_profile.add_cx(cx)
|
self.ro_tg_profile.add_cx(cx)
|
||||||
else:
|
else:
|
||||||
print("Creating Read Only CXs")
|
print("Creating Read Only CXs")
|
||||||
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.ro_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Creating Read Only test group")
|
print("Creating Read Only test group")
|
||||||
@@ -390,21 +402,25 @@ class FileIOTest(LFCliBase):
|
|||||||
else:
|
else:
|
||||||
if self.mode == "write":
|
if self.mode == "write":
|
||||||
print("Creating Write Only CXs")
|
print("Creating Write Only CXs")
|
||||||
self.wo_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.wo_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
elif self.mode == "read":
|
elif self.mode == "read":
|
||||||
print("Creating Read Only CXs")
|
print("Creating Read Only CXs")
|
||||||
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.ro_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
elif self.mode == "both":
|
elif self.mode == "both":
|
||||||
print("Creating Write Only CXs")
|
print("Creating Write Only CXs")
|
||||||
self.wo_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.wo_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
print("Creating Read Only CXs")
|
print("Creating Read Only CXs")
|
||||||
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
self.ro_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||||
|
sleep_time=.5, debug_=self.debug,
|
||||||
suppress_related_commands_=None)
|
suppress_related_commands_=None)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Uknown mode used, must be (read, write, both)")
|
raise ValueError("Unknown mode used, must be (read, write, both)")
|
||||||
else:
|
else:
|
||||||
raise ValueError("Mode must be set (read, write, both)")
|
raise ValueError("Mode must be set (read, write, both)")
|
||||||
|
|
||||||
@@ -553,6 +569,19 @@ Generic command layout:
|
|||||||
|
|
||||||
./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13
|
./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13
|
||||||
--netmask 255.255.255.0 --gateway 192.168.92.1
|
--netmask 255.255.255.0 --gateway 192.168.92.1
|
||||||
|
|
||||||
|
./test_fileio.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans
|
||||||
|
--use_ports eth1#0,eth1#1,eth1#2 --connections_per_port 2 --mode write
|
||||||
|
|
||||||
|
./test_fileio.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans
|
||||||
|
--first_mvlan_ip 10.40.3.100 --netmask 255.255.240.0 --gateway 10.40.0.1
|
||||||
|
--use_test_groups --write_only_test_group test_wo --read_only_test_group test_ro
|
||||||
|
--add_to_group test_wo --cxs test_wo0000,test_wo0001,test_wo0002
|
||||||
|
|
||||||
|
./test_fileio.py --radio 1.wiphy0 --test_duration 1m --macvlan_parent eth1 --num_ports 3 --use_macvlans
|
||||||
|
--use_ports eth1#0=10.40.3.103,eth1#1,eth1#2 --connections_per_port 2
|
||||||
|
--netmask 255.255.240.0 --gateway 10.40.0.1
|
||||||
|
|
||||||
''')
|
''')
|
||||||
parser.add_argument('--num_stations', help='Number of stations to create', default=0)
|
parser.add_argument('--num_stations', help='Number of stations to create', default=0)
|
||||||
parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2')
|
parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2')
|
||||||
@@ -576,9 +605,15 @@ Generic command layout:
|
|||||||
default="AUTO")
|
default="AUTO")
|
||||||
parser.add_argument('--server_mount', help='--server_mount The server to mount, ex: 192.168.100.5/exports/test1',
|
parser.add_argument('--server_mount', help='--server_mount The server to mount, ex: 192.168.100.5/exports/test1',
|
||||||
default="10.40.0.1:/var/tmp/test")
|
default="10.40.0.1:/var/tmp/test")
|
||||||
|
|
||||||
parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', default=None)
|
parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', default=None)
|
||||||
parser.add_argument('--first_port', help='specifies name of first port to be used', default=None)
|
parser.add_argument('--first_port', help='specifies name of first port to be used', default=None)
|
||||||
parser.add_argument('--num_ports', help='number of ports to create', default=1)
|
parser.add_argument('--num_ports', help='number of ports to create', default=1)
|
||||||
|
parser.add_argument('--connections_per_port', help='specifies number of connections to be used per port', default=1,
|
||||||
|
type=int)
|
||||||
|
parser.add_argument('--use_ports', help='list of comma separated ports to use with ips, \'=\' separates name and ip'
|
||||||
|
'{ port_name1=ip_addr1,port_name1=ip_addr2 }. '
|
||||||
|
'Ports without ips will be left alone', default=None)
|
||||||
parser.add_argument('--use_macvlans', help='will create macvlans', action='store_true', default=False)
|
parser.add_argument('--use_macvlans', help='will create macvlans', action='store_true', default=False)
|
||||||
parser.add_argument('--first_mvlan_ip', help='specifies first static ip address to be used or dhcp', default=None)
|
parser.add_argument('--first_mvlan_ip', help='specifies first static ip address to be used or dhcp', default=None)
|
||||||
parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None)
|
parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None)
|
||||||
@@ -588,12 +623,11 @@ Generic command layout:
|
|||||||
parser.add_argument('--read_only_test_group', help='specifies name to use for read only test group', default=None)
|
parser.add_argument('--read_only_test_group', help='specifies name to use for read only test group', default=None)
|
||||||
parser.add_argument('--write_only_test_group', help='specifies name to use for write only test group', default=None)
|
parser.add_argument('--write_only_test_group', help='specifies name to use for write only test group', default=None)
|
||||||
parser.add_argument('--mode', help='write,read,both', default='both', type=str)
|
parser.add_argument('--mode', help='write,read,both', default='both', type=str)
|
||||||
parser.add_argument('--use_ports', help='list of comma separated ports to use with ips, \'=\' separates name and ip'
|
|
||||||
'{ port_name1=ip_addr1,port_name1=ip_addr2 }', default=None)
|
|
||||||
tg_group = parser.add_mutually_exclusive_group()
|
tg_group = parser.add_mutually_exclusive_group()
|
||||||
tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None)
|
tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None)
|
||||||
tg_group.add_argument('--del_from_group', help='name of test group to delete cxs from', default=None)
|
tg_group.add_argument('--del_from_group', help='name of test group to delete cxs from', default=None)
|
||||||
parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group', default=None)
|
parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group'
|
||||||
|
, default=None)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
update_group_args = {
|
update_group_args = {
|
||||||
@@ -647,7 +681,10 @@ Generic command layout:
|
|||||||
temp_list = args.use_ports.split(',')
|
temp_list = args.use_ports.split(',')
|
||||||
for port in temp_list:
|
for port in temp_list:
|
||||||
port_list.append(port.split('=')[0])
|
port_list.append(port.split('=')[0])
|
||||||
|
if '=' in port:
|
||||||
ip_list.append(port.split('=')[1])
|
ip_list.append(port.split('=')[1])
|
||||||
|
else:
|
||||||
|
ip_list.append(0)
|
||||||
|
|
||||||
if len(port_list) != len(ip_list):
|
if len(port_list) != len(ip_list):
|
||||||
raise ValueError(temp_list, " ports must have matching ip addresses!")
|
raise ValueError(temp_list, " ports must have matching ip addresses!")
|
||||||
@@ -695,16 +732,16 @@ Generic command layout:
|
|||||||
write_only_test_group=args.write_only_test_group,
|
write_only_test_group=args.write_only_test_group,
|
||||||
read_only_test_group=args.read_only_test_group,
|
read_only_test_group=args.read_only_test_group,
|
||||||
update_group_args = update_group_args,
|
update_group_args = update_group_args,
|
||||||
|
connections_per_port=args.connections_per_port,
|
||||||
mode=args.mode
|
mode=args.mode
|
||||||
# want a mount options param
|
# want a mount options param
|
||||||
)
|
)
|
||||||
|
|
||||||
ip_test.cleanup(port_list)
|
ip_test.cleanup(port_list)
|
||||||
ip_test.build()
|
ip_test.build()
|
||||||
# exit(1)
|
|
||||||
if not ip_test.passes():
|
if not ip_test.passes():
|
||||||
print(ip_test.get_fail_message())
|
print(ip_test.get_fail_message())
|
||||||
# ip_test.start(False, False)
|
ip_test.start(False, False)
|
||||||
ip_test.stop()
|
ip_test.stop()
|
||||||
if not ip_test.passes():
|
if not ip_test.passes():
|
||||||
print(ip_test.get_fail_message())
|
print(ip_test.get_fail_message())
|
||||||
|
|||||||
@@ -21,34 +21,41 @@ import pprint
|
|||||||
|
|
||||||
class IPv4Test(LFCliBase):
|
class IPv4Test(LFCliBase):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
ssid,
|
_ssid=None,
|
||||||
security,
|
_security=None,
|
||||||
password,
|
_password=None,
|
||||||
host,
|
_host=None,
|
||||||
port,
|
_port=None,
|
||||||
sta_list=None,
|
_sta_list=None,
|
||||||
number_template="00000",
|
_number_template="00000",
|
||||||
radio="wiphy0",
|
_radio="wiphy0",
|
||||||
|
_proxy_str=None,
|
||||||
_debug_on=False,
|
_debug_on=False,
|
||||||
_exit_on_error=False,
|
_exit_on_error=False,
|
||||||
_exit_on_fail=False):
|
_exit_on_fail=False):
|
||||||
super().__init__(host,
|
super().__init__(_host,
|
||||||
port,
|
_port,
|
||||||
|
_proxy_str=_proxy_str,
|
||||||
|
_local_realm=realm.Realm(lfclient_host=_host,
|
||||||
|
lfclient_port=_port,
|
||||||
|
halt_on_error_=_exit_on_error,
|
||||||
|
_exit_on_error=_exit_on_error,
|
||||||
|
_exit_on_fail=_exit_on_fail,
|
||||||
|
_proxy_str=_proxy_str,
|
||||||
|
debug_=_debug_on),
|
||||||
_debug=_debug_on,
|
_debug=_debug_on,
|
||||||
_halt_on_error=_exit_on_error,
|
_halt_on_error=_exit_on_error,
|
||||||
_exit_on_fail=_exit_on_fail)
|
_exit_on_fail=_exit_on_fail)
|
||||||
self.host = host
|
self.host = _host
|
||||||
self.port = port
|
self.port = _port
|
||||||
self.ssid = ssid
|
self.ssid = _ssid
|
||||||
self.security = security
|
self.security = _security
|
||||||
self.password = password
|
self.password = _password
|
||||||
self.sta_list = sta_list
|
self.sta_list = _sta_list
|
||||||
self.radio = radio
|
self.radio = _radio
|
||||||
self.timeout = 120
|
self.timeout = 120
|
||||||
self.number_template = number_template
|
self.number_template = _number_template
|
||||||
self.debug = _debug_on
|
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 = self.local_realm.new_station_profile()
|
||||||
self.station_profile.lfclient_url = self.lfclient_url
|
self.station_profile.lfclient_url = self.lfclient_url
|
||||||
self.station_profile.ssid = self.ssid
|
self.station_profile.ssid = self.ssid
|
||||||
@@ -137,7 +144,7 @@ def main():
|
|||||||
description='''\
|
description='''\
|
||||||
test_ipv4_connection.py
|
test_ipv4_connection.py
|
||||||
--------------------
|
--------------------
|
||||||
Generic command example:
|
Command example:
|
||||||
./test_ipv4_connection.py
|
./test_ipv4_connection.py
|
||||||
--upstream_port eth1
|
--upstream_port eth1
|
||||||
--radio wiphy0
|
--radio wiphy0
|
||||||
@@ -151,6 +158,9 @@ Generic command example:
|
|||||||
required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True)
|
required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
#if args.debug:
|
||||||
|
# pprint.pprint(args)
|
||||||
|
# time.sleep(5)
|
||||||
if (args.radio is None):
|
if (args.radio is None):
|
||||||
raise ValueError("--radio required")
|
raise ValueError("--radio required")
|
||||||
|
|
||||||
@@ -164,14 +174,18 @@ Generic command example:
|
|||||||
end_id=num_sta-1,
|
end_id=num_sta-1,
|
||||||
padding_number=10000,
|
padding_number=10000,
|
||||||
radio=args.radio)
|
radio=args.radio)
|
||||||
|
if args.debug:
|
||||||
ip_test = IPv4Test(host=args.mgr, port=args.mgr_port,
|
print("args.proxy: %s" % args.proxy)
|
||||||
ssid=args.ssid,
|
ip_test = IPv4Test(_host=args.mgr,
|
||||||
password=args.passwd,
|
_port=args.mgr_port,
|
||||||
security=args.security,
|
_ssid=args.ssid,
|
||||||
sta_list=station_list,
|
_password=args.passwd,
|
||||||
radio=args.radio,
|
_security=args.security,
|
||||||
|
_sta_list=station_list,
|
||||||
|
_radio=args.radio,
|
||||||
|
_proxy_str=args.proxy,
|
||||||
_debug_on=args.debug)
|
_debug_on=args.debug)
|
||||||
|
|
||||||
ip_test.cleanup(station_list)
|
ip_test.cleanup(station_list)
|
||||||
ip_test.build()
|
ip_test.build()
|
||||||
if not ip_test.passes():
|
if not ip_test.passes():
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import pprint
|
|||||||
|
|
||||||
|
|
||||||
class IPv6Test(LFCliBase):
|
class IPv6Test(LFCliBase):
|
||||||
def __init__(self, ssid, security, password, sta_list=None, num_stations=0, prefix="00000", host="localhost", port=8080,
|
def __init__(self, ssid, security, password,ap=None, mode=0, sta_list=None, num_stations=0, prefix="00000", host="localhost", port=8080,
|
||||||
_debug_on=False, timeout=120, radio="wiphy0",
|
_debug_on=False, timeout=120, radio="wiphy0",
|
||||||
_exit_on_error=False,
|
_exit_on_error=False,
|
||||||
_exit_on_fail=False,
|
_exit_on_fail=False,
|
||||||
@@ -30,6 +30,8 @@ class IPv6Test(LFCliBase):
|
|||||||
self.radio = radio
|
self.radio = radio
|
||||||
self.security = security
|
self.security = security
|
||||||
self.password = password
|
self.password = password
|
||||||
|
self.ap=ap
|
||||||
|
self.mode=mode
|
||||||
self.num_stations = num_stations
|
self.num_stations = num_stations
|
||||||
self.sta_list = sta_list
|
self.sta_list = sta_list
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
@@ -41,12 +43,16 @@ class IPv6Test(LFCliBase):
|
|||||||
|
|
||||||
self.station_profile.lfclient_url = self.lfclient_url
|
self.station_profile.lfclient_url = self.lfclient_url
|
||||||
self.station_profile.ssid = self.ssid
|
self.station_profile.ssid = self.ssid
|
||||||
self.station_profile.ssid_pass = self.password,
|
self.station_profile.ssid_pass = self.password
|
||||||
|
if mode is not None:
|
||||||
|
self.station_profile.mode = mode
|
||||||
self.station_profile.security = self.security
|
self.station_profile.security = self.security
|
||||||
self.station_profile.number_template_ = self.number_template
|
self.station_profile.number_template_ = self.number_template
|
||||||
self.station_profile.mode = 0
|
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
|
if self.ap is not None:
|
||||||
|
self.station_profile.set_command_param("add_sta", "ap", self.ap)
|
||||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||||
self.station_profile.set_number_template(self.prefix)
|
self.station_profile.set_number_template(self.prefix)
|
||||||
print("Creating stations")
|
print("Creating stations")
|
||||||
@@ -104,7 +110,6 @@ class IPv6Test(LFCliBase):
|
|||||||
return self.passes()
|
return self.passes()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
# Bring stations down
|
|
||||||
self.station_profile.admin_down()
|
self.station_profile.admin_down()
|
||||||
|
|
||||||
def cleanup(self, sta_list):
|
def cleanup(self, sta_list):
|
||||||
@@ -125,26 +130,39 @@ def main():
|
|||||||
|
|
||||||
description='''\
|
description='''\
|
||||||
test_ipv6_connection.py:
|
test_ipv6_connection.py:
|
||||||
--------------------
|
--------------------------------------------------
|
||||||
Generic command example:
|
Generic command example:
|
||||||
python3 ./test_ipv6_connection.py --upstream_port eth1 \\
|
python3 ./test_ipv6_connection.py
|
||||||
--radio wiphy0 \\
|
--upstream_port eth1
|
||||||
--num_stations 3 \\
|
--radio wiphy0
|
||||||
--security {open|wep|wpa|wpa2|wpa3} \\
|
--num_stations 3
|
||||||
--ssid netgear \\
|
--proxy
|
||||||
--passwd admin123 \\
|
--security {open|wep|wpa|wpa2|wpa3}
|
||||||
--dest 10.40.0.1 \\
|
--ssid netgear
|
||||||
--test_duration 2m \\
|
--passwd admin123
|
||||||
--interval 1s \\
|
--mode 1
|
||||||
-- timeout 120 \\
|
--ap "00:0e:8e:78:e1:76"
|
||||||
|
--test_id
|
||||||
|
-- timeout 120
|
||||||
--debug
|
--debug
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
|
||||||
optional = parser.add_argument_group('optional arguments')
|
required = None
|
||||||
required = parser.add_argument_group('required arguments')
|
for agroup in parser._action_groups:
|
||||||
required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True)
|
if agroup.title == "required arguments":
|
||||||
parser.add_argument('--timeout', help='--timeout sets the length of time to wait until a connection is successful', default=30)
|
required = agroup
|
||||||
|
#if required is not None:
|
||||||
|
|
||||||
|
optional = None
|
||||||
|
for agroup in parser._action_groups:
|
||||||
|
if agroup.title == "optional arguments":
|
||||||
|
optional = agroup
|
||||||
|
|
||||||
|
if optional is not None:
|
||||||
|
optional.add_argument("--ap", help="Add BSSID of access point to connect to")
|
||||||
|
optional.add_argument('--mode', help=LFCliBase.Help_Mode)
|
||||||
|
optional.add_argument('--timeout', help='--timeout sets the length of time to wait until a connection is successful', default=30)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
num_sta=2
|
num_sta=2
|
||||||
@@ -159,6 +177,8 @@ python3 ./test_ipv6_connection.py --upstream_port eth1 \\
|
|||||||
ssid=args.ssid,
|
ssid=args.ssid,
|
||||||
password=args.passwd,
|
password=args.passwd,
|
||||||
security=args.security,
|
security=args.security,
|
||||||
|
ap=args.ap,
|
||||||
|
mode=args.mode,
|
||||||
sta_list=station_list,
|
sta_list=station_list,
|
||||||
_debug_on=args.debug)
|
_debug_on=args.debug)
|
||||||
ipv6_test.cleanup(station_list)
|
ipv6_test.cleanup(station_list)
|
||||||
|
|||||||
Reference in New Issue
Block a user