Merge "[ffwd3] Create nework_environment during node_extraction"

This commit is contained in:
Zuul 2023-03-24 00:40:25 +00:00 committed by Gerrit Code Review
commit 75c5f4057e

View File

@ -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()):