From cae4740ee2803e111705def2f53bcef1a5c11427 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 17 Aug 2015 11:01:39 -0400 Subject: [PATCH] os-net-config: add configure_safe_defaults This patch adds a new configure_safe_defaults function that is called on EXIT. If the exit code is non-zero the function executes code to configure DHCP on all active interfaces. Since DHCP is used to initially bootstrap all TripleO instances via the provisioning network this should always be a safe default and allow communication with Heat to persist if an invalid (breaking) network configuration change is pushed out. This would facilitate immediate Heat notification of the failure and subsequent Heat updates to potentially help correct the invalid network configuration. Change-Id: Ibccba1ee77aa13c85a78a75d2e6cd179f87d7d16 Depends-on: Ibe0e32bc09979bc68b92a722b2bfa383e77502a9 --- .../configure.d/20-os-net-config | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/elements/os-net-config/os-refresh-config/configure.d/20-os-net-config b/elements/os-net-config/os-refresh-config/configure.d/20-os-net-config index 572db79e3..2598067f1 100755 --- a/elements/os-net-config/os-refresh-config/configure.d/20-os-net-config +++ b/elements/os-net-config/os-refresh-config/configure.d/20-os-net-config @@ -48,9 +48,58 @@ function ping_metadata_ip() { fi } +function configure_safe_defaults() { + +[[ $? == 0 ]] && return 0 + +cat > /etc/os-net-config/dhcp_all_interfaces.yaml </dev/null + HAS_LINK="$(cat /sys/class/net/${iface}/carrier)" + + TRIES=10 + while [ "$HAS_LINK" == "0" -a $TRIES -gt 0 ]; do + HAS_LINK="$(cat /sys/class/net/${iface}/carrier)" + if [ "$HAS_LINK" == "1" ]; then + break + else + sleep 1 + fi + TRIES=$(( TRIES - 1 )) + done + if [ "$HAS_LINK" == "1" ] ; then +cat >> /etc/os-net-config/dhcp_all_interfaces.yaml <