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
(cherry picked from commit 9c997ff094)
This commit is contained in:
Harald Jensås 2021-06-28 17:49:37 +02:00
parent 84f35aeef7
commit 4e097d5409
6 changed files with 44 additions and 14 deletions

View File

@ -1490,11 +1490,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)
@ -1524,7 +1526,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',
@ -1558,8 +1561,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')
@ -1572,7 +1577,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',
@ -1596,10 +1602,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')
@ -1613,7 +1621,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',

View File

@ -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,
}
)

View File

@ -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={

View File

@ -593,7 +593,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:
@ -651,6 +652,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:
@ -682,6 +684,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:

View File

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

View File

@ -261,6 +261,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 '
@ -305,7 +309,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: