From 9c997ff0945e2771a857c6859120af381d480505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Mon, 28 Jun 2021 17:49:37 +0200 Subject: [PATCH] Add '--templates' arg to node and net provision Allow setting '--templates', the path tot the THT root directory. Environment files created by the node and network provision commands will be created with the user specified path to the THT root. Defaults to: /usr/share/openstack-tripleo-heat-templates/ Closes-Bug: #1932079 Depends-On: I9decd8fb9860cd17dc9e69b9970d9f9dabf11428 Change-Id: I5dd81788c08bb0d797190a5fb8bb120b7d8b4f32 --- .../overcloud_deploy/test_overcloud_deploy.py | 25 +++++++++++++------ .../test_overcloud_network.py | 4 ++- .../v2/overcloud_node/test_overcloud_node.py | 3 ++- tripleoclient/v1/overcloud_deploy.py | 5 +++- tripleoclient/v2/overcloud_network.py | 14 +++++++++-- tripleoclient/v2/overcloud_node.py | 7 +++++- 6 files changed, 44 insertions(+), 14 deletions(-) diff --git a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py index 43ea7b4dd..42dc54a46 100644 --- a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py +++ b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py @@ -1478,11 +1478,13 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): arglist = [ '--baremetal-deployment', bm_deploy_path, - '--overcloud-ssh-key', ssh_key_path + '--overcloud-ssh-key', ssh_key_path, + '--templates', constants.TRIPLEO_HEAT_TEMPLATES, ] verifylist = [ ('baremetal_deployment', bm_deploy_path), ('overcloud_ssh_key', ssh_key_path), + ('templates', constants.TRIPLEO_HEAT_TEMPLATES) ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -1512,7 +1514,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): 'ssh_private_key_file': self.tmp_dir.join('id_rsa.pub'), 'manage_network_ports': False, 'configure_networking': False, - 'working_dir': self.tmp_dir.join('working_dir') + 'working_dir': self.tmp_dir.join('working_dir'), + 'templates': constants.TRIPLEO_HEAT_TEMPLATES, }, inventory='localhost,', playbook='cli-overcloud-node-provision.yaml', @@ -1546,8 +1549,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): with open(networks_file_path, 'w') as temp_file: yaml.safe_dump(network_data, temp_file) - arglist = ['--networks-file', networks_file_path] - verifylist = [('networks_file', networks_file_path)] + arglist = ['--networks-file', networks_file_path, + '--templates', constants.TRIPLEO_HEAT_TEMPLATES] + verifylist = [('networks_file', networks_file_path), + ('templates', constants.TRIPLEO_HEAT_TEMPLATES)] parsed_args = self.check_parser(self.cmd, arglist, verifylist) tht_root = self.tmp_dir.join('tht') @@ -1560,7 +1565,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): self.mock_playbook.assert_called_once_with( extra_vars={'network_data_path': networks_file_path, 'network_deployed_path': env_path, - 'overwrite': True}, + 'overwrite': True, + 'templates': constants.TRIPLEO_HEAT_TEMPLATES}, inventory='localhost,', playbook='cli-overcloud-network-provision.yaml', playbook_dir='/usr/share/ansible/tripleo-playbooks', @@ -1584,10 +1590,12 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): stack_name = 'overcloud' arglist = ['--stack', stack_name, '--vip-file', vips_file_path, - '--networks-file', networks_file_path] + '--networks-file', networks_file_path, + '--templates', constants.TRIPLEO_HEAT_TEMPLATES] verifylist = [('stack', stack_name), ('vip_file', vips_file_path), - ('networks_file', networks_file_path)] + ('networks_file', networks_file_path), + ('templates', constants.TRIPLEO_HEAT_TEMPLATES)] parsed_args = self.check_parser(self.cmd, arglist, verifylist) tht_root = self.tmp_dir.join('tht') @@ -1601,7 +1609,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): extra_vars={'stack_name': stack_name, 'vip_data_path': vips_file_path, 'vip_deployed_path': env_path, - 'overwrite': True}, + 'overwrite': True, + 'templates': constants.TRIPLEO_HEAT_TEMPLATES}, inventory='localhost,', playbook='cli-overcloud-network-vip-provision.yaml', playbook_dir='/usr/share/ansible/tripleo-playbooks', diff --git a/tripleoclient/tests/v2/overcloud_network/test_overcloud_network.py b/tripleoclient/tests/v2/overcloud_network/test_overcloud_network.py index 4c1011652..50067813a 100644 --- a/tripleoclient/tests/v2/overcloud_network/test_overcloud_network.py +++ b/tripleoclient/tests/v2/overcloud_network/test_overcloud_network.py @@ -17,6 +17,7 @@ import mock from osc_lib import exceptions as osc_lib_exc +from tripleoclient import constants from tripleoclient.tests import fakes from tripleoclient.v2 import overcloud_network @@ -102,7 +103,8 @@ class TestOvercloudNetworkProvision(fakes.FakePlaybookExecution): extra_vars={ "network_data_path": '/test/network_data_v2.yaml', "network_deployed_path": '/test/deployed_networks.yaml', - "overwrite": True + "overwrite": True, + 'templates': constants.TRIPLEO_HEAT_TEMPLATES, } ) diff --git a/tripleoclient/tests/v2/overcloud_node/test_overcloud_node.py b/tripleoclient/tests/v2/overcloud_node/test_overcloud_node.py index d72a3beb4..e5979afed 100644 --- a/tripleoclient/tests/v2/overcloud_node/test_overcloud_node.py +++ b/tripleoclient/tests/v2/overcloud_node/test_overcloud_node.py @@ -354,6 +354,7 @@ class TestProvisionNode(fakes.TestOvercloudNode): 'manage_network_ports': False, 'configure_networking': False, 'working_dir': mock.ANY, + 'templates': constants.TRIPLEO_HEAT_TEMPLATES, }, inventory='localhost,', playbook='cli-overcloud-node-provision.yaml', @@ -411,7 +412,7 @@ class TestUnprovisionNode(fakes.TestOvercloudNode): playbook='cli-overcloud-node-unprovision.yaml', playbook_dir='/usr/share/ansible/tripleo-playbooks', verbosity=mock.ANY, - workdir=tmp + workdir=tmp, ), mock.call( extra_vars={ diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index d4804f891..3b1c6158a 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -454,7 +454,8 @@ class DeployOvercloud(command.Command): "manage_network_ports": (parsed_args.network_ports or parsed_args.network_config), "configure_networking": parsed_args.network_config, - "working_dir": self.working_dir + "working_dir": self.working_dir, + "templates": parsed_args.templates, } with utils.TempDirs() as tmp: @@ -512,6 +513,7 @@ class DeployOvercloud(command.Command): "network_data_path": networks_file_path, "network_deployed_path": output_path, "overwrite": True, + "templates": parsed_args.templates, } with utils.TempDirs() as tmp: @@ -543,6 +545,7 @@ class DeployOvercloud(command.Command): "vip_data_path": vip_file_path, "vip_deployed_path": output_path, "overwrite": True, + "templates": parsed_args.templates, } with utils.TempDirs() as tmp: diff --git a/tripleoclient/v2/overcloud_network.py b/tripleoclient/v2/overcloud_network.py index 0c0ae4ffc..60814520a 100644 --- a/tripleoclient/v2/overcloud_network.py +++ b/tripleoclient/v2/overcloud_network.py @@ -96,6 +96,10 @@ class OvercloudNetworkProvision(command.Command): parser.add_argument('-y', '--yes', default=False, action='store_true', help=_('Skip yes/no prompt for existing files ' '(assume yes).')) + parser.add_argument('--templates', + help=_("The directory containing the Heat " + "templates to deploy"), + default=constants.TRIPLEO_HEAT_TEMPLATES) return parser @@ -123,7 +127,8 @@ class OvercloudNetworkProvision(command.Command): extra_vars = { "network_data_path": networks_file_path, "network_deployed_path": output_path, - "overwrite": overwrite + "overwrite": overwrite, + "templates": parsed_args.templates, } with oooutils.TempDirs() as tmp: @@ -214,6 +219,10 @@ class OvercloudVirtualIPsProvision(command.Command): parser.add_argument('-y', '--yes', default=False, action='store_true', help=_('Skip yes/no prompt for existing files ' '(assume yes).')) + parser.add_argument('--templates', + help=_("The directory containing the Heat " + "templates to deploy"), + default=constants.TRIPLEO_HEAT_TEMPLATES) return parser @@ -242,7 +251,8 @@ class OvercloudVirtualIPsProvision(command.Command): "stack_name": parsed_args.stack, "vip_data_path": vip_file_path, "vip_deployed_path": output_path, - "overwrite": overwrite + "overwrite": overwrite, + "templates": parsed_args.templates, } with oooutils.TempDirs() as tmp: diff --git a/tripleoclient/v2/overcloud_node.py b/tripleoclient/v2/overcloud_node.py index 6ef38ec28..474619b2d 100644 --- a/tripleoclient/v2/overcloud_node.py +++ b/tripleoclient/v2/overcloud_node.py @@ -262,6 +262,10 @@ class ProvisionNode(command.Command): 'nodes. (Implies "--network-ports")'), default=False, action="store_true") + parser.add_argument('--templates', + help=_("The directory containing the Heat " + "templates to deploy"), + default=constants.TRIPLEO_HEAT_TEMPLATES) parser.add_argument( '--working-dir', action='store', help=_('The working directory for the deployment where all ' @@ -314,7 +318,8 @@ class ProvisionNode(command.Command): "manage_network_ports": (parsed_args.network_ports or parsed_args.network_config), "configure_networking": parsed_args.network_config, - "working_dir": working_dir + "working_dir": working_dir, + "templates": parsed_args.templates, } with oooutils.TempDirs() as tmp: