From 06a82e0ebf5a9e2016bf17d1c272e650e11e9fe6 Mon Sep 17 00:00:00 2001 From: Srinivas Atmakuri Date: Tue, 4 May 2021 17:15:32 +0530 Subject: [PATCH] make net_config_override of undercloud.conf work with yaml On setting net_config_override parameter, the undercloud uses a JSON or YAML format template to configure the networking with os-net-config and ignores the network parameters set in undercloud.conf. We can use this parameter when we want to configure bonding or add an option to the interface. This patch will allow net_config_override to work with a json or a yaml as an input. Closes-Bug: #1927090 Change-Id: I5f5cec5a1622be4983b4d0db392453d1c489fa40 (cherry picked from commit 253bd6e7db425f2340e8b47319cd527a5210333d) --- tripleoclient/config/standalone.py | 2 +- tripleoclient/v1/undercloud_config.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tripleoclient/config/standalone.py b/tripleoclient/config/standalone.py index 29d5bbd01..259d315c0 100644 --- a/tripleoclient/config/standalone.py +++ b/tripleoclient/config/standalone.py @@ -137,7 +137,7 @@ class StandaloneConfig(BaseConfig): help=_( 'Path to network config override template. ' 'Relative paths get computed inside of $HOME. ' - 'Must be in the json format. ' + 'Must be in the json or yaml format. ' 'Its content overrides anything in t-h-t ' 'NetConfigOverride. The processed ' 'template is then passed in Heat via the ' diff --git a/tripleoclient/v1/undercloud_config.py b/tripleoclient/v1/undercloud_config.py index 0aa7ecb63..4589f16c0 100644 --- a/tripleoclient/v1/undercloud_config.py +++ b/tripleoclient/v1/undercloud_config.py @@ -15,7 +15,7 @@ """Plugin action implementation""" -import json +import yaml import logging import netaddr import os @@ -786,9 +786,9 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=True, os.path.split(data_file)[-1]).render(context).replace( "'", '"').replace('"', '"') try: - net_config_json = json.loads(net_config_str) + net_config_json = yaml.safe_load(net_config_str) except ValueError: - net_config_json = json.loads("{%s}" % net_config_str) + net_config_json = yaml.safe_load("{%s}" % net_config_str) if 'network_config' not in net_config_json: msg = ('Unsupported data format in net_config_override '