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