Update trymcp image
* add ability to specify gateway for Vm (DMZ case) via metadata;
* add missed copy for script adding default keycloak user;
Change-Id: If4e72c775031f23d67a01546c31c3e488ea516bd
Related-Prod: PROD-27660
diff --git a/trymcp-day01-image/files/etc/rc.local b/trymcp-day01-image/files/etc/rc.local
index 6b31cac..58c560c 100644
--- a/trymcp-day01-image/files/etc/rc.local
+++ b/trymcp-day01-image/files/etc/rc.local
@@ -11,9 +11,29 @@
#
# By default this script does nothing.
+update_from_metadata_fields() {
+ local metadataIp="169.254.169.254"
+ local metadataFiels=$(curl -s --connect-timeout 5 169.254.169.254/openstack/latest/meta_data.json | jq -r .meta)
+ if [ -n "${metadataFiels}" ]; then
+ local dmz=$(echo ${metadataFiels} | jq -r .dmz)
+ if [ "${dmz}" == "true" ]
+ local dmzGateway=$(echo ${metadataFiels} | jq -r .dmz_gateway)
+ if [ -n "${dmzGateway}" ]; then
+ local curDefault=$(ip r | grep 'default via' | cut -f 3 -d ' ')
+ if [ "${curDefault}" != "${dmzGateway}" ]; then
+ ip r del default
+ ip r add default via ${dmzGateway}
+ fi
+ fi
+ fi
+ fi
+}
+
if [ ! -f /tmp/bootstrap_interfaces ] && [ -d /srv/salt/reclass/nodes/_generated ]; then
sed -i "s/single_address:.*/single_address: $(hostname -I | cut -d ' ' -f 1)/g" /srv/salt/reclass/nodes/cfg01.*
touch /tmp/bootstrap_interfaces
fi
+update_from_metadata_fields || echo "Can't update settings from metadata fields"
+
exit 0