Fixing linters errors E010, E011, E020, E041,E043, E003, E001,E042
Listed below are the errors which were fixed as well as the actions taken to fix them: E010: do not on the same line as for --> let do and for in the same line E011: then not on the same line as if or elif --> let then and if or elif in the same line E020: Function declaration not in format ^function name {$ --> fix the format to suit ^function name {$ E041: Usage of $[ for arithmetic is deprecated for $(( --> fix from $[ to $(( E043: arithmetic compound has inconsistent return semantics --> do not use +=, ++, -=, --; use value=value+? instead. E001: check that lines do not end with trailing whitespace --> delete trailing whitespace E003: ensure all indents are a multiple of 4 spaces --> add/delete spaces E042: local declaration hides errors --> let declaration and assignment in two lines. Listed below are test cases done which run one controller and one compute in KVMs Test-Install ---- success Related: https://review.openstack.org/#/c/600663/ https://review.openstack.org/#/c/601221/ Story: 2003360 Task: 26213 Change-Id: I3ece37db3a326ea58bd344f43beefcbbbd4f0ad4 Signed-off-by: SidneyAn <ran1.an@intel.com>
This commit is contained in:
parent
081cbf0240
commit
47ac546217
@ -21,18 +21,15 @@ LOG_PRIORITY=info
|
||||
TMPLOG=/tmp/${WHOAMI}.log
|
||||
|
||||
# LOG() - generates log and puts in temporary file
|
||||
function LOG()
|
||||
{
|
||||
function LOG {
|
||||
logger -t "${0##*/}[$$]" -p ${LOG_FACILITY}.${LOG_PRIORITY} "$@"
|
||||
echo "${0##*/}[$$]" "$@" >> ${TMPLOG}
|
||||
}
|
||||
function INFO()
|
||||
{
|
||||
function INFO {
|
||||
MSG="INFO"
|
||||
LOG "${MSG} $@"
|
||||
}
|
||||
function ERROR()
|
||||
{
|
||||
function ERROR {
|
||||
MSG="ERROR"
|
||||
LOG "${MSG} $@"
|
||||
}
|
||||
|
@ -26,8 +26,7 @@ LOG_DEBUG=1
|
||||
################################################################################
|
||||
# Affine all running tasks to the CPULIST provided in the first parameter.
|
||||
################################################################################
|
||||
function affine_tasks
|
||||
{
|
||||
function affine_tasks {
|
||||
local CPULIST=$1
|
||||
local PIDLIST
|
||||
local RET=0
|
||||
@ -73,23 +72,19 @@ function affine_tasks
|
||||
# On low latency compute reassign the per cpu threads rcuc, ksoftirq,
|
||||
# ktimersoftd to FIFO along with the specified priority
|
||||
PIDLIST=$( ps -e -p 2 |grep rcuc | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}
|
||||
do
|
||||
for PID in ${PIDLIST[@]}; do
|
||||
chrt -p -f 4 ${PID} 2>/dev/null
|
||||
done
|
||||
|
||||
PIDLIST=$( ps -e -p 2 |grep ksoftirq | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}
|
||||
do
|
||||
for PID in ${PIDLIST[@]}; do
|
||||
chrt -p -f 2 ${PID} 2>/dev/null
|
||||
done
|
||||
|
||||
PIDLIST=$( ps -e -p 2 |grep ktimersoftd | awk '{ print $1; }')
|
||||
for PID in ${PIDLIST[@]}
|
||||
do
|
||||
for PID in ${PIDLIST[@]}; do
|
||||
chrt -p -f 3 ${PID} 2>/dev/null
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
return 0
|
||||
@ -98,8 +93,7 @@ function affine_tasks
|
||||
################################################################################
|
||||
# Start Action
|
||||
################################################################################
|
||||
function start
|
||||
{
|
||||
function start {
|
||||
local RET=0
|
||||
|
||||
echo -n "Starting ${scriptname}: "
|
||||
@ -129,8 +123,7 @@ function start
|
||||
################################################################################
|
||||
# Stop Action - don't do anything
|
||||
################################################################################
|
||||
function stop
|
||||
{
|
||||
function stop {
|
||||
local RET=0
|
||||
echo -n "Stopping ${scriptname}: "
|
||||
print_status ${RET}
|
||||
@ -140,7 +133,7 @@ function stop
|
||||
################################################################################
|
||||
# Restart Action
|
||||
################################################################################
|
||||
function restart() {
|
||||
function restart {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
@ -11,20 +11,17 @@ source /etc/platform/platform.conf
|
||||
################################################################################
|
||||
# Utility function to expand a sequence of numbers (e.g., 0-7,16-23)
|
||||
################################################################################
|
||||
function expand_sequence
|
||||
{
|
||||
function expand_sequence {
|
||||
SEQUENCE=(${1//,/ })
|
||||
DELIMITER=${2:-","}
|
||||
|
||||
LIST=
|
||||
for entry in ${SEQUENCE[@]}
|
||||
do
|
||||
for entry in ${SEQUENCE[@]}; do
|
||||
range=(${entry/-/ })
|
||||
a=${range[0]}
|
||||
b=${range[1]:-${range[0]}}
|
||||
|
||||
for i in $(seq $a $b)
|
||||
do
|
||||
for i in $(seq $a $b); do
|
||||
LIST="${LIST}${DELIMITER}${i}"
|
||||
done
|
||||
done
|
||||
@ -34,11 +31,10 @@ function expand_sequence
|
||||
################################################################################
|
||||
# Append a string to comma separated list string
|
||||
################################################################################
|
||||
function append_list() {
|
||||
function append_list {
|
||||
local PUSH=$1
|
||||
local LIST=$2
|
||||
if [ -z "${LIST}" ]
|
||||
then
|
||||
if [ -z "${LIST}" ]; then
|
||||
LIST=${PUSH}
|
||||
else
|
||||
LIST="${LIST},${PUSH}"
|
||||
@ -50,13 +46,12 @@ function append_list() {
|
||||
################################################################################
|
||||
# Condense a sequence of numbers to a list of ranges (e.g, 7-12,15-16)
|
||||
################################################################################
|
||||
function condense_sequence() {
|
||||
function condense_sequence {
|
||||
local arr=( $(printf '%s\n' "$@" | sort -n) )
|
||||
local first
|
||||
local last
|
||||
local cpulist=""
|
||||
for ((i=0; i < ${#arr[@]}; i++))
|
||||
do
|
||||
for ((i=0; i < ${#arr[@]}; i++)); do
|
||||
num=${arr[$i]}
|
||||
if [[ -z $first ]]; then
|
||||
first=$num
|
||||
@ -89,19 +84,16 @@ function condense_sequence() {
|
||||
# number but without the leading "0x" characters.
|
||||
#
|
||||
################################################################################
|
||||
function cpulist_to_cpumap
|
||||
{
|
||||
function cpulist_to_cpumap {
|
||||
local CPULIST=$1
|
||||
local NR_CPUS=$2
|
||||
local CPUMAP=0
|
||||
local CPUID=0
|
||||
if [ -z "${NR_CPUS}" ] || [ ${NR_CPUS} -eq 0 ]
|
||||
then
|
||||
if [ -z "${NR_CPUS}" ] || [ ${NR_CPUS} -eq 0 ]; then
|
||||
echo 0
|
||||
return 0
|
||||
fi
|
||||
for CPUID in $(expand_sequence $CPULIST " ")
|
||||
do
|
||||
for CPUID in $(expand_sequence $CPULIST " "); do
|
||||
if [ "${CPUID}" -lt "${NR_CPUS}" ]; then
|
||||
CPUMAP=$(echo "${CPUMAP} + (2^${CPUID})" | bc -l)
|
||||
fi
|
||||
@ -117,9 +109,9 @@ function cpulist_to_cpumap
|
||||
# characters.
|
||||
#
|
||||
################################################################################
|
||||
function cpumap_to_cpulist
|
||||
{
|
||||
local CPUMAP=$(echo "obase=10;ibase=16;$1" | bc -l)
|
||||
function cpumap_to_cpulist {
|
||||
local CPUMAP
|
||||
CPUMAP=$(echo "obase=10;ibase=16;$1" | bc -l)
|
||||
local NR_CPUS=$2
|
||||
local list=()
|
||||
local cpulist=""
|
||||
@ -131,8 +123,7 @@ function cpumap_to_cpulist
|
||||
## if (CPUMAP % (2**(CPUID+1)) > ((2**(CPUID)) - 1))
|
||||
##
|
||||
ISSET=$(echo "scale=0; (${CPUMAP} % 2^(${i}+1)) > (2^${i})-1" | bc -l)
|
||||
if [ "${ISSET}" -ne 0 ]
|
||||
then
|
||||
if [ "${ISSET}" -ne 0 ]; then
|
||||
list+=($i)
|
||||
fi
|
||||
done
|
||||
@ -146,14 +137,13 @@ function cpumap_to_cpulist
|
||||
# returned as a hexidecimal value but without the leading "0x" characters
|
||||
#
|
||||
################################################################################
|
||||
function invert_cpumap
|
||||
{
|
||||
local CPUMAP=$(echo "obase=10;ibase=16;$1" | bc -l)
|
||||
function invert_cpumap {
|
||||
local CPUMAP
|
||||
CPUMAP=$(echo "obase=10;ibase=16;$1" | bc -l)
|
||||
local NR_CPUS=$2
|
||||
local INVERSE_CPUMAP=0
|
||||
|
||||
for CPUID in $(seq 0 $((NR_CPUS - 1)));
|
||||
do
|
||||
for CPUID in $(seq 0 $((NR_CPUS - 1))); do
|
||||
## See comment in previous function
|
||||
ISSET=$(echo "scale=0; (${CPUMAP} % 2^(${CPUID}+1)) > (2^${CPUID})-1" | bc -l)
|
||||
if [ "${ISSET}" -eq 1 ]; then
|
||||
@ -171,11 +161,11 @@ function invert_cpumap
|
||||
# Builds the complement representation of a CPULIST
|
||||
#
|
||||
################################################################################
|
||||
function invert_cpulist
|
||||
{
|
||||
function invert_cpulist {
|
||||
local CPULIST=$1
|
||||
local NR_CPUS=$2
|
||||
local CPUMAP=$(cpulist_to_cpumap ${CPULIST} ${NR_CPUS})
|
||||
local CPUMAP
|
||||
CPUMAP=$(cpulist_to_cpumap ${CPULIST} ${NR_CPUS})
|
||||
cpumap_to_cpulist $(invert_cpumap ${CPUMAP} ${NR_CPUS}) ${NR_CPUS}
|
||||
return 0
|
||||
}
|
||||
@ -188,17 +178,17 @@ function invert_cpulist
|
||||
# 1 - item is not contained in list
|
||||
#
|
||||
################################################################################
|
||||
function in_list() {
|
||||
function in_list {
|
||||
local item="$1"
|
||||
local list="$2"
|
||||
|
||||
# expand list format 0-3,8-11 to a full sequence {0..3} {8..11}
|
||||
local exp_list=$(echo ${list} | \
|
||||
local exp_list
|
||||
exp_list=$(echo ${list} | \
|
||||
sed -e 's#,# #g' -e 's#\([0-9]*\)-\([0-9]*\)#{\1\.\.\2}#g')
|
||||
|
||||
local e
|
||||
for e in $(eval echo ${exp_list})
|
||||
do
|
||||
for e in $(eval echo ${exp_list}); do
|
||||
[[ "$e" == "$item" ]] && return 0
|
||||
done
|
||||
return 1
|
||||
@ -212,7 +202,7 @@ function in_list() {
|
||||
# 1 - no sublist items contained in list
|
||||
#
|
||||
################################################################################
|
||||
function any_in_list() {
|
||||
function any_in_list {
|
||||
local sublist="$1"
|
||||
local list="$2"
|
||||
local e
|
||||
@ -222,8 +212,7 @@ function any_in_list() {
|
||||
exp_list=$(echo ${list} | \
|
||||
sed -e 's#,# #g' -e 's#\([0-9]*\)-\([0-9]*\)#{\1\.\.\2}#g')
|
||||
declare -A a_list
|
||||
for e in $(eval echo ${exp_list})
|
||||
do
|
||||
for e in $(eval echo ${exp_list}); do
|
||||
a_list[$e]=1
|
||||
done
|
||||
|
||||
@ -231,16 +220,13 @@ function any_in_list() {
|
||||
exp_list=$(echo ${sublist} | \
|
||||
sed -e 's#,# #g' -e 's#\([0-9]*\)-\([0-9]*\)#{\1\.\.\2}#g')
|
||||
declare -A a_sublist
|
||||
for e in $(eval echo ${exp_list})
|
||||
do
|
||||
for e in $(eval echo ${exp_list}); do
|
||||
a_sublist[$e]=1
|
||||
done
|
||||
|
||||
# Check if any element of sublist is in list
|
||||
for e in "${!a_sublist[@]}"
|
||||
do
|
||||
if [[ "${a_list[$e]}" == 1 ]]
|
||||
then
|
||||
for e in "${!a_sublist[@]}"; do
|
||||
if [[ "${a_list[$e]}" == 1 ]]; then
|
||||
return 0 # matches
|
||||
fi
|
||||
done
|
||||
@ -250,7 +236,7 @@ function any_in_list() {
|
||||
################################################################################
|
||||
# Return list of CPUs reserved for platform
|
||||
################################################################################
|
||||
function get_platform_cpu_list() {
|
||||
function get_platform_cpu_list {
|
||||
## Define platform cpulist based on engineering a number of cores and
|
||||
## whether this is a combo or not, and include SMT siblings.
|
||||
if [[ $subfunction = *compute* ]]; then
|
||||
@ -266,16 +252,17 @@ function get_platform_cpu_list() {
|
||||
local PLATFORM_START=0
|
||||
local PLATFORM_CORES=1
|
||||
if [ "$nodetype" = "controller" ]; then
|
||||
((PLATFORM_CORES+=1))
|
||||
PLATFORM_CORES=$(($PLATFORM_CORES+1))
|
||||
fi
|
||||
local PLATFORM_CPULIST=$(topology_to_cpulist ${PLATFORM_SOCKET} ${PLATFORM_START} ${PLATFORM_CORES})
|
||||
local PLATFORM_CPULIST
|
||||
PLATFORM_CPULIST=$(topology_to_cpulist ${PLATFORM_SOCKET} ${PLATFORM_START} ${PLATFORM_CORES})
|
||||
echo ${PLATFORM_CPULIST}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Return list of CPUs reserved for vswitch
|
||||
################################################################################
|
||||
function get_vswitch_cpu_list() {
|
||||
function get_vswitch_cpu_list {
|
||||
## Define default avp cpulist based on engineered number of platform cores,
|
||||
## engineered avp cores, and include SMT siblings.
|
||||
if [[ $subfunction = *compute* ]]; then
|
||||
@ -287,12 +274,13 @@ function get_vswitch_cpu_list() {
|
||||
fi
|
||||
fi
|
||||
|
||||
local N_CORES_IN_PKG=$(cat /proc/cpuinfo 2>/dev/null | \
|
||||
local N_CORES_IN_PKG
|
||||
N_CORES_IN_PKG=$(cat /proc/cpuinfo 2>/dev/null | \
|
||||
awk '/^cpu cores/ {n = $4} END { print (n>0) ? n : 1 }')
|
||||
# engineer platform cores
|
||||
local PLATFORM_CORES=1
|
||||
if [ "$nodetype" = "controller" ]; then
|
||||
((PLATFORM_CORES+=1))
|
||||
PLATFORM_CORES=$(($PLATFORM_CORES+1))
|
||||
fi
|
||||
|
||||
# engineer AVP cores
|
||||
@ -300,32 +288,30 @@ function get_vswitch_cpu_list() {
|
||||
local AVP_START=${PLATFORM_CORES}
|
||||
local AVP_CORES=1
|
||||
if [ ${N_CORES_IN_PKG} -gt 4 ]; then
|
||||
((AVP_CORES+=1))
|
||||
AVP_CORES=$(($AVP_CORES+1))
|
||||
fi
|
||||
local AVP_CPULIST=$(topology_to_cpulist ${AVP_SOCKET} ${AVP_START} ${AVP_CORES})
|
||||
local AVP_CPULIST
|
||||
AVP_CPULIST=$(topology_to_cpulist ${AVP_SOCKET} ${AVP_START} ${AVP_CORES})
|
||||
echo ${AVP_CPULIST}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# vswitch_expanded_cpu_list() - compute the vswitch cpu list, including it's siblings
|
||||
################################################################################
|
||||
function vswitch_expanded_cpu_list() {
|
||||
function vswitch_expanded_cpu_list {
|
||||
list=$(get_vswitch_cpu_list)
|
||||
|
||||
# Expand vswitch cpulist
|
||||
vswitch_cpulist=$(expand_sequence ${list} " ")
|
||||
|
||||
cpulist=""
|
||||
for e in $vswitch_cpulist
|
||||
do
|
||||
for e in $vswitch_cpulist; do
|
||||
# claim hyperthread siblings if SMT enabled
|
||||
SIBLINGS_CPULIST=$(cat /sys/devices/system/cpu/cpu${e}/topology/thread_siblings_list 2>/dev/null)
|
||||
siblings_cpulist=$(expand_sequence ${SIBLINGS_CPULIST} " ")
|
||||
for s in $siblings_cpulist
|
||||
do
|
||||
for s in $siblings_cpulist; do
|
||||
in_list ${s} ${cpulist}
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
if [ $? -eq 1 ]; then
|
||||
cpulist=$(append_list ${s} ${cpulist})
|
||||
fi
|
||||
done
|
||||
@ -338,23 +324,20 @@ function vswitch_expanded_cpu_list() {
|
||||
################################################################################
|
||||
# platform_expanded_cpu_list() - compute the platform cpu list, including it's siblings
|
||||
################################################################################
|
||||
function platform_expanded_cpu_list() {
|
||||
function platform_expanded_cpu_list {
|
||||
list=$(get_platform_cpu_list)
|
||||
|
||||
# Expand platform cpulist
|
||||
platform_cpulist=$(expand_sequence ${list} " ")
|
||||
|
||||
cpulist=""
|
||||
for e in $platform_cpulist
|
||||
do
|
||||
for e in $platform_cpulist; do
|
||||
# claim hyperthread siblings if SMT enabled
|
||||
SIBLINGS_CPULIST=$(cat /sys/devices/system/cpu/cpu${e}/topology/thread_siblings_list 2>/dev/null)
|
||||
siblings_cpulist=$(expand_sequence ${SIBLINGS_CPULIST} " ")
|
||||
for s in $siblings_cpulist
|
||||
do
|
||||
for s in $siblings_cpulist; do
|
||||
in_list ${s} ${cpulist}
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
if [ $? -eq 1 ]; then
|
||||
cpulist=$(append_list ${s} ${cpulist})
|
||||
fi
|
||||
done
|
||||
@ -368,11 +351,12 @@ function platform_expanded_cpu_list() {
|
||||
# Return list of CPUs based on cpu topology. Select the socket, starting core
|
||||
# within the socket, select number of cores, and SMT siblings.
|
||||
################################################################################
|
||||
function topology_to_cpulist() {
|
||||
function topology_to_cpulist {
|
||||
local SOCKET=$1
|
||||
local CORE_START=$2
|
||||
local NUM_CORES=$3
|
||||
local CPULIST=$(cat /proc/cpuinfo 2>/dev/null | perl -sne \
|
||||
local CPULIST
|
||||
CPULIST=$(cat /proc/cpuinfo 2>/dev/null | perl -sne \
|
||||
'BEGIN { %T = {}; %H = {}; $L = $P = $C = $S = 0; }
|
||||
{
|
||||
if (/processor\s+:\s+(\d+)/) { $L = $1; }
|
||||
|
@ -13,8 +13,7 @@ if [ ! -z ${1} ]; then
|
||||
NR_CPUS_LIST=(${1//,/ })
|
||||
fi
|
||||
|
||||
function test_cpumap_to_cpulist()
|
||||
{
|
||||
function test_cpumap_to_cpulist {
|
||||
local NR_CPUS=$1
|
||||
declare -A CPULISTS
|
||||
|
||||
@ -85,8 +84,7 @@ function test_cpumap_to_cpulist()
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
function test_cpulist_to_cpumap()
|
||||
{
|
||||
function test_cpulist_to_cpumap {
|
||||
local NR_CPUS=$1
|
||||
declare -A CPUMAPS
|
||||
|
||||
@ -152,8 +150,7 @@ function test_cpulist_to_cpumap()
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
function test_invert_cpumap()
|
||||
{
|
||||
function test_invert_cpumap {
|
||||
local NR_CPUS=$1
|
||||
declare -A INVERSES
|
||||
|
||||
|
@ -10,8 +10,7 @@
|
||||
# Log if debug is enabled via LOG_DEBUG
|
||||
#
|
||||
################################################################################
|
||||
function log_debug
|
||||
{
|
||||
function log_debug {
|
||||
if [ ! -z "${LOG_DEBUG}" ]; then
|
||||
logger -p debug -t "$0[${PPID}]" -s "$@" 2>&1
|
||||
fi
|
||||
@ -21,8 +20,7 @@ function log_debug
|
||||
# Log unconditionally to STDERR
|
||||
#
|
||||
################################################################################
|
||||
function log_error
|
||||
{
|
||||
function log_error {
|
||||
logger -p error -t "$0[${PPID}]" -s "$@"
|
||||
}
|
||||
|
||||
@ -30,8 +28,7 @@ function log_error
|
||||
# Log unconditionally to STDOUT
|
||||
#
|
||||
################################################################################
|
||||
function log
|
||||
{
|
||||
function log {
|
||||
logger -p info -t "$0[${PPID}]" -s "$@" 2>&1
|
||||
}
|
||||
|
||||
@ -39,8 +36,7 @@ function log
|
||||
# Utility function to print the status of a command result
|
||||
#
|
||||
################################################################################
|
||||
function print_status()
|
||||
{
|
||||
function print_status {
|
||||
if [ "$1" -eq "0" ]; then
|
||||
echo "[ OK ]"
|
||||
else
|
||||
|
@ -12,8 +12,7 @@
|
||||
|
||||
printf "%6s %6s %6s %1c %2s %4s %6s %4s %-24s %2s %-16s %s\n" "PID" "TID" "PPID" "S" "PO" "NICE" "RTPRIO" "PR" "AFFINITY" "P" "COMM" "COMMAND"
|
||||
ps -eL -o pid=,lwp=,ppid=,state=,class=,nice=,rtprio=,priority=,psr=,comm=,command= | \
|
||||
while read pid tid ppid state policy nice rtprio priority psr comm command
|
||||
do
|
||||
while read pid tid ppid state policy nice rtprio priority psr comm command; do
|
||||
bitmask=$(taskset -p $tid 2>/dev/null)
|
||||
aff=${bitmask##*: }
|
||||
if [ -z "${aff}" ]; then
|
||||
@ -22,6 +21,6 @@ do
|
||||
aff="0x${aff}"
|
||||
fi
|
||||
printf "%6d %6d %6d %1c %2s %4s %6s %4d %-24s %2d %-16s %s\n" $pid $tid $ppid $state $policy $nice $rtprio $priority $aff $psr $comm "$command"
|
||||
done
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
@ -37,8 +37,7 @@ CPU_LIST=$2
|
||||
NUMBER_OF_CPUS=$(getconf _NPROCESSORS_CONF 2>/dev/null)
|
||||
STATUS=1
|
||||
|
||||
for CPU_NUM in $(expand_sequence "$CPU_LIST" " ")
|
||||
do
|
||||
for CPU_NUM in $(expand_sequence "$CPU_LIST" " "); do
|
||||
# Check that we are not setting PM QoS policy for non-existing CPU
|
||||
if [ "$CPU_NUM" -lt "0" ] || [ "$CPU_NUM" -ge "$NUMBER_OF_CPUS" ]; then
|
||||
log_error "CPU number ${CPU_NUM} is invalid, available CPUs are 0-${NUMBER_OF_CPUS-1}"
|
||||
|
@ -36,8 +36,7 @@ KERNEL=`uname -a`
|
||||
################################################################################
|
||||
# Check if a given core is one of the platform cores
|
||||
################################################################################
|
||||
function is_platform_core()
|
||||
{
|
||||
function is_platform_core {
|
||||
local core=$1
|
||||
for CPU in ${PLATFORM_CPULIST}; do
|
||||
if [ $core -eq $CPU ]; then
|
||||
@ -50,8 +49,7 @@ function is_platform_core()
|
||||
################################################################################
|
||||
# Check if a given core is one of the vswitch cores
|
||||
################################################################################
|
||||
function is_vswitch_core()
|
||||
{
|
||||
function is_vswitch_core {
|
||||
local core=$1
|
||||
for CPU in ${VSWITCH_CPULIST}; do
|
||||
if [ $core -eq $CPU ]; then
|
||||
@ -64,8 +62,7 @@ function is_vswitch_core()
|
||||
################################################################################
|
||||
# An audit and corrective action following a swact
|
||||
################################################################################
|
||||
function audit_and_reaffine()
|
||||
{
|
||||
function audit_and_reaffine {
|
||||
local mask=$1
|
||||
local cmd_str=""
|
||||
local tasklist
|
||||
@ -93,8 +90,7 @@ function audit_and_reaffine()
|
||||
# The induced tasks migration should be done after all VMs have been restored
|
||||
# following a host reboot in AIO, hence the delay.
|
||||
################################################################################
|
||||
function move_inactive_threads_to_platform_cores()
|
||||
{
|
||||
function move_inactive_threads_to_platform_cores {
|
||||
local tasklist
|
||||
local cmd_str=""
|
||||
|
||||
@ -129,8 +125,7 @@ function move_inactive_threads_to_platform_cores()
|
||||
# The following function is called by affine-platform.sh to affine tasks to
|
||||
# all available cores during initial startup and subsequent host reboots.
|
||||
################################################################################
|
||||
function affine_tasks_to_all_cores()
|
||||
{
|
||||
function affine_tasks_to_all_cores {
|
||||
local pidlist
|
||||
local rc=0
|
||||
|
||||
@ -170,8 +165,7 @@ function affine_tasks_to_all_cores()
|
||||
#
|
||||
# Kernel, vswitch and VM related tasks are untouched.
|
||||
################################################################################
|
||||
function affine_tasks_to_idle_cores()
|
||||
{
|
||||
function affine_tasks_to_idle_cores {
|
||||
local cpulist
|
||||
local cpuocc_list
|
||||
local vswitch_pid
|
||||
@ -198,7 +192,7 @@ function affine_tasks_to_idle_cores()
|
||||
for idle_value in ${cpuocc_list[@]}; do
|
||||
is_vswitch_core $cpu
|
||||
if [ $? -eq 1 ]; then
|
||||
((cpu++))
|
||||
cpu=$(($cpu+1))
|
||||
continue
|
||||
fi
|
||||
|
||||
@ -210,7 +204,7 @@ function affine_tasks_to_idle_cores()
|
||||
# Non platform core is added to the idle list if it is more than 95% idle
|
||||
[[ $(echo "$idle_value > ${IDLE_MARK}"|bc) -eq 1 ]] && idle_cpulist=$idle_cpulist$cpu","
|
||||
fi
|
||||
((cpu++))
|
||||
cpu=$(($cpu+1))
|
||||
done
|
||||
|
||||
idle_cpulist=$(echo $idle_cpulist|sed 's/.$//')
|
||||
@ -248,8 +242,7 @@ function affine_tasks_to_idle_cores()
|
||||
# b) sm at the end of swact sequence
|
||||
# to re-affine management tasks back to the platform cores.
|
||||
################################################################################
|
||||
function affine_tasks_to_platform_cores()
|
||||
{
|
||||
function affine_tasks_to_platform_cores {
|
||||
local cpulist
|
||||
local pidlist
|
||||
local rc=0
|
||||
@ -274,7 +267,7 @@ function affine_tasks_to_platform_cores()
|
||||
# tasks were not affined previously so they should have different affinity
|
||||
# mask(s).
|
||||
if [ "${pid_affinity_mask}" == "${affinity_mask}" ]; then
|
||||
((count++))
|
||||
count=$(($count+1))
|
||||
# log_debug "Affining pid $pid to platform cores..."
|
||||
taskset --all-tasks --pid --cpu-list ${PLATFORM_CPUS} $pid &> /dev/null
|
||||
rc=$?
|
||||
@ -298,8 +291,7 @@ function affine_tasks_to_platform_cores()
|
||||
################################################################################
|
||||
# The following function can be leveraged by cron tasks
|
||||
################################################################################
|
||||
function get_most_idle_core()
|
||||
{
|
||||
function get_most_idle_core {
|
||||
local cpuocc_list
|
||||
local cpu=0
|
||||
local most_idle_value=${IDLE_MARK}
|
||||
@ -315,7 +307,7 @@ function get_most_idle_core()
|
||||
for idle_value in ${cpuocc_list[@]}; do
|
||||
is_vswitch_core $cpu
|
||||
if [ $? -eq 1 ]; then
|
||||
((cpu++))
|
||||
cpu=$(($cpu+1))
|
||||
continue
|
||||
fi
|
||||
|
||||
@ -323,7 +315,7 @@ function get_most_idle_core()
|
||||
most_idle_value=$idle_value
|
||||
most_idle_cpu=$cpu
|
||||
fi
|
||||
((cpu++))
|
||||
cpu=$(($cpu+1))
|
||||
done
|
||||
|
||||
echo $most_idle_cpu
|
||||
|
@ -13,8 +13,7 @@ VOLATILE_CONFIG_FAIL="/var/run/.config_fail"
|
||||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]
|
||||
then
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]; then
|
||||
logger "$NAME: Node configuration has failed. Failing goenabled check."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
SERVICE=computeconfig.service
|
||||
|
||||
while :
|
||||
do
|
||||
while :; do
|
||||
systemctl status $SERVICE |grep -q running
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 0
|
||||
|
@ -25,8 +25,7 @@ case $nodetype in
|
||||
;;
|
||||
esac
|
||||
|
||||
while :
|
||||
do
|
||||
while :; do
|
||||
systemctl status $SERVICE |grep -q running
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 0
|
||||
|
@ -49,8 +49,7 @@ function log {
|
||||
log "$NAME: performing sample migration from release $FROM_RELEASE to $TO_RELEASE with action $ACTION"
|
||||
|
||||
|
||||
if [ "$FROM_RELEASE" == "17.06" ] && [ "$ACTION" == "migrate" ]
|
||||
then
|
||||
if [ "$FROM_RELEASE" == "17.06" ] && [ "$ACTION" == "migrate" ]; then
|
||||
log "Sample migration from release $FROM_RELEASE"
|
||||
fi
|
||||
|
||||
|
@ -13,8 +13,7 @@ VOLATILE_CONFIG_FAIL="/var/run/.config_fail"
|
||||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]
|
||||
then
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]; then
|
||||
logger "$NAME: Node configuration has failed. Failing goenabled check."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -33,11 +33,9 @@ function do_escape {
|
||||
echo $val_escaped
|
||||
}
|
||||
|
||||
if [ "$ACTION" == "migrate" ]
|
||||
then
|
||||
if [ "$ACTION" == "migrate" ]; then
|
||||
log "Creating new $NEW_PIPELINE_FILE file for release $TO_RELEASE"
|
||||
if [ ! -d "$NEW_PIPELINE_DIR" ]
|
||||
then
|
||||
if [ ! -d "$NEW_PIPELINE_DIR" ]; then
|
||||
mkdir $NEW_PIPELINE_DIR
|
||||
fi
|
||||
cp $PIPELINE_SOURCE_FILE $NEW_PIPELINE_FILE
|
||||
|
@ -15,7 +15,6 @@ source $DEST/stx-config/devstack/lib/stx-config
|
||||
# check for service enabled
|
||||
|
||||
if is_service_enabled sysinv-api sysinv-cond; then
|
||||
|
||||
if [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
# Perform installation of sysinv source
|
||||
echo_summary "Installing cgts_client"
|
||||
|
@ -31,29 +31,29 @@ if [ ! -d /var/run/network-scripts.puppet/ ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function log_it() {
|
||||
function log_it {
|
||||
logger "${0} ${1}"
|
||||
}
|
||||
|
||||
function do_if_up() {
|
||||
function do_if_up {
|
||||
local iface=$1
|
||||
log_it "Bringing $iface up"
|
||||
/sbin/ifup $iface
|
||||
}
|
||||
|
||||
function do_if_down() {
|
||||
function do_if_down {
|
||||
local iface=$1
|
||||
log_it "Bringing $iface down"
|
||||
/sbin/ifdown $iface
|
||||
}
|
||||
|
||||
function do_rm() {
|
||||
function do_rm {
|
||||
local theFile=$1
|
||||
log_it "Removing $theFile"
|
||||
/bin/rm $theFile
|
||||
}
|
||||
|
||||
function do_cp() {
|
||||
function do_cp {
|
||||
local srcFile=$1
|
||||
local dstFile=$2
|
||||
log_it "copying network cfg $srcFile to $dstFile"
|
||||
@ -76,10 +76,11 @@ array_diff () {
|
||||
echo ${result[@]}
|
||||
}
|
||||
|
||||
function normalized_cfg_attr_value() {
|
||||
function normalized_cfg_attr_value {
|
||||
local cfg=$1
|
||||
local attr_name=$2
|
||||
local attr_value=$(cat $cfg | grep $attr_name= | awk -F "=" {'print $2'})
|
||||
local attr_value
|
||||
attr_value=$(cat $cfg | grep $attr_name= | awk -F "=" {'print $2'})
|
||||
|
||||
|
||||
#
|
||||
@ -139,7 +140,7 @@ function normalized_cfg_attr_value() {
|
||||
#
|
||||
# returns $(true) if cfg file ( $1 ) has property propName ( $2 ) with a value of propValue ( $3 )
|
||||
#
|
||||
function cfg_has_property_with_value() {
|
||||
function cfg_has_property_with_value {
|
||||
local cfg=$1
|
||||
local propname=$2
|
||||
local propvalue=$3
|
||||
@ -154,7 +155,7 @@ function cfg_has_property_with_value() {
|
||||
#
|
||||
# returns $(true) if cfg file is configured as a slave
|
||||
#
|
||||
function is_slave() {
|
||||
function is_slave {
|
||||
cfg_has_property_with_value $1 "SLAVE" "yes"
|
||||
return $?
|
||||
}
|
||||
@ -162,14 +163,14 @@ function is_slave() {
|
||||
#
|
||||
# returns $(true) if cfg file is configured for DHCP
|
||||
#
|
||||
function is_dhcp() {
|
||||
function is_dhcp {
|
||||
cfg_has_property_with_value $1 "BOOTPROTO" "dhcp"
|
||||
}
|
||||
|
||||
#
|
||||
# returns $(true) if cfg file is configured as a VLAN interface
|
||||
#
|
||||
function is_vlan() {
|
||||
function is_vlan {
|
||||
cfg_has_property_with_value $1 "VLAN" "yes"
|
||||
return $?
|
||||
}
|
||||
@ -180,7 +181,7 @@ function is_vlan() {
|
||||
# a vlan or a slave. This includes both regular ethernet interfaces and bonded
|
||||
# interfaces.
|
||||
#
|
||||
function is_ethernet() {
|
||||
function is_ethernet {
|
||||
if ! is_vlan $1; then
|
||||
if ! is_slave $1; then
|
||||
return $(true)
|
||||
@ -192,7 +193,7 @@ function is_ethernet() {
|
||||
#
|
||||
# returns $(true) if cfg file represents an interface of the specified type.
|
||||
#
|
||||
function iftype_filter() {
|
||||
function iftype_filter {
|
||||
local iftype=$1
|
||||
|
||||
return $(is_$iftype $2)
|
||||
@ -202,12 +203,13 @@ function iftype_filter() {
|
||||
# returns $(true) if ifcfg files have the same number of VFs
|
||||
#
|
||||
#
|
||||
function is_eq_sriov_numvfs() {
|
||||
function is_eq_sriov_numvfs {
|
||||
local cfg_1=$1
|
||||
local cfg_2=$2
|
||||
|
||||
local sriov_numvfs_1=$(grep -o 'echo *[1-9].*sriov_numvfs' $cfg_1 | awk {'print $2'})
|
||||
local sriov_numvfs_2=$(grep -o 'echo *[1-9].*sriov_numvfs' $cfg_2 | awk {'print $2'})
|
||||
local sriov_numvfs_1
|
||||
sriov_numvfs_1=$(grep -o 'echo *[1-9].*sriov_numvfs' $cfg_1 | awk {'print $2'})
|
||||
local sriov_numvfs_2
|
||||
sriov_numvfs_2=$(grep -o 'echo *[1-9].*sriov_numvfs' $cfg_2 | awk {'print $2'})
|
||||
|
||||
sriov_numvfs_1=${sriov_numvfs_1:-0}
|
||||
sriov_numvfs_2=${sriov_numvfs_2:-0}
|
||||
@ -226,14 +228,15 @@ function is_eq_sriov_numvfs() {
|
||||
# Warning: Only compares against cfg file attributes:
|
||||
# BOOTPROTO DEVICE IPADDR NETMASK GATEWAY MTU BONDING_OPTS SRIOV_NUMVFS
|
||||
#
|
||||
function is_eq_ifcfg() {
|
||||
function is_eq_ifcfg {
|
||||
local cfg_1=$1
|
||||
local cfg_2=$2
|
||||
|
||||
for attr in BOOTPROTO DEVICE IPADDR NETMASK GATEWAY MTU BONDING_OPTS
|
||||
do
|
||||
local attr_value1=$(normalized_cfg_attr_value $cfg_1 $attr)
|
||||
local attr_value2=$(normalized_cfg_attr_value $cfg_2 $attr)
|
||||
for attr in BOOTPROTO DEVICE IPADDR NETMASK GATEWAY MTU BONDING_OPTS; do
|
||||
local attr_value1
|
||||
attr_value1=$(normalized_cfg_attr_value $cfg_1 $attr)
|
||||
local attr_value2
|
||||
attr_value2=$(normalized_cfg_attr_value $cfg_2 $attr)
|
||||
if [[ "${attr_value1}" != "${attr_value2}" ]]; then
|
||||
log_it "$cfg_1 and $cfg_2 differ on attribute $attr"
|
||||
return $(false)
|
||||
@ -245,7 +248,7 @@ function is_eq_ifcfg() {
|
||||
}
|
||||
|
||||
# Synchronize with sysinv-agent audit (ifup/down to query link speed).
|
||||
function sysinv_agent_lock() {
|
||||
function sysinv_agent_lock {
|
||||
case $1 in
|
||||
$ACQUIRE_LOCK)
|
||||
local lock_file="/var/run/apply_network_config.lock"
|
||||
@ -255,12 +258,12 @@ function sysinv_agent_lock() {
|
||||
local n=1
|
||||
LOCK_FD=0
|
||||
exec {LOCK_FD}>$lock_file
|
||||
while [[ $n -le $max ]]
|
||||
do
|
||||
while [[ $n -le $max ]]; do
|
||||
|
||||
flock -w $lock_timeout $LOCK_FD && break
|
||||
log_it "Failed to get lock($LOCK_FD) after $lock_timeout seconds ($n/$max), will retry"
|
||||
sleep 1
|
||||
((n++))
|
||||
n=$(($n+1))
|
||||
done
|
||||
if [[ $n -gt $max ]]; then
|
||||
log_it "Failed to acquire lock($LOCK_FD) even after $max retries"
|
||||
|
@ -59,10 +59,9 @@ cp /etc/puppet/hieradata/${PERSONALITY}.yaml ${PUPPET_TMP}/hieradata/personality
|
||||
# has not yet been fully understood. Subsequent retries worked.
|
||||
if [ "${PERSONALITY}" = "compute" ]; then
|
||||
n=0
|
||||
until [ $n -ge 3 ]
|
||||
do
|
||||
until [ $n -ge 3 ]; do
|
||||
cp -f ${HIERADATA}/${HOST}.yaml ${PUPPET_TMP}/hieradata/host.yaml && break
|
||||
n=$[$n+1]
|
||||
n=$(($n+1))
|
||||
logger -t $0 "Failed to copy /etc/puppet/hieradata/${HOST}.yaml"
|
||||
sleep 15
|
||||
done
|
||||
@ -81,8 +80,7 @@ fi
|
||||
|
||||
|
||||
# Exit function to save logs from initial apply
|
||||
function finish()
|
||||
{
|
||||
function finish {
|
||||
local SAVEDLOGS=/var/log/puppet/first_apply.tgz
|
||||
if [ ! -f ${SAVEDLOGS} ]; then
|
||||
# Save the logs
|
||||
@ -102,15 +100,13 @@ echo "Applying puppet ${MANIFEST} manifest..."
|
||||
flock /var/run/puppet.lock \
|
||||
puppet apply --debug --trace --modulepath ${PUPPET_MODULES_PATH} ${PUPPET_MANIFEST} \
|
||||
< /dev/null 2>&1 | awk ' { system("date -u +%FT%T.%3N | tr \"\n\" \" \""); print $0; fflush(); } ' > ${LOGFILE}
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[FAILED]"
|
||||
echo "See ${LOGFILE} for details"
|
||||
exit 1
|
||||
else
|
||||
grep -qE '^(.......)?Warning|^....-..-..T..:..:..([.]...)?(.......)?.Warning|^(.......)?Error|^....-..-..T..:..:..([.]...)?(.......)?.Error' ${LOGFILE}
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "[WARNING]"
|
||||
echo "Warnings found. See ${LOGFILE} for details"
|
||||
exit 1
|
||||
|
@ -2,7 +2,6 @@
|
||||
[ -z "$PS1" -o -n "$KUBECONFIG" ] && return
|
||||
|
||||
# Set up the location of the k8s config file for anyone who can read it.
|
||||
if [ -r /etc/kubernetes/admin.conf ]
|
||||
then
|
||||
if [ -r /etc/kubernetes/admin.conf ]; then
|
||||
export KUBECONFIG=/etc/kubernetes/admin.conf
|
||||
fi
|
||||
|
@ -13,8 +13,7 @@ VOLATILE_CONFIG_FAIL="/var/run/.config_fail"
|
||||
|
||||
logfile=/var/log/patching.log
|
||||
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]
|
||||
then
|
||||
if [ -f $VOLATILE_CONFIG_FAIL ]; then
|
||||
logger "$NAME: Node configuration has failed. Failing goenabled check."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -13,24 +13,21 @@ SYSINV_READY_FLAG=/var/run/.sysinv_ready
|
||||
|
||||
logfile=/var/log/platform.log
|
||||
|
||||
function LOG()
|
||||
{
|
||||
function LOG {
|
||||
logger "$NAME: $*"
|
||||
echo "`date "+%FT%T"`: $NAME: $*" >> $logfile
|
||||
}
|
||||
|
||||
count=0
|
||||
while [ $count -le 45 ]
|
||||
do
|
||||
if [ -f $SYSINV_READY_FLAG ]
|
||||
then
|
||||
while [ $count -le 45 ]; do
|
||||
if [ -f $SYSINV_READY_FLAG ]; then
|
||||
LOG "SysInv is ready. Passing goenabled check."
|
||||
echo "SysInv goenabled iterations PASS $count"
|
||||
LOG "SysInv goenabled iterations PASS $count"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
(( count++ ))
|
||||
count=$(($count+1))
|
||||
done
|
||||
|
||||
echo "SysInv goenabled iterations FAIL $count"
|
||||
|
@ -33,7 +33,8 @@ wlog() {
|
||||
return
|
||||
fi
|
||||
|
||||
local head="$(date "+%Y-%m-%d %H:%M:%S.%3N") $0 $1"
|
||||
local head
|
||||
head="$(date "+%Y-%m-%d %H:%M:%S.%3N") $0 $1"
|
||||
echo "$head $2: $3" >> $LOG_FILE
|
||||
if [ "$4" = "print_trace" ]; then
|
||||
# Print out the stack trace
|
||||
@ -50,8 +51,7 @@ device_path=$1 && shift
|
||||
part_numbers=( `parted -s $device_path print | awk '$1 == "Number" {i=1; next}; i {print $1}'` )
|
||||
sector_size=$(blockdev --getss $device_path)
|
||||
|
||||
for part_number in "${part_numbers[@]}";
|
||||
do
|
||||
for part_number in "${part_numbers[@]}"; do
|
||||
sgdisk_part_info=$(sgdisk -i $part_number $device_path)
|
||||
|
||||
# Parse the output and put it in the right return format.
|
||||
|
14
tox.ini
14
tox.ini
@ -21,12 +21,14 @@ commands =
|
||||
-not -name \*~ \
|
||||
-not -name \*.md \
|
||||
-name \*.sh \
|
||||
-print0 | xargs -0 bashate -v"
|
||||
bash -c "find {toxinidir} \
|
||||
\( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \
|
||||
-o \( -name .tox -prune \) \
|
||||
-o -type f -name '*.yaml' \
|
||||
-print0 | xargs -0 yamllint"
|
||||
-print0 | xargs -0 bashate -v -e E* \
|
||||
-i E006,E010"
|
||||
|
||||
# bash -c "find {toxinidir} \
|
||||
# \( -name .tox -prune \) \
|
||||
# -o -type f -name '*.yaml' \
|
||||
# -print0 | xargs -0 yamllint -f parsable \
|
||||
# -c {toxinidir}/.yamllint"
|
||||
|
||||
[testenv:pep8]
|
||||
usedevelop = False
|
||||
|
Loading…
Reference in New Issue
Block a user