From 61752801c01031ff780648c15eeab395a6c35ed0 Mon Sep 17 00:00:00 2001 From: Lukas Bezdicka Date: Wed, 20 Jul 2022 16:22:11 +0200 Subject: [PATCH] [ffwd3] Create nework_environment during node_extraction When extracting nodes from stack during Undercloud upgrade we should also extract network environment so we can use it during the subsequent Overcloud upgrade. Change-Id: Ic86c1cab0b5e79326c52098ebf1b3369a6cd3da2 --- tripleoclient/v1/overcloud_node.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tripleoclient/v1/overcloud_node.py b/tripleoclient/v1/overcloud_node.py index cad3f316a..2c0cb3831 100644 --- a/tripleoclient/v1/overcloud_node.py +++ b/tripleoclient/v1/overcloud_node.py @@ -666,9 +666,17 @@ class ExtractProvisionedNode(command.Command): data = [] warnings = [] + network_environment = {'resource_registry': {}, + 'parameter_defaults': {}} for role_name, entries in host_vars.items(): role_count = len(entries) + net_parameter_defaults = {} + net_resource_registry = { + "OS::TripleO::{}::Net::SoftwareConfig".format(role_name): + "OS::Heat::None"} + network_environment['resource_registry'].update( + net_resource_registry) # skip zero count roles if not role_count: continue @@ -715,6 +723,9 @@ class ExtractProvisionedNode(command.Command): 'Please edit the file and set the path to the correct ' 'network config template.'.format(role_name)) else: + net_parameter_defaults = { + "{}NetworkConfigTemplate".format(role_name): + "{}".format(net_conf['template'])} warnings.append( 'WARNING: Network config for role {} was ' 'automatically converted from Heat template to ' @@ -775,7 +786,9 @@ class ExtractProvisionedNode(command.Command): role_net_ip_map[role_name][net['network']][idx]) instances.append(instance) - + if net_parameter_defaults != {}: + network_environment['parameter_defaults'].update( + net_parameter_defaults) data.append(role) # Write the file header @@ -794,6 +807,15 @@ class ExtractProvisionedNode(command.Command): yaml.dump(data, file_data, RoleDataDumper, width=120, default_flow_style=False) + if len(network_environment['parameter_defaults']) > 0: + net_env_file = os.path.join(self.working_dir, + "{}-network-environment.yaml".format( + parsed_args.stack)) + with open(net_env_file, 'w+') as nfp: + nfp.write(yaml.dump(network_environment, + width=120, + default_flow_style=False)) + if parsed_args.output: if (os.path.exists(parsed_args.output) and not parsed_args.yes and sys.stdin.isatty()):