summaryrefslogtreecommitdiffstats
path: root/ci/deploy.sh
diff options
context:
space:
mode:
authorBlaisonneau David <david.blaisonneau@orange.com>2017-03-31 18:38:53 +0200
committerBlaisonneau David <david.blaisonneau@orange.com>2017-03-31 18:42:03 +0200
commit50bab952e49d425b17c8306162bb3726a3ab6717 (patch)
treecdf0daecb629652f30e9d7eea37dee2255fce00d /ci/deploy.sh
parente3983c25772ce327684ed98b7600300bf3132471 (diff)
change default network gateway on containers with a public network
Change-Id: Ic6b08b2942e94e8d8b9e7f46519058fcf3536d74 Signed-off-by: Blaisonneau David <david.blaisonneau@orange.com>
Diffstat (limited to 'ci/deploy.sh')
-rwxr-xr-xci/deploy.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/ci/deploy.sh b/ci/deploy.sh
index 05fc462d..e1ec7a69 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -203,6 +203,32 @@ check_status
echo "...... deployment finished ......."
+
+echo "...... configuring public access ......."
+
+# translate bundle.yaml to json
+python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < bundles.yaml > bundles.json
+# get services list having a public interface
+srv_list=$(cat bundles.json | jq -r ".services | to_entries[] | {\"key\": .key, \"value\": .value[\"bindings\"]} | select (.value!=null) | select(.value[] | contains(\"public-api\"))".key)
+# get cnt list from service list
+cnt_list=$(for cnt in $srv_list; do juju status $cnt --format=json | jq -r ".machines[].containers | to_entries[]".key; done)
+# get public network gateway (supposing it is the first ip of the network)
+public_api_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"public\")".gateway)
+admin_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"admin\")".gateway)
+# set default gateway to public api gateway
+for cnt in $cnt_list; do
+ echo "changing default gw on $cnt"
+ juju ssh $cnt "sudo ip r d default && sudo ip r a default via $public_api_gw";
+ juju ssh $cnt "gw_dev=\$(ip r l | grep 'via $public_api_gw' | cut -d \ -f5) &&\
+ sudo cp /etc/network/interfaces /etc/network/interfaces.bak &&\
+ echo 'removing old default gateway' &&\
+ sudo perl -i -pe 's/^\ *gateway $admin_gw\n$//' /etc/network/interfaces &&\
+ sudo perl -i -pe \"s/iface \$gw_dev inet static/iface \$gw_dev inet static\\n gateway $public_api_gw/\" /etc/network/interfaces \
+ ";
+done
+
+echo "...... configure ......."
+
if [[ "$opnfvmodel" = "openstack" ]]; then
./openstack.sh "$opnfvsdn" "$opnfvlab" "$opnfvdistro" "$openstack" || true