From 5e5c5cdd71d91db14a3d0c7274286882d5a99d93 Mon Sep 17 00:00:00 2001 From: Dan Sneddon Date: Wed, 20 Feb 2019 15:34:29 -0800 Subject: [PATCH] Backup /etc/os-net-config/config.json when os-net-config runs Currently os-net-config is called by TripleO with either the config.json or element_config.json configuration, and then the configuration file is deleted after os-net-config runs. This makes it more difficult to troubleshoot a deployment, since there is no reference file for the network config which was applied. This change renames the file and appends the date_time to the file name to preserve the file for troubleshooting. Closes-bug: 1816920 Change-Id: I79a6c5428958c1508eb16f91096cb96d7ddc03f6 --- network/scripts/run-os-net-config.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/network/scripts/run-os-net-config.sh b/network/scripts/run-os-net-config.sh index c0a9aff7ee..46532c72d8 100755 --- a/network/scripts/run-os-net-config.sh +++ b/network/scripts/run-os-net-config.sh @@ -122,6 +122,12 @@ if [ -n '$network_config' ]; then trap configure_safe_defaults EXIT fi + # Backup the old /etc/os-net-config/config.json, if it exists + DATETIME=`date +"%Y-%m-%dT%H:%M:%S"` + if [ -f /etc/os-net-config/config.json ]; then + mv /etc/os-net-config/config.json /etc/os-net-config/config.json.$DATETIME + fi + mkdir -p /etc/os-net-config # Note these variables come from the calling heat SoftwareConfig echo '$network_config' > /etc/os-net-config/config.json @@ -156,9 +162,9 @@ if [ -n '$network_config' ]; then # Remove files used by os-apply-config for old style configs if [ -f /usr/libexec/os-apply-config/templates/etc/os-net-config/config.json ]; then - rm /usr/libexec/os-apply-config/templates/etc/os-net-config/config.json + mv /usr/libexec/os-apply-config/templates/etc/os-net-config/config.json /usr/libexec/os-apply-config/templates/etc/os-net-config/config.json.$DATETIME fi if [ -f /usr/libexec/os-apply-config/templates/etc/os-net-config/element_config.json ]; then - rm /usr/libexec/os-apply-config/templates/etc/os-net-config/element_config.json + mv /usr/libexec/os-apply-config/templates/etc/os-net-config/element_config.json /usr/libexec/os-apply-config/templates/etc/os-net-config/element_config.json.$DATETIME fi fi