Skip to content

Commit 996ff5d

Browse files
committed
New gaol-basher script for BOSH-lite warden
1 parent 42fb909 commit 996ff5d

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

ci/release_notes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# New Features
2+
3+
- The `toolbelt-gaol` package now includes a new script,
4+
`gaol-basher`, that makes it easier to log into BOSH-lite warden
5+
containers via gaol.

packages/toolbelt-gaol/packaging

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ CPUS=$(grep -c ^processor /proc/cpuinfo)
99
export HOME=/var/vcap
1010
mkdir -p ${BOSH_INSTALL_TARGET}/bin
1111
cp gaol/gaol-linux64 ${BOSH_INSTALL_TARGET}/bin/gaol
12-
chmod 755 ${BOSH_INSTALL_TARGET}/bin/gaol
13-
14-
12+
cp gaol/gaol-basher ${BOSH_INSTALL_TARGET}/bin/gaol-basher
13+
chmod 755 ${BOSH_INSTALL_TARGET}/bin/*

packages/toolbelt-gaol/spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ files:
55
# checkout from https://github.com/contraband/gaol
66
# gox -osarch linux/amd64
77
- gaol/gaol-linux64
8+
- gaol/gaol-basher
89

src/gaol/gaol-basher

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
DEPLOYMENT_ID=""
4+
CONTAINER_ID=""
5+
6+
help() {
7+
echo -e "\nGaol Basher: A tool that makes connecting to bosh-lite Garden containers easy!"
8+
echo -e "\nUSAGE:"
9+
echo -e "------"
10+
echo -e "$0 <command> <parameter>"
11+
echo -e "\nCommands:"
12+
echo -e "---------"
13+
echo -e "help Displays this message."
14+
echo -e "deployments Prints the list of deployments."
15+
echo -e "jobs <deployment name> Prints the list of jobs for the deployment."
16+
echo -e "bash <job number> Initiates a bash session with the Garden container using Gaol.\n"
17+
echo -e "Go directly to Gaol. Do not pass Go, do not collect \$200.\n"
18+
}
19+
20+
get_deployments() {
21+
echo -e "\nDeployments:"
22+
echo -e "------------"
23+
/var/vcap/packages/postgres/bin/psql -c "select id, name from deployments;" bosh
24+
}
25+
26+
get_jobs() {
27+
echo -e "\nJobs:"
28+
echo -e "------"
29+
/var/vcap/packages/postgres/bin/psql -c "select id as job_number, job || '/' || index as job, vm_cid as container_uuid from instances WHERE vm_cid IS NOT NULL AND deployment_id = $1;" bosh
30+
}
31+
32+
get_job_container_uuid () {
33+
CONTAINER_ID=$(/var/vcap/packages/postgres/bin/psql -t -c "select vm_cid from instances WHERE id = '$1';" bosh | awk '$1=$1')
34+
}
35+
36+
get_deployment_id() {
37+
DEPLOYMENT_ID=$(/var/vcap/packages/postgres/bin/psql -t -c "select id from deployments where name = '$1';" bosh | awk '$1=$1')
38+
}
39+
40+
if [[ "$1" = "deployments" ]]; then
41+
get_deployments
42+
exit 0
43+
fi
44+
45+
if [[ "$1" = "jobs" && "$2" != "" ]]; then
46+
get_deployment_id $2
47+
if [[ -z "$DEPLOYMENT_ID" ]]; then
48+
echo "Deployment name "$2" not found."
49+
exit 0
50+
fi
51+
get_jobs $DEPLOYMENT_ID
52+
exit 0
53+
fi
54+
55+
if [[ "$1" = "bash" && "$2" != "" ]]; then
56+
get_job_container_uuid $2
57+
if [[ -z "$CONTAINER_ID" ]]; then
58+
echo "Job number "$2" not found."
59+
exit 0
60+
fi
61+
/var/vcap/packages/toolbelt-gaol/bin/gaol shell $CONTAINER_ID
62+
exit 0
63+
fi
64+
65+
help

0 commit comments

Comments
 (0)