Add bash script style checker to pep8 check
Added the bashate script style checker to the pep8 check target in tox.ini. It actually found two valid issues - a bad function declaration and a local variable issue, but mostly just indentation noise. Fixed all the complaints. Change-Id: I43b60e7dcf53acf259c8a52b248fbb8c63d3c8d4
This commit is contained in:
parent
ca80bc9e03
commit
98448dce44
@ -204,7 +204,7 @@ function create_octavia_accounts {
|
||||
# This is imporant for concurrent tempest testing
|
||||
openstack quota set --secgroups 100 $SERVICE_PROJECT_NAME
|
||||
|
||||
local octavia_service=$(get_or_create_service "octavia" \
|
||||
octavia_service=$(get_or_create_service "octavia" \
|
||||
$OCTAVIA_SERVICE_TYPE "Octavia Load Balancing Service")
|
||||
|
||||
if [[ "$WSGI_MODE" == "uwsgi" ]] && [[ "$OCTAVIA_NODE" == "main" ]] ; then
|
||||
@ -493,10 +493,10 @@ function configure_octavia_api_haproxy {
|
||||
NODES=(${OCTAVIA_NODES//,/ })
|
||||
|
||||
for NODE in ${NODES[@]}; do
|
||||
DATA=(${NODE//:/ })
|
||||
NAME=$(echo -e "${DATA[0]}" | tr -d '[[:space:]]')
|
||||
IP=$(echo -e "${DATA[1]}" | tr -d '[[:space:]]')
|
||||
echo " server octavia-${NAME} ${IP}:80 weight 1" >> ${OCTAVIA_CONF_DIR}/haproxy.cfg
|
||||
DATA=(${NODE//:/ })
|
||||
NAME=$(echo -e "${DATA[0]}" | tr -d '[[:space:]]')
|
||||
IP=$(echo -e "${DATA[1]}" | tr -d '[[:space:]]')
|
||||
echo " server octavia-${NAME} ${IP}:80 weight 1" >> ${OCTAVIA_CONF_DIR}/haproxy.cfg
|
||||
done
|
||||
|
||||
}
|
||||
@ -564,19 +564,19 @@ function octavia_stop {
|
||||
function octavia_cleanup {
|
||||
|
||||
if [ ${OCTAVIA_AMP_IMAGE_NAME}x != x ] ; then
|
||||
rm -rf ${OCTAVIA_AMP_IMAGE_NAME}*
|
||||
rm -rf ${OCTAVIA_AMP_IMAGE_NAME}*
|
||||
fi
|
||||
if [ ${OCTAVIA_AMP_SSH_KEY_NAME}x != x ] ; then
|
||||
rm -f ${OCTAVIA_AMP_SSH_KEY_NAME}*
|
||||
rm -f ${OCTAVIA_AMP_SSH_KEY_NAME}*
|
||||
fi
|
||||
if [ ${OCTAVIA_SSH_DIR}x != x ] ; then
|
||||
rm -rf ${OCTAVIA_SSH_DIR}
|
||||
rm -rf ${OCTAVIA_SSH_DIR}
|
||||
fi
|
||||
if [ ${OCTAVIA_CONF_DIR}x != x ] ; then
|
||||
sudo rm -rf ${OCTAVIA_CONF_DIR}
|
||||
sudo rm -rf ${OCTAVIA_CONF_DIR}
|
||||
fi
|
||||
if [ ${OCTAVIA_RUN_DIR}x != x ] ; then
|
||||
sudo rm -rf ${OCTAVIA_RUN_DIR}
|
||||
sudo rm -rf ${OCTAVIA_RUN_DIR}
|
||||
fi
|
||||
if [ ${OCTAVIA_AMP_SSH_KEY_PATH}x != x ] ; then
|
||||
rm -f ${OCTAVIA_AMP_SSH_KEY_PATH} ${OCTAVIA_AMP_SSH_KEY_PATH}.pub
|
||||
@ -610,66 +610,66 @@ function add_load-balancer_roles {
|
||||
}
|
||||
|
||||
function octavia_init {
|
||||
if [ $OCTAVIA_NODE != 'main' ] && [ $OCTAVIA_NODE != 'standalone' ] && [ $OCTAVIA_NODE != 'api' ]; then
|
||||
# without the other services enabled apparently we don't have
|
||||
# credentials at this point
|
||||
# TOP_DIR=$(cd $(dirname "$0") && pwd)
|
||||
source ${TOP_DIR}/openrc admin admin
|
||||
OCTAVIA_AMP_NETWORK_ID=$(openstack network show lb-mgmt-net -f value -c id)
|
||||
iniset $OCTAVIA_CONF controller_worker amp_boot_network_list ${OCTAVIA_AMP_NETWORK_ID}
|
||||
fi
|
||||
if [ $OCTAVIA_NODE != 'main' ] && [ $OCTAVIA_NODE != 'standalone' ] && [ $OCTAVIA_NODE != 'api' ]; then
|
||||
# without the other services enabled apparently we don't have
|
||||
# credentials at this point
|
||||
# TOP_DIR=$(cd $(dirname "$0") && pwd)
|
||||
source ${TOP_DIR}/openrc admin admin
|
||||
OCTAVIA_AMP_NETWORK_ID=$(openstack network show lb-mgmt-net -f value -c id)
|
||||
iniset $OCTAVIA_CONF controller_worker amp_boot_network_list ${OCTAVIA_AMP_NETWORK_ID}
|
||||
fi
|
||||
|
||||
if [ $OCTAVIA_NODE == 'main' ] || [ $OCTAVIA_NODE == 'standalone' ] ; then
|
||||
# things that should only happen on the ha main node / or once
|
||||
if ! openstack keypair show ${OCTAVIA_AMP_SSH_KEY_NAME} ; then
|
||||
openstack keypair create --public-key ${OCTAVIA_AMP_SSH_KEY_PATH}.pub ${OCTAVIA_AMP_SSH_KEY_NAME}
|
||||
fi
|
||||
if [ $OCTAVIA_NODE == 'main' ] || [ $OCTAVIA_NODE == 'standalone' ] ; then
|
||||
# things that should only happen on the ha main node / or once
|
||||
if ! openstack keypair show ${OCTAVIA_AMP_SSH_KEY_NAME} ; then
|
||||
openstack keypair create --public-key ${OCTAVIA_AMP_SSH_KEY_PATH}.pub ${OCTAVIA_AMP_SSH_KEY_NAME}
|
||||
fi
|
||||
|
||||
# Check if an amphora image is already loaded
|
||||
AMPHORA_IMAGE_NAME=$(openstack image list --property name=${OCTAVIA_AMP_IMAGE_NAME} -f value -c Name)
|
||||
export AMPHORA_IMAGE_NAME
|
||||
# Check if an amphora image is already loaded
|
||||
AMPHORA_IMAGE_NAME=$(openstack image list --property name=${OCTAVIA_AMP_IMAGE_NAME} -f value -c Name)
|
||||
export AMPHORA_IMAGE_NAME
|
||||
|
||||
if [ "$AMPHORA_IMAGE_NAME" == ${OCTAVIA_AMP_IMAGE_NAME} ]; then
|
||||
echo "Found existing amphora image: $AMPHORA_IMAGE_NAME"
|
||||
echo "Skipping amphora image build"
|
||||
export DISABLE_AMP_IMAGE_BUILD=True
|
||||
fi
|
||||
if [ "$AMPHORA_IMAGE_NAME" == ${OCTAVIA_AMP_IMAGE_NAME} ]; then
|
||||
echo "Found existing amphora image: $AMPHORA_IMAGE_NAME"
|
||||
echo "Skipping amphora image build"
|
||||
export DISABLE_AMP_IMAGE_BUILD=True
|
||||
fi
|
||||
|
||||
if ! [ "$DISABLE_AMP_IMAGE_BUILD" == 'True' ]; then
|
||||
build_octavia_worker_image
|
||||
fi
|
||||
if ! [ "$DISABLE_AMP_IMAGE_BUILD" == 'True' ]; then
|
||||
build_octavia_worker_image
|
||||
fi
|
||||
|
||||
OCTAVIA_AMP_IMAGE_ID=$(openstack image list -f value --property name=${OCTAVIA_AMP_IMAGE_NAME} -c ID)
|
||||
OCTAVIA_AMP_IMAGE_ID=$(openstack image list -f value --property name=${OCTAVIA_AMP_IMAGE_NAME} -c ID)
|
||||
|
||||
if [ -n "$OCTAVIA_AMP_IMAGE_ID" ]; then
|
||||
openstack image set --tag ${OCTAVIA_AMP_IMAGE_TAG} --property hw_architecture='x86_64' --property hw_rng_model=virtio ${OCTAVIA_AMP_IMAGE_ID}
|
||||
fi
|
||||
if [ -n "$OCTAVIA_AMP_IMAGE_ID" ]; then
|
||||
openstack image set --tag ${OCTAVIA_AMP_IMAGE_TAG} --property hw_architecture='x86_64' --property hw_rng_model=virtio ${OCTAVIA_AMP_IMAGE_ID}
|
||||
fi
|
||||
|
||||
# Create a management network.
|
||||
build_mgmt_network
|
||||
OCTAVIA_AMP_NETWORK_ID=$(openstack network show lb-mgmt-net -f value -c id)
|
||||
iniset $OCTAVIA_CONF controller_worker amp_boot_network_list ${OCTAVIA_AMP_NETWORK_ID}
|
||||
# Create a management network.
|
||||
build_mgmt_network
|
||||
OCTAVIA_AMP_NETWORK_ID=$(openstack network show lb-mgmt-net -f value -c id)
|
||||
iniset $OCTAVIA_CONF controller_worker amp_boot_network_list ${OCTAVIA_AMP_NETWORK_ID}
|
||||
|
||||
create_octavia_accounts
|
||||
create_octavia_accounts
|
||||
|
||||
add_load-balancer_roles
|
||||
add_load-balancer_roles
|
||||
|
||||
configure_rsyslog
|
||||
elif [ $OCTAVIA_NODE == 'api' ] ; then
|
||||
create_octavia_accounts
|
||||
configure_rsyslog
|
||||
elif [ $OCTAVIA_NODE == 'api' ] ; then
|
||||
create_octavia_accounts
|
||||
|
||||
add_load-balancer_roles
|
||||
fi
|
||||
add_load-balancer_roles
|
||||
fi
|
||||
|
||||
if [ $OCTAVIA_NODE != 'api' ] ; then
|
||||
create_mgmt_network_interface
|
||||
create_amphora_flavor
|
||||
configure_lb_mgmt_sec_grp
|
||||
fi
|
||||
if [ $OCTAVIA_NODE != 'api' ] ; then
|
||||
create_mgmt_network_interface
|
||||
create_amphora_flavor
|
||||
configure_lb_mgmt_sec_grp
|
||||
fi
|
||||
|
||||
if ! [ "$DISABLE_AMP_IMAGE_BUILD" == 'True' ]; then
|
||||
set_octavia_worker_image_owner_id
|
||||
fi
|
||||
if ! [ "$DISABLE_AMP_IMAGE_BUILD" == 'True' ]; then
|
||||
set_octavia_worker_image_owner_id
|
||||
fi
|
||||
}
|
||||
|
||||
function _configure_tempest {
|
||||
|
@ -18,11 +18,11 @@ source ${TOP_DIR}/stackrc
|
||||
DEST=${DEST:-/opt/stack}
|
||||
|
||||
# Polling functions
|
||||
function wait_for_loadbalancer_active() {
|
||||
lb_name=$1
|
||||
while [ $(openstack loadbalancer show $lb_name -f value -c provisioning_status) != "ACTIVE" ]; do
|
||||
sleep 2
|
||||
done
|
||||
function wait_for_loadbalancer_active {
|
||||
lb_name=$1
|
||||
while [ $(openstack loadbalancer show $lb_name -f value -c provisioning_status) != "ACTIVE" ]; do
|
||||
sleep 2
|
||||
done
|
||||
}
|
||||
|
||||
if is_service_enabled nova; then
|
||||
|
@ -21,8 +21,7 @@ PRIVATE_SUBNET_NAME=${PRIVATE_SUBNET_NAME:-"private-subnet"}
|
||||
# $3..n: command with arguments and parameters
|
||||
# TODO(cgoncalves): set timeout
|
||||
function _wait_for_status {
|
||||
while :
|
||||
do
|
||||
while true; do
|
||||
eval $("${@:3}" -f shell -c provisioning_status -c operating_status)
|
||||
[[ $operating_status == "ONLINE" && $provisioning_status == "ACTIVE" ]] && break
|
||||
if [ $provisioning_status == "ERROR" ]; then
|
||||
|
@ -1,4 +1,6 @@
|
||||
#!/bin/sh -v
|
||||
Body=$(hostname)
|
||||
Response="HTTP/1.1 200 OK\r\nContent-Length: ${#Body}\r\n\r\n$Body"
|
||||
while true ; do echo -e $Response | nc -llp 80; done
|
||||
while true; do
|
||||
echo -e $Response | nc -llp 80
|
||||
done
|
||||
|
@ -7,6 +7,7 @@ astroid==1.3.8
|
||||
automaton==1.14.0
|
||||
Babel==2.3.4
|
||||
bandit==1.4.0
|
||||
bashate==0.5.1
|
||||
bcrypt==3.1.4
|
||||
beautifulsoup4==4.6.0
|
||||
cachetools==2.0.1
|
||||
|
@ -21,3 +21,4 @@ tempest>=17.1.0 # Apache-2.0
|
||||
# Required for pep8 - doc8 tests
|
||||
sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
|
||||
sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
|
||||
bashate>=0.5.1 # Apache-2.0
|
||||
|
@ -25,8 +25,8 @@ FAILURES=$TMPDIR/failures
|
||||
|
||||
check_pot_files_errors () {
|
||||
find octavia -type f -regex '.*\.pot?' \
|
||||
-print0|xargs -0 -n 1 --no-run-if-empty msgfmt \
|
||||
--check-format -o /dev/null
|
||||
-print0|xargs -0 -n 1 --no-run-if-empty msgfmt \
|
||||
--check-format -o /dev/null
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo "PO files syntax is not correct!" >>$FAILURES
|
||||
fi
|
||||
|
16
tox.ini
16
tox.ini
@ -86,9 +86,11 @@ commands = flake8
|
||||
python -m unittest specs-tests.test_titles
|
||||
sh ./tools/misc-sanity-checks.sh
|
||||
{toxinidir}/tools/coding-checks.sh --pylint {posargs}
|
||||
{[testenv:bashate]commands}
|
||||
whitelist_externals =
|
||||
sh
|
||||
find
|
||||
bash
|
||||
|
||||
[testenv:docs]
|
||||
basepython = python3
|
||||
@ -166,6 +168,20 @@ import-order-style = pep8
|
||||
# [H904]: Delay string interpolations at logging calls
|
||||
enable-extensions=H106,H203,H204,H205,H904
|
||||
|
||||
[testenv:bashate]
|
||||
basepython = python3
|
||||
envdir = {toxworkdir}/shared
|
||||
commands = bash -c "find {toxinidir} \
|
||||
-not \( -type d -name .tox\* -prune \) \
|
||||
-not \( -type d -name .venv\* -prune \) \
|
||||
-type f \
|
||||
-name \*.sh \
|
||||
# [E005]: File does not begin with #! or have a .sh prefix
|
||||
# [E006]: Check for lines longer than 79 columns
|
||||
# [E042]: Local declaration hides errors
|
||||
# [E043]: Arithmetic compound has inconsistent return semantics
|
||||
-print0 | xargs -0 bashate -v -iE006 -eE005,E042,E043"
|
||||
|
||||
[hacking]
|
||||
import_exceptions = octavia.i18n
|
||||
local-check-factory = octavia.hacking.checks.factory
|
||||
|
Loading…
Reference in New Issue
Block a user