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
This commit is contained in:
Dan Sneddon 2019-02-20 15:34:29 -08:00
parent 6f73f44a28
commit 5e5c5cdd71
1 changed files with 8 additions and 2 deletions

View File

@ -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