Fix tox linters for zuul

Fix bashate and yamllint to only run if files are provided
Fix whitespace errors and line errors in shell scripts
Relax line length requirement in yamllint
Enable voting on zuul jobs
Story: 2003359
Task: 24409

Change-Id: I6bfa31c9a0c1527c6517cfd95758feadd73c0ae6
Signed-off-by: Lachlan Plant <lachlan.plant@windriver.com>
This commit is contained in:
Lachlan Plant 2018-08-29 11:30:50 -05:00
parent 50caaef062
commit e2137f94df
5 changed files with 37 additions and 44 deletions

View File

@ -1,5 +1,5 @@
- project: - project:
check: check:
jobs: jobs:
- openstack-tox-linters: - openstack-tox-linters
voting: false - openstack-tox-pep8

View File

@ -164,7 +164,7 @@ elif [[ ! -z $APT_GET_CMD ]]; then
fi fi
if $install_curl ; then if $install_curl ; then
echo "curl is required for Elasticsearch package download." echo "curl is required for Elasticsearch package download."
apt-get install curl apt-get install curl
fi fi
if $install_iptables_save; then if $install_iptables_save; then
echo "iptables-persistent is required for Logstash with protected ports under 1024." echo "iptables-persistent is required for Logstash with protected ports under 1024."
@ -178,8 +178,7 @@ fi
get_install_package() { get_install_package() {
# The URL parameter is required for this function # The URL parameter is required for this function
if [ -z "$1" ] if [ -z "$1" ] ; then
then
return 1 return 1
fi fi
@ -205,8 +204,7 @@ get_install_package() {
} }
boot_at_startup () { boot_at_startup () {
if [ -z "$1" ] if [ -z "$1" ] ; then
then
echo "A URL parameter must be passed to boot_at_startup" echo "A URL parameter must be passed to boot_at_startup"
return 1 return 1
fi fi
@ -243,8 +241,7 @@ if [[ "$_java" ]]; then
echo "Elasticsearch recommends that you use the Oracle JDK version 1.8.0_73." echo "Elasticsearch recommends that you use the Oracle JDK version 1.8.0_73."
echo "Refer to the current documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html" echo "Refer to the current documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html"
read -p "Would you like to install Oracle Java 8? y/n: " PACKMAN_CONTINUE_INPUT read -p "Would you like to install Oracle Java 8? y/n: " PACKMAN_CONTINUE_INPUT
while [[ "$PACKMAN_CONTINUE_INPUT" != "y" && "$PACKMAN_CONTINUE_INPUT" != "n" ]] while [[ "$PACKMAN_CONTINUE_INPUT" != "y" && "$PACKMAN_CONTINUE_INPUT" != "n" ]] ; do
do
echo invalid input: $PACKMAN_CONTINUE_INPUT echo invalid input: $PACKMAN_CONTINUE_INPUT
read -p "Continue with installation? y/n: " PACKMAN_CONTINUE_INPUT read -p "Continue with installation? y/n: " PACKMAN_CONTINUE_INPUT
done done
@ -263,7 +260,7 @@ if [[ "$install_java" == "y" ]]; then
apt-get install oracle-java8-set-default apt-get install oracle-java8-set-default
else else
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jre-8u92-linux-x64.rpm" wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jre-8u92-linux-x64.rpm"
yum localinstall jre-8u92-linux-x64.rpm yum localinstall jre-8u92-linux-x64.rpm
fi fi
echo "Java installation complete." echo "Java installation complete."
fi fi
@ -282,7 +279,7 @@ wait_for_elasticsearch() {
break 2 break 2
fi fi
done done
if [ "$ES_ACTIVE" == false ]; then if [ "$ES_ACTIVE" == false ]; then
echo "Elasticsearch is not responding. Please resolve the issue and rerun the script." echo "Elasticsearch is not responding. Please resolve the issue and rerun the script."
echo "More details at: https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html" echo "More details at: https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html"
@ -333,7 +330,7 @@ config_logstash() {
# Update conf file with IP_ADDRESS # Update conf file with IP_ADDRESS
sed -i "s/ host => .*/ host => \"${IP_ADDRESS}\"/" /etc/logstash/conf.d/wrs-logstash.conf sed -i "s/ host => .*/ host => \"${IP_ADDRESS}\"/" /etc/logstash/conf.d/wrs-logstash.conf
sed -i "s/.*elasticsearch { hosts.*/ elasticsearch { hosts => [\"${IP_ADDRESS}:9200\"] }/" /etc/logstash/conf.d/wrs-logstash.conf sed -i "s/.*elasticsearch { hosts.*/ elasticsearch { hosts => [\"${IP_ADDRESS}:9200\"] }/" /etc/logstash/conf.d/wrs-logstash.conf
# install certificate, key, and set TLS config # install certificate, key, and set TLS config
if [ $TLS_PARAM_COUNT -eq 2 ]; then if [ $TLS_PARAM_COUNT -eq 2 ]; then
mkdir -p /etc/pki/tls/certs mkdir -p /etc/pki/tls/certs
@ -355,20 +352,20 @@ config_logstash() {
port_in_use=$( netstat -an | grep 10514 ) port_in_use=$( netstat -an | grep 10514 )
if [ -f "/bin/systemctl" ] ; then if [ -f "/bin/systemctl" ] ; then
systemctl enable iptables systemctl enable iptables
else else
update-rc.d iptables defaults 95 10 update-rc.d iptables defaults 95 10
fi fi
netstat -an | grep 10514 netstat -an | grep 10514
# Delete any pre-existing rules forwarding to port 10514 # Delete any pre-existing rules forwarding to port 10514
old_rules_list=$(iptables -t nat --line-numbers -L | grep '^[0-9].*10514' | awk '{ print $1 }' | tac) old_rules_list=$(iptables -t nat --line-numbers -L | grep '^[0-9].*10514' | awk '{ print $1 }' | tac)
old_rules_count=0 old_rules_count=0
for i in $old_rules_list; do for i in $old_rules_list ; do
iptables -t nat -D PREROUTING $i iptables -t nat -D PREROUTING $i
old_rules_count=$((old_rules_count+1)) old_rules_count=$((old_rules_count+1))
done done
echo Deleted $old_rules_count NAT PREROUTING rules to Logstash listening authorized port 10514. echo Deleted $old_rules_count NAT PREROUTING rules to Logstash listening authorized port 10514.
# Update conf file with non-priviledged port # Update conf file with non-priviledged port
echo "Priviledged port $PORT redirected to Logstash listening authorized port 10514." echo "Priviledged port $PORT redirected to Logstash listening authorized port 10514."
sed -i "s/ port =>.*/ port => 10514/" /etc/logstash/conf.d/wrs-logstash.conf sed -i "s/ port =>.*/ port => 10514/" /etc/logstash/conf.d/wrs-logstash.conf
@ -395,7 +392,7 @@ config_logstash() {
netfilter-persistent save netfilter-persistent save
netfilter-persistent reload netfilter-persistent reload
elif [ -f "/etc/init.d/iptables-persistent" ] ; then elif [ -f "/etc/init.d/iptables-persistent" ] ; then
/etc/init.d/iptables-persistent save /etc/init.d/iptables-persistent save
/etc/init.d/iptables-persistent reload /etc/init.d/iptables-persistent reload
elif [ -f "/etc/centos-release" ] ; then elif [ -f "/etc/centos-release" ] ; then
# CentOS 7 https://wiki.centos.org/HowTos/Network/IPTables # CentOS 7 https://wiki.centos.org/HowTos/Network/IPTables

View File

@ -71,8 +71,8 @@ ip=""
suffix="" suffix=""
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Directory that this script is contained in DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Directory that this script is contained in
if [ $UID -ne 0 ]; then if [ $UID -ne 0 ]; then
echo $'\tWarning: This script must be run as \'root\' user to restart ELK services. Please rerun with sudo.\n' echo $'\tWarning: This script must be run as \'root\' user to restart ELK services. Please rerun with sudo.\n'
exit 1 exit 1
fi fi
# Check to see if required config files are present # Check to see if required config files are present
if [[ ! -f "/etc/logstash/conf.d/wrs-logstash.conf" ]]; then if [[ ! -f "/etc/logstash/conf.d/wrs-logstash.conf" ]]; then
@ -139,7 +139,7 @@ function help {
echo " originally used when setting up ELK to work with a remote logger." echo " originally used when setting up ELK to work with a remote logger."
echo " -If you use the --remote option and logs fail to populate, or you get an error about elasticsearch" echo " -If you use the --remote option and logs fail to populate, or you get an error about elasticsearch"
echo " make sure that the port your remote logger is using is still being forwarded correctly by re-entering" echo " make sure that the port your remote logger is using is still being forwarded correctly by re-entering"
echo " iptables -t nat -A PREROUTING -p UDP -m udp --dport $PORT -j REDIRECT --to-ports 10514" echo " iptables -t nat -A PREROUTING -p UDP -m udp --dport $PORT -j REDIRECT --to-ports 10514"
echo " OR" echo " OR"
echo " ip6tables -t nat -A PREROUTING -p tcp -m tcp --dport $PORT -j REDIRECT --to-ports 10514" echo " ip6tables -t nat -A PREROUTING -p tcp -m tcp --dport $PORT -j REDIRECT --to-ports 10514"
echo " make sure you correctly specify tcp or udp, and use iptables for IPV4 and ip6tables for IPV6" echo " make sure you correctly specify tcp or udp, and use iptables for IPV4 and ip6tables for IPV6"
@ -259,7 +259,7 @@ dist="$(lsb_release -a)"
while [[ $# > 0 ]]; do while [[ $# > 0 ]]; do
arg="$1" arg="$1"
case $arg in case $arg in
-h|--help) -h|--help)
help help
;; ;;

View File

@ -90,8 +90,7 @@ if [ -z "${VIRTUAL_ENV}" ]; then
echo "Please ensure the following are installed on your system before continuing:" echo "Please ensure the following are installed on your system before continuing:"
echo "python-dev python-setuptools gcc git python-pip" echo "python-dev python-setuptools gcc git python-pip"
read -p "Continue with installation? y/n: " PACKMAN_CONTINUE_INPUT read -p "Continue with installation? y/n: " PACKMAN_CONTINUE_INPUT
while [[ "$PACKMAN_CONTINUE_INPUT" != "y" && "$PACKMAN_CONTINUE_INPUT" != "n" ]] while [[ "$PACKMAN_CONTINUE_INPUT" != "y" && "$PACKMAN_CONTINUE_INPUT" != "n" ]] ; do
do
echo invalid input: $PACKMAN_CONTINUE_INPUT echo invalid input: $PACKMAN_CONTINUE_INPUT
read -p "Continue with installation? y/n: " PACKMAN_CONTINUE_INPUT read -p "Continue with installation? y/n: " PACKMAN_CONTINUE_INPUT
done done
@ -120,18 +119,19 @@ if ! pip install "pbr>=1.8"; then
exit 1 exit 1
fi fi
while true;do echo -n . 1>&3;sleep 1;done & while true; do
echo -n . 1>&3
sleep 1
done &
trap 'kill $! 2>/dev/null' EXIT trap 'kill $! 2>/dev/null' EXIT
for file in *.tgz for file in *.tgz ; do
do
if ! tar -zxf $file; then if ! tar -zxf $file; then
echo "Failed to extract file $file" 1>&3 echo "Failed to extract file $file" 1>&3
exit 1 exit 1
fi fi
done done
if [ -f "requirements.txt" ] if [ -f "requirements.txt" ] ; then
then
if ! pip -q install -r requirements.txt -c upper_constraints.txt; then if ! pip -q install -r requirements.txt -c upper_constraints.txt; then
echo "Failed to install requirements" 1>&3 echo "Failed to install requirements" 1>&3
exit 1 exit 1
@ -145,17 +145,17 @@ echo [DONE] 1>&3
# because some of our tis clients are older than the most recent openstack clients # because some of our tis clients are older than the most recent openstack clients
pip freeze | grep -wF -f installed_clients.txt | xargs pip uninstall -y pip freeze | grep -wF -f installed_clients.txt | xargs pip uninstall -y
for dir in ./*/ for dir in ./*/ ; do
do
cd $dir cd $dir
if [ -f "setup.py" ] if [ -f "setup.py" ] ; then
then
echo -n Installing $(python setup.py --name) ... 1>&3 echo -n Installing $(python setup.py --name) ... 1>&3
fi fi
while true;do echo -n . 1>&3;sleep 1;done & while true; do
if [ -f "requirements.txt" ] echo -n . 1>&3
then sleep 1
done &
if [ -f "requirements.txt" ] ; then
grep -vwF -f ../installed_clients.txt requirements.txt > requirements.txt.temp grep -vwF -f ../installed_clients.txt requirements.txt > requirements.txt.temp
mv requirements.txt.temp requirements.txt mv requirements.txt.temp requirements.txt
sed -i -e 's/# Apache-2.0//g' requirements.txt sed -i -e 's/# Apache-2.0//g' requirements.txt
@ -165,8 +165,7 @@ do
fi fi
fi fi
if [ -f "setup.py" ] if [ -f "setup.py" ] ; then
then
if ! python setup.py -q install; then if ! python setup.py -q install; then
echo "Failed to install $(python setup.py --name)" 1>&3 echo "Failed to install $(python setup.py --name)" 1>&3
exit 1 exit 1
@ -174,14 +173,11 @@ do
fi fi
# install bash completion # install bash completion
if [ -d "tools" -a -z "${VIRTUAL_ENV}" ] if [ -d "tools" -a -z "${VIRTUAL_ENV}" ] ; then
then
cd tools cd tools
if [ -d "/etc/bash_completion.d" ] if [ -d "/etc/bash_completion.d" ] ; then
then
count=`ls -1 *.bash_completion 2>/dev/null | wc -l` count=`ls -1 *.bash_completion 2>/dev/null | wc -l`
if [ $count != 0 ] if [ $count != 0 ] ; then
then
cp *.bash_completion /etc/bash_completion.d cp *.bash_completion /etc/bash_completion.d
fi fi
fi fi

View File

@ -20,7 +20,7 @@ commands =
-not -name \*~ \ -not -name \*~ \
-not -name \*.md \ -not -name \*.md \
-name \*.sh \ -name \*.sh \
-print0 | xargs -0 bashate -v" -print0 | xargs -0 bashate -iE006 -v"
bash -c "find {toxinidir} \ bash -c "find {toxinidir} \
\( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \ \( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \
-o \( -name .tox -prune \) \ -o \( -name .tox -prune \) \