Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some linter warnings, part 1 #201

Merged
merged 5 commits into from
Sep 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions elasticsearch-init/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ TPL_DIR=/templates

_get_tpl_name_from_file() {
local tpl=$1
local tpl_name=$(basename $tpl)
echo $tpl_name
local tpl_name
tpl_name=$(basename "$tpl")
echo "$tpl_name"
}

if [ ! -d $TPL_DIR ]; then
Expand All @@ -18,10 +19,8 @@ fi
for template in $TPLS; do

echo "Handling template file $template"
tpl_name=`_get_tpl_name_from_file $template`
tpl_name=`_get_tpl_name_from_file "$template"`

curl -XPUT --retry 2 --retry-delay 2 $ELASTICSEARCH_URI/_template/${tpl_name} -d @$TPL_DIR/$template
curl -XPUT --retry 2 --retry-delay 2 "$ELASTICSEARCH_URI"/_template/"${tpl_name}" -d @$TPL_DIR/"$template"

done


8 changes: 4 additions & 4 deletions elasticsearch-init/wait-for.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/sh

: ${SLEEP_LENGTH:=2}
: "${SLEEP_LENGTH:=2}"

wait_for() {
echo Waiting for $1 to listen on $2...
while ! nc -z $1 $2; do echo sleeping; sleep $SLEEP_LENGTH; done
echo "Waiting for $1 to listen on $2..."
while ! nc -z "$1" "$2"; do echo sleeping; sleep "$SLEEP_LENGTH"; done
}

for var in "$@"
do
host=${var%:*}
port=${var#*:}
wait_for $host $port
wait_for "$host" "$port"
done
10 changes: 5 additions & 5 deletions monasca-python/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ else

if [ "z$extra_deps" != "z" ]; then
for extra in $extra_deps; do
pip install --no-cache-dir $extra -c $constraints
pip install --no-cache-dir "$extra" -c "$constraints"
done
else
echo "No extra dependencies"
fi

if [ "z$extras" != "z" ]; then
for extra in $extras; do
pip install --no-cache-dir .[${extra}] -c $constraints
pip install --no-cache-dir .["${extra}"] -c "$constraints"
done
else
echo "No extras"
fi

pip install --no-cache-dir -r requirements.txt -c $constraints
pip install --no-cache-dir -r requirements.txt -c "$constraints"
python setup.py install
}
fi
Expand Down Expand Up @@ -101,7 +101,7 @@ EXTRA_DEPS="${EXTRA_DEPS:-""}"

echo "Installing APK Dependencies" && install_apk_deps
mkdir -p /app
cd /app
cd /app || exit

# actual build happens here
cat << EOF
Expand All @@ -115,7 +115,7 @@ echo "Cloning ${REPO}@${BRANCH}" && clone "${REPO}" "${BRANCH}"
echo "Installing ${REPO}" && install "${CONSTRAINTS}" "${EXTRAS}" "${EXTRA_DEPS}"
# end of actual build

cd -
cd - || exit
rm -rf /install.sh /clone.sh /install_apk_deps.sh /app /root/.cache/pip

apk del build-dep
3 changes: 2 additions & 1 deletion smoke-tests/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export OS_DOMAIN_NAME=${OS_DOMAIN_NAME:-"Default"}
export OS_AUTH_URL=${OS_AUTH_URL:-"http://keystone:35357/v3"}
export MONASCA_URL=${MONASCA_URL:-"http://monasca-api:8070"}

export WEBHOOK_IP=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}')
export WEBHOOK_IP
WEBHOOK_IP=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}')

/smoke-test
4 changes: 2 additions & 2 deletions tempest-tests/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if [ "$MONASCA_WAIT_FOR_API" = "true" ]; then
echo "Waiting for Monasca API to become available..."
success="false"

for i in $(seq $MONASCA_API_WAIT_RETRIES); do
for i in $(seq "$MONASCA_API_WAIT_RETRIES"); do
monasca --os-user-domain-name "${OS_DOMAIN_NAME}" --os-project-name "${OS_TENANT_NAME}" \
--os-auth-url "${AUTH_URI_V3}" --os-username "${OS_USERNAME}" \
--os-password "${OS_PASSWORD}" alarm-list --limit 1
Expand All @@ -60,7 +60,7 @@ python template.py \
/etc/tempest/tempest.conf.j2 \
/etc/tempest/tempest.conf

cd /monasca-api
cd /monasca-api || exit
export OS_TEST_PATH=./monasca_tempest_tests/tests/api

if [ ! -r .testrepository ]; then
Expand Down
7 changes: 5 additions & 2 deletions tempest-tests/template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# coding=utf-8

# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
#
Expand All @@ -13,6 +14,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from __future__ import print_function

import os
Expand All @@ -30,8 +32,9 @@ def main():
out_path = sys.argv[2]

with open(in_path, 'r') as in_file, open(out_path, 'w') as out_file:
t = Template(in_file.read())
out_file.write(t.render(os.environ))
tmt = Template(in_file.read())
out_file.write(tmt.render(os.environ))


if __name__ == '__main__':
main()