From 930663240b5221abaef910bd315e3e25104aed5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Fri, 21 Jan 2022 16:28:08 +0100 Subject: [PATCH] node extract provisioned - warning no net_conf tpl Add a warning to the baremetal_deployment.yaml generated with the node extract provisioned command in case no network config was found for a role in the deployed stack. This is always true if the current stack is pre-Victoria, since the command looks for Ansible J2 template. pre-Victoria used Heat template so the template parameter won't be set. Change-Id: I6789799480a1391b92336e2518a2ac2b800288e5 (cherry picked from commit 90ee1b3a72c61302c13567cc75053735172cb7d0) --- .../tests/v1/overcloud_node/test_overcloud_node.py | 11 +++++++---- tripleoclient/v1/overcloud_node.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py b/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py index ab3ab85d7..775a7390b 100644 --- a/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py +++ b/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py @@ -751,7 +751,6 @@ class TestExtractProvisionedNode(test_utils.TestCommand): 'parameters': { 'ComputeHostnameFormat': '%stackname%-novacompute-%index%', 'ControllerHostnameFormat': '%stackname%-controller-%index%', - 'ComputeNetworkConfigTemplate': 'templates/compute.j2', 'ControllerNetworkConfigTemplate': 'templates/controller.j2' }, 'outputs': [{ @@ -927,7 +926,7 @@ class TestExtractProvisionedNode(test_utils.TestCommand): 'network_config': {'network_config_update': False, 'physical_bridge_name': 'br-ex', 'public_interface_name': 'nic1', - 'template': 'templates/compute.j2'}, + 'template': None}, 'networks': [{'network': 'ctlplane', 'vif': True}, {'network': 'internal_api', @@ -968,7 +967,11 @@ class TestExtractProvisionedNode(test_utils.TestCommand): }], yaml.safe_load(result)) with open(self.extract_file.name) as f: - self.assertEqual(yaml.safe_load(result), yaml.safe_load(f)) + file_content = f.read() + self.assertEqual(yaml.safe_load(result), yaml.safe_load(file_content)) + self.assertIn('# WARNING: No network config found for role Compute. ' + 'Please edit the file and set the path to the correct ' + 'network config template.\n', file_content) def test_extract_ips_from_pool(self): stack = mock.Mock() @@ -1006,7 +1009,7 @@ class TestExtractProvisionedNode(test_utils.TestCommand): 'network_config': {'network_config_update': False, 'physical_bridge_name': 'br-ex', 'public_interface_name': 'nic1', - 'template': 'templates/compute.j2'}, + 'template': None}, 'networks': [{'network': 'ctlplane', 'vif': True}, {'network': 'internal_api', diff --git a/tripleoclient/v1/overcloud_node.py b/tripleoclient/v1/overcloud_node.py index b55a84296..af8e82a7d 100644 --- a/tripleoclient/v1/overcloud_node.py +++ b/tripleoclient/v1/overcloud_node.py @@ -550,6 +550,7 @@ class ExtractProvisionedNode(command.Command): hostname_node_map[hostname] = node.name data = [] + warnings = [] for role_name, entries in host_vars.items(): role_count = len(entries) @@ -588,6 +589,11 @@ class ExtractProvisionedNode(command.Command): net_conf = defaults['network_config'] = {} net_conf['template'] = parameters.get( role_name + 'NetworkConfigTemplate') + if net_conf['template'] is None: + warnings.append( + 'WARNING: No network config found for role {}. Please ' + 'edit the file and set the path to the correct network ' + 'config template.'.format(role_name)) if parameters.get(role_name + 'NetworkDeploymentActions'): network_deployment_actions = parameters.get( @@ -649,6 +655,11 @@ class ExtractProvisionedNode(command.Command): datetime.datetime.now().isoformat()) file_data.write('# openstack %s\n#\n\n' % ' '.join(self.app.command_options)) + # Write any warnings in the file header + for warning in warnings: + file_data.write('# {}\n'.format(warning)) + if warnings: + file_data.write(('#\n\n')) # Write the data if data: yaml.dump(data, file_data, RoleDataDumper, width=120,