Make scripts work on latest Atomic images

Remove git and jq dependency in most scripts, allowing to run them on
latest atomic images, or even distribute Kolla in the form of tarball.

The only remainings of git dependency are in the git pre-commit hook,
and in the image build scripts. We can remove the latter one and have
the scripts running in degraded mode if we really want to.

I opted for a python based approach to finding the top-level directory
for portability, ensuring consistent result on Linux and BSD, including
OSX.

Change-Id: I987174032d11b2e9d6a993c563b5dc877c15dd2d
This commit is contained in:
Martin André 2015-01-15 10:09:30 +09:00
parent 9723a796d3
commit 13799455c2
12 changed files with 39 additions and 36 deletions

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
./tools/start-all-services
./tools/start-all-replications

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
pods='
rabbitmq

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
services='
nova-compute

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
services='
ceilometer-api

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
./tools/stop-all-replications
./tools/stop-all-pods

View File

@ -1,21 +1,18 @@
#!/bin/sh
#!/bin/bash
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
# Delete the replication is not cleaning up its pods
# These pods need to be deleted according to their UUID
uuids=$(kubectl get pods -o json | jq '.[][].id' 2>/dev/null | grep -o -E '"[a-fA-F|0-9|\-]*' | cut -c 2- | grep '\-')
UUID_REGEX="[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}"
for uuid in $uuids; do
if [ $uuid ]; then
kubectl delete pod $uuid
pods=$(kubectl get pods -o template -t '{{range .items}}{{.id}} {{end}}')
for pod in $pods; do
if [[ $pod =~ $UUID_REGEX ]]; then
# Stopping a k8s replicationController doesn't delete the associated
# pods, which names are UUIDs.
# Assuming all pods named by UUID are leftover replication pods.
kubectl delete pod $pod
else
kubectl delete -f "k8s/pod/${pod}-pod.yaml" 2>/dev/null
fi
done
pods=$(kubectl get pods -o json| jq '.[][].id' 2>/dev/null)
# Removes quotes from jquery
pods=${pods//\"/}
for pod in $pods; do
kubectl delete -f "k8s/pod/${pod}-pod.yaml" 2>/dev/null
done

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
replication_ctrs=$(kubectl get replicationController | awk 'NR>1 {print $1}')

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
services=$(kubectl get services | awk 'NR>1 {print $1}')

View File

@ -1,6 +1,8 @@
#!/bin/sh
cd $(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
find docker -name Dockerfile | while read dockerfile; do
dir=${dockerfile%/*}
link=$(python -c 'import os,sys; print os.path.relpath(sys.argv[1], sys.argv[2])' \

View File

@ -1,9 +1,8 @@
#!/bin/sh
TOPLEVEL=$(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
cd $TOPLEVEL
git ls-files -z '*.json' |
find . -name '*.json' -print0 |
xargs -0 python tools/validate-json.py || exit 1

View File

@ -1,9 +1,8 @@
#!/bin/sh
TOPLEVEL=$(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
cd $TOPLEVEL
git ls-files -z '*/Dockerfile' |
find docker -name Dockerfile -print0 |
xargs -0 tools/validate-maintainer.sh || exit 1

View File

@ -1,9 +1,8 @@
#!/bin/sh
TOPLEVEL=$(git rev-parse --show-toplevel)
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
cd $TOPLEVEL
git ls-files -z '*.yaml' |
find . -name '*.yaml' -print0 |
xargs -0 python tools/validate-yaml.py || exit 1