From 0017b64560074032b09b18b349c2ba1d8b71196b Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Tue, 6 Mar 2018 13:50:02 -0500 Subject: [PATCH] Add check for old-style nic config files Since old-style nic config files can no longer be used in Queens or Rocky (the format changed in Ocata), add a check in yaml-validate to detect that old-style files are in use and list conversion script that can be used. Made some changes to the script to ask before overwriting the nic config file and save a datestamped copy as backup. In addition, the script now takes an optional parameter to define location of run-os-net-config.sh. Change-Id: Ic56c48fa35ab2f4c1762c0e370be03fbf2e7671c Closes-Bug: 1753812 --- ...old-style-nic-config-4624a60e3303411b.yaml | 5 + tools/yaml-nic-config-2-script.py | 115 ++++++++++++------ tools/yaml-validate.py | 20 +++ 3 files changed, 105 insertions(+), 35 deletions(-) create mode 100644 releasenotes/notes/check-old-style-nic-config-4624a60e3303411b.yaml diff --git a/releasenotes/notes/check-old-style-nic-config-4624a60e3303411b.yaml b/releasenotes/notes/check-old-style-nic-config-4624a60e3303411b.yaml new file mode 100644 index 0000000000..4af632489d --- /dev/null +++ b/releasenotes/notes/check-old-style-nic-config-4624a60e3303411b.yaml @@ -0,0 +1,5 @@ +--- +other: + - Add check for nic config files using the old style format + (os-apply-config) and list the script that can be used + to convert the file. diff --git a/tools/yaml-nic-config-2-script.py b/tools/yaml-nic-config-2-script.py index cdda108f1f..8aba1f364b 100755 --- a/tools/yaml-nic-config-2-script.py +++ b/tools/yaml-nic-config-2-script.py @@ -11,15 +11,31 @@ # License for the specific language governing permissions and limitations # under the License. +import argparse import collections import copy +import datetime import os +import shutil import sys import traceback import yaml import six import re +def parse_opts(argv): + parser = argparse.ArgumentParser( + description='Convert an old style NIC config file into the new format using ' + 'run-os-net-config.sh') + parser.add_argument('--script-dir', metavar='