Fix linters issues and enable tox/zuul linters job as gate
Fix below linters issues E001 Trailing Whitespace E003 Indent not multiple of 4 E006 Line too long E011 Then keyword is not on same line as if or elif keyword E020 Function declaration not in format ^function name {$ E040 Syntax error: syntax error near unexpected token `;' ignore cases are added in tox setup E006 Line too long E010: do not on the same line as for Story: 2003368 Task: 24427 Change-Id: I6acf64271a4e608be8bc8fa965cac4fa31e0c05b Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
82e851d651
commit
fedb95ba79
@ -4,3 +4,7 @@
|
|||||||
jobs:
|
jobs:
|
||||||
- openstack-tox-pep8:
|
- openstack-tox-pep8:
|
||||||
voting: false
|
voting: false
|
||||||
|
- openstack-tox-linters
|
||||||
|
gate:
|
||||||
|
jobs:
|
||||||
|
- openstack-tox-linters
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
# -o /pxeboot/pxelinux.cfg/01-08-00-27-3e-f8-05 -b sda -r sda -t -c ttyS0,115200
|
# -o /pxeboot/pxelinux.cfg/01-08-00-27-3e-f8-05 -b sda -r sda -t -c ttyS0,115200
|
||||||
#
|
#
|
||||||
|
|
||||||
function usage()
|
function usage {
|
||||||
{
|
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
$0: This utility is used to generate a node-specific pxeboot.cfg file
|
$0: This utility is used to generate a node-specific pxeboot.cfg file
|
||||||
|
|
||||||
@ -37,33 +36,28 @@ EOF
|
|||||||
|
|
||||||
declare text_install="inst.text"
|
declare text_install="inst.text"
|
||||||
|
|
||||||
function generate_config()
|
function generate_config {
|
||||||
{
|
|
||||||
input=$1
|
input=$1
|
||||||
output=$2
|
output=$2
|
||||||
|
|
||||||
if [ ! -f "$input" ]
|
if [ ! -f "$input" ]; then
|
||||||
then
|
|
||||||
logger --stderr -t $0 "Error: Input file $input does not exist"
|
logger --stderr -t $0 "Error: Input file $input does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -w $(dirname $output) ]
|
if [ ! -w $(dirname $output) ]; then
|
||||||
then
|
|
||||||
logger --stderr -t $0 "Error: Destination directory $(dirname $output) not writeable"
|
logger --stderr -t $0 "Error: Destination directory $(dirname $output) not writeable"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e $output -a ! -w $output ]
|
if [ -e $output -a ! -w $output ]; then
|
||||||
then
|
|
||||||
logger --stderr -t $0 "Error: Destination file $output_file_efi exists and is not writeable"
|
logger --stderr -t $0 "Error: Destination file $output_file_efi exists and is not writeable"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -e "s#xxxAPPEND_OPTIONSxxx#$APPEND_OPTIONS#" $input > $output
|
sed -e "s#xxxAPPEND_OPTIONSxxx#$APPEND_OPTIONS#" $input > $output
|
||||||
|
|
||||||
if [ $? -ne 0 -o ! -f $output ]
|
if [ $? -ne 0 -o ! -f $output ]; then
|
||||||
then
|
|
||||||
logger --stderr -t $0 "Error: Failed to generate pxeboot file $output"
|
logger --stderr -t $0 "Error: Failed to generate pxeboot file $output"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -130,8 +124,7 @@ if [ -z "$input_file" \
|
|||||||
-o -z "$output_file" \
|
-o -z "$output_file" \
|
||||||
-o -z "$output_file_efi" \
|
-o -z "$output_file_efi" \
|
||||||
-o -z "$boot_device" \
|
-o -z "$boot_device" \
|
||||||
-o -z "$rootfs_device" ]
|
-o -z "$rootfs_device" ]; then
|
||||||
then
|
|
||||||
logger --stderr -t $0 "Error: One or more mandatory options not specified: $@"
|
logger --stderr -t $0 "Error: One or more mandatory options not specified: $@"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
@ -139,18 +132,15 @@ fi
|
|||||||
|
|
||||||
APPEND_OPTIONS="boot_device=$boot_device rootfs_device=$rootfs_device"
|
APPEND_OPTIONS="boot_device=$boot_device rootfs_device=$rootfs_device"
|
||||||
|
|
||||||
if [ -n "$text_install" ]
|
if [ -n "$text_install" ]; then
|
||||||
then
|
|
||||||
APPEND_OPTIONS="$APPEND_OPTIONS $text_install"
|
APPEND_OPTIONS="$APPEND_OPTIONS $text_install"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$console" ]
|
if [ -n "$console" ]; then
|
||||||
then
|
|
||||||
APPEND_OPTIONS="$APPEND_OPTIONS console=$console"
|
APPEND_OPTIONS="$APPEND_OPTIONS console=$console"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$tisnotify" ]
|
if [ -n "$tisnotify" ]; then
|
||||||
then
|
|
||||||
APPEND_OPTIONS="$APPEND_OPTIONS tisnotify=$tisnotify"
|
APPEND_OPTIONS="$APPEND_OPTIONS tisnotify=$tisnotify"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -160,13 +150,11 @@ APPEND_OPTIONS="$APPEND_OPTIONS inst.gpt"
|
|||||||
# Add k8s support for namespaces
|
# Add k8s support for namespaces
|
||||||
APPEND_OPTIONS="$APPEND_OPTIONS user_namespace.enable=1"
|
APPEND_OPTIONS="$APPEND_OPTIONS user_namespace.enable=1"
|
||||||
|
|
||||||
if [ -n "$security_profile" ]
|
if [ -n "$security_profile" ]; then
|
||||||
then
|
|
||||||
APPEND_OPTIONS="$APPEND_OPTIONS security_profile=$security_profile"
|
APPEND_OPTIONS="$APPEND_OPTIONS security_profile=$security_profile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$kernal_extra_args" ]
|
if [ -n "$kernal_extra_args" ]; then
|
||||||
then
|
|
||||||
APPEND_OPTIONS="$APPEND_OPTIONS $kernal_extra_args"
|
APPEND_OPTIONS="$APPEND_OPTIONS $kernal_extra_args"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -174,8 +162,7 @@ generate_config $input_file $output_file
|
|||||||
|
|
||||||
# for extended security profile UEFI boot only,
|
# for extended security profile UEFI boot only,
|
||||||
# a tboot option will be passed to target boot option menu
|
# a tboot option will be passed to target boot option menu
|
||||||
if [ "$security_profile" == "extended" -a -n "$tboot" ]
|
if [ "$security_profile" == "extended" -a -n "$tboot" ]; then
|
||||||
then
|
|
||||||
APPEND_OPTIONS="$APPEND_OPTIONS tboot=$tboot"
|
APPEND_OPTIONS="$APPEND_OPTIONS tboot=$tboot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ NOT_RUNNING=7
|
|||||||
|
|
||||||
trap ctrl_c INT
|
trap ctrl_c INT
|
||||||
|
|
||||||
function ctrl_c(){
|
function ctrl_c {
|
||||||
echo "Exiting ..."
|
echo "Exiting ..."
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
@ -201,12 +201,16 @@ while true; do
|
|||||||
# parent process is 1. If the parent process ID is not 1 then the process in question is a child proceess
|
# parent process is 1. If the parent process ID is not 1 then the process in question is a child proceess
|
||||||
# and we do not care about its memory usage (for the purposes of this specific script). The continue
|
# and we do not care about its memory usage (for the purposes of this specific script). The continue
|
||||||
# statement will return us to the for-loop and begin running for the next pid.
|
# statement will return us to the for-loop and begin running for the next pid.
|
||||||
if [ -f "/proc/$pid/status" ] && [ "$(awk '$0 ~ "PPid:" {print $2}' /proc/"$pid"/status)" -ne "1" ]; then continue; fi
|
if [ -f "/proc/$pid/status" ] && [ "$(awk '$0 ~ "PPid:" {print $2}' /proc/"$pid"/status)" -ne "1" ];then
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
# This checks that neither rssCurrent nor pss have empty values due to a child process being generated
|
# This checks that neither rssCurrent nor pss have empty values due to a child process being generated
|
||||||
# and then killed off before its values could be read. Root occasionally generates a child process of
|
# and then killed off before its values could be read. Root occasionally generates a child process of
|
||||||
# one of the monitored commands so the above if-statement doesn't exclude it because the PPID is 1.
|
# one of the monitored commands so the above if-statement doesn't exclude it because the PPID is 1.
|
||||||
if [ -z "$rssCurrent" ] || [ -z "$pss" ]; then continue; fi
|
if [ -z "$rssCurrent" ] || [ -z "$pss" ]; then
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
# Sets initial values for PSS and RSS. NA is set instead of 0 because using numbers could lead to false
|
# Sets initial values for PSS and RSS. NA is set instead of 0 because using numbers could lead to false
|
||||||
# or inaccurate information. It also previously allowed one to see when child processes were spawned.
|
# or inaccurate information. It also previously allowed one to see when child processes were spawned.
|
||||||
@ -241,12 +245,18 @@ while true; do
|
|||||||
# Calculates the changes in PSS and RSS usage over time. If this is the first run and there is no
|
# Calculates the changes in PSS and RSS usage over time. If this is the first run and there is no
|
||||||
# previous value with which to compare against, delta is set to 0, where delta is the change over
|
# previous value with which to compare against, delta is set to 0, where delta is the change over
|
||||||
# time.
|
# time.
|
||||||
if [ "${lastP[pid]}" = "NA" ]; then changeP[$pid]=0; deltaP=0.000;
|
if [ "${lastP[pid]}" = "NA" ]; then
|
||||||
else changeP[pid]="$((changeP[$pid] + $pss - lastP[$pid]))"; deltaP=$(awk -v chP="${changeP[$pid]}" -v hrs="${hours}" -v t="${period}" 'BEGIN {printf "%.3f", (chP/(hrs*t))*3600; exit(0)}');
|
changeP[$pid]=0; deltaP=0.000;
|
||||||
|
else
|
||||||
|
changeP[pid]="$((changeP[$pid] + $pss - lastP[$pid]))";
|
||||||
|
deltaP=$(awk -v chP="${changeP[$pid]}" -v hrs="${hours}" -v t="${period}" 'BEGIN {printf "%.3f", (chP/(hrs*t))*3600; exit(0)}');
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${lastR[pid]}" = "NA" ]; then changeR[$pid]=0; deltaR=0.000;
|
if [ "${lastR[pid]}" = "NA" ]; then
|
||||||
else changeR[pid]="$((changeR[$pid] + rss[$pid] - lastR[$pid]))"; deltaR=$(awk -v chR="${changeR[$pid]}" -v hrs="${hours}" -v t="${period}" 'BEGIN {printf "%.3f", (chR/(hrs*t))*3600; exit(0)}');
|
changeR[$pid]=0; deltaR=0.000;
|
||||||
|
else
|
||||||
|
changeR[pid]="$((changeR[$pid] + rss[$pid] - lastR[$pid]))";
|
||||||
|
deltaR=$(awk -v chR="${changeR[$pid]}" -v hrs="${hours}" -v t="${period}" 'BEGIN {printf "%.3f", (chR/(hrs*t))*3600; exit(0)}');
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The below if-else block seeks to determine gradual sustained patterns of RSS usage over time to determine if the memory usage is gradually
|
# The below if-else block seeks to determine gradual sustained patterns of RSS usage over time to determine if the memory usage is gradually
|
||||||
@ -336,19 +346,21 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${trend[pid]}" -ge "3" ]; then pattern[pid]="${s1[pid]}"; else pattern[pid]="none"; fi # Sets the trend variable for printing if a trend exists
|
if [ "${trend[pid]}" -ge "3" ]; then
|
||||||
|
pattern[pid]="${s1[pid]}";
|
||||||
|
else
|
||||||
|
pattern[pid]="none";
|
||||||
|
fi # Sets the trend variable for printing if a trend exists
|
||||||
printf "\n%15s | %8s | %2s | %10s | %8s kB/h | %8s | %8s | %8s | %8s kB/h | %8s | %8s | %8s |" \
|
printf "\n%15s | %8s | %2s | %10s | %8s kB/h | %8s | %8s | %8s | %8s kB/h | %8s | %8s | %8s |" \
|
||||||
$cmd $pid "${leak[pid]}" "${pattern[pid]}" $deltaR ${rss[pid]} ${firstR[pid]} ${lastR[pid]} $deltaP $pss ${firstP[pid]} ${lastP[pid]} >&1
|
$cmd $pid "${leak[pid]}" "${pattern[pid]}" $deltaR ${rss[pid]} ${firstR[pid]} ${lastR[pid]} $deltaP $pss ${firstP[pid]} ${lastP[pid]} >&1
|
||||||
|
|
||||||
lastP[pid]="$pss"
|
lastP[pid]="$pss"
|
||||||
leak[pid]="" # Resets the indicator in the 'Leak' column
|
leak[pid]="" # Resets the indicator in the 'Leak' column
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$leakFlag" -eq "1" ]; then memLeak leaking[@]; fi # Calls the mem leak function if flag is set
|
if [ "$leakFlag" -eq "1" ]; then
|
||||||
|
memLeak leaking[@];
|
||||||
|
fi # Calls the mem leak function if flag is set
|
||||||
unset leaking[@] # Clear the array holding PIDs of processes with potential leaks
|
unset leaking[@] # Clear the array holding PIDs of processes with potential leaks
|
||||||
let leakFlag=0
|
let leakFlag=0
|
||||||
let hours+=1 # Hour count[pid]er used in calculating delta
|
let hours+=1 # Hour count[pid]er used in calculating delta
|
||||||
|
@ -30,24 +30,20 @@
|
|||||||
[ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
|
[ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
if [ "$VERBOSE" != no ]
|
if [ "$VERBOSE" != no ] ;then
|
||||||
then
|
|
||||||
echo "System time was `date`."
|
echo "System time was `date`."
|
||||||
echo "Setting the System Clock using the Hardware Clock as reference..."
|
echo "Setting the System Clock using the Hardware Clock as reference..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$HWCLOCKACCESS" != no ]
|
if [ "$HWCLOCKACCESS" != no ] ;then
|
||||||
then
|
if [ -z "$TZ" ] ;then
|
||||||
if [ -z "$TZ" ]
|
|
||||||
then
|
|
||||||
hwclock $tz --hctosys
|
hwclock $tz --hctosys
|
||||||
else
|
else
|
||||||
TZ="$TZ" hwclock $tz --hctosys
|
TZ="$TZ" hwclock $tz --hctosys
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$VERBOSE" != no ]
|
if [ "$VERBOSE" != no ]; then
|
||||||
then
|
|
||||||
echo "System Clock set. System local time is now `date`."
|
echo "System Clock set. System local time is now `date`."
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -59,23 +55,19 @@ case "$1" in
|
|||||||
# WARNING: If you disable this, any changes to the system
|
# WARNING: If you disable this, any changes to the system
|
||||||
# clock will not be carried across reboots.
|
# clock will not be carried across reboots.
|
||||||
#
|
#
|
||||||
if [ "$VERBOSE" != no ]
|
if [ "$VERBOSE" != no ]; then
|
||||||
then
|
|
||||||
echo "Saving the System Clock time to the Hardware Clock..."
|
echo "Saving the System Clock time to the Hardware Clock..."
|
||||||
fi
|
fi
|
||||||
if [ "$HWCLOCKACCESS" != no ]
|
if [ "$HWCLOCKACCESS" != no ]; then
|
||||||
then
|
|
||||||
hwclock $tz --systohc
|
hwclock $tz --systohc
|
||||||
fi
|
fi
|
||||||
if [ "$VERBOSE" != no ]
|
if [ "$VERBOSE" != no ]; then
|
||||||
then
|
|
||||||
echo "Hardware Clock updated to `date`."
|
echo "Hardware Clock updated to `date`."
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
show)
|
show)
|
||||||
if [ "$HWCLOCKACCESS" != no ]
|
if [ "$HWCLOCKACCESS" != no ]; then
|
||||||
then
|
|
||||||
hwclock $tz --show
|
hwclock $tz --show
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -20,7 +20,7 @@ GENERIC_ERROR=1
|
|||||||
|
|
||||||
NOVA_GOENABLED_TAG=${NOVA_GOENABLED_TAG:-"NOVA_GOENABLED"}
|
NOVA_GOENABLED_TAG=${NOVA_GOENABLED_TAG:-"NOVA_GOENABLED"}
|
||||||
|
|
||||||
function log
|
log()
|
||||||
{
|
{
|
||||||
logger -p local1.info -t ${NOVA_GOENABLED_TAG} $@
|
logger -p local1.info -t ${NOVA_GOENABLED_TAG} $@
|
||||||
}
|
}
|
||||||
@ -32,22 +32,18 @@ NOVA_ADVANCE_ENABLED="/var/run/.nova_timer_advance_enabled"
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
if [ -e ${VOLATILE_COMPUTE_CONFIG_COMPLETE} ] && [ ! -e ${VOLATILE_DISABLE_COMPUTE_SERVICES} ]
|
if [ -e ${VOLATILE_COMPUTE_CONFIG_COMPLETE} ] && [ ! -e ${VOLATILE_DISABLE_COMPUTE_SERVICES} ]; then
|
||||||
then
|
|
||||||
log "Start"
|
log "Start"
|
||||||
|
|
||||||
if [ -e ${NOVA_INIT_FAILED} ]
|
if [ -e ${NOVA_INIT_FAILED} ]; then
|
||||||
then
|
|
||||||
log "Nova-Init check FAILED"
|
log "Nova-Init check FAILED"
|
||||||
exit ${GENERIC_ERROR}
|
exit ${GENERIC_ERROR}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "Nova-Init check PASSED"
|
log "Nova-Init check PASSED"
|
||||||
|
|
||||||
while :
|
while [ true ]; do
|
||||||
do
|
if [ -e ${NOVA_ADVANCE_ENABLED} ]; then
|
||||||
if [ -e ${NOVA_ADVANCE_ENABLED} ]
|
|
||||||
then
|
|
||||||
log "Nova setup timer advance PASSED"
|
log "Nova setup timer advance PASSED"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -55,10 +51,8 @@ case "$1" in
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
while :
|
while [ true ]; do
|
||||||
do
|
if [ -e ${NOVA_COMPUTE_ENABLED} ]; then
|
||||||
if [ -e ${NOVA_COMPUTE_ENABLED} ]
|
|
||||||
then
|
|
||||||
log "Nova-Compute service enabled PASSED"
|
log "Nova-Compute service enabled PASSED"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -9,7 +9,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
|
|||||||
|
|
||||||
NAME=$(basename $0)
|
NAME=$(basename $0)
|
||||||
|
|
||||||
function LOG()
|
LOG()
|
||||||
{
|
{
|
||||||
logger "$NAME: $*"
|
logger "$NAME: $*"
|
||||||
}
|
}
|
||||||
@ -47,8 +47,7 @@ REASONS=$(virt-host-validate qemu 2>/dev/null | grep -w -e FAIL)
|
|||||||
# - on emulated systems such as VirtualBox or QEMU, vmx is not required
|
# - on emulated systems such as VirtualBox or QEMU, vmx is not required
|
||||||
# - if vmx is enabled on QEMU, it can also support nested virtualization
|
# - if vmx is enabled on QEMU, it can also support nested virtualization
|
||||||
|
|
||||||
if [ "${host_type}" = "physical" ] && [ "${hardware_virt_supported}" == "false" ]
|
if [ "${host_type}" = "physical" ] && [ "${hardware_virt_supported}" == "false" ]; then
|
||||||
then
|
|
||||||
LOG "Virtualization is not supported: ${OPTS}. Failing goenabled check."
|
LOG "Virtualization is not supported: ${OPTS}. Failing goenabled check."
|
||||||
LOG "Failure reasons:"$'\n'"${REASONS}"
|
LOG "Failure reasons:"$'\n'"${REASONS}"
|
||||||
exit 1
|
exit 1
|
||||||
|
5
tox.ini
5
tox.ini
@ -14,6 +14,9 @@ deps = -r{toxinidir}/test-requirements.txt
|
|||||||
|
|
||||||
[testenv:linters]
|
[testenv:linters]
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
|
#bashate ignore errors
|
||||||
|
#E010: do not on the same line as for
|
||||||
|
#E006 Line too long
|
||||||
commands =
|
commands =
|
||||||
bash -c "find {toxinidir} \
|
bash -c "find {toxinidir} \
|
||||||
-not \( -type d -name .?\* -prune \) \
|
-not \( -type d -name .?\* -prune \) \
|
||||||
@ -21,7 +24,7 @@ commands =
|
|||||||
-not -name \*~ \
|
-not -name \*~ \
|
||||||
-not -name \*.md \
|
-not -name \*.md \
|
||||||
-name \*.sh \
|
-name \*.sh \
|
||||||
-print0 | xargs -0 bashate -v"
|
-print0 | xargs -0 bashate -v -i E010,E006"
|
||||||
bash -c "find {toxinidir} \
|
bash -c "find {toxinidir} \
|
||||||
\( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \
|
\( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \
|
||||||
-o \( -name .tox -prune \) \
|
-o \( -name .tox -prune \) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user