This gets all network info from config_data and parses all instances and their NICs and makes the substitution.
Signed-off-by: Dimitris Aragiorgis <[email protected]> --- tools/cfgupgrade | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/cfgupgrade b/tools/cfgupgrade index bccb34e..d538284 100755 --- a/tools/cfgupgrade +++ b/tools/cfgupgrade @@ -110,6 +110,18 @@ def UpgradeGroups(config_data): if not networks: group["networks"] = {} +def UpgradeInstances(config_data): + network2uuid = dict((n["name"], n["uuid"]) + for n in config_data["networks"].values()) + for inst in config_data["instances"].values(): + for nic in inst["nics"]: + name = nic.get("network", None) + if name: + uuid = network2uuid.get(name, None) + if uuid: + print("NIC with network name %s found." + " Substituting with uuid %s." % (name, uuid)) + nic["network"] = uuid def main(): """Main program. @@ -294,6 +306,7 @@ def main(): UpgradeNetworks(config_data) UpgradeGroups(config_data) + UpgradeInstances(config_data) try: logging.info("Writing configuration file to %s", options.CONFIG_DATA_PATH) -- 1.7.10.4
