Clarify error when a template is missing
Currently when passing a non-existing template the following error is
output:
$ openstack overcloud deploy --templates -e /tmp/nonexistant.yaml
Deploying templates in the directory /usr/share/openstack-tripleo-heat-templates
The files ('overcloud-without-mergepy.yaml', 'overcloud.yaml') not found
in the /usr/share/openstack-tripleo-heat-templates/ directory
Add a proper error instead:
$ openstack overcloud deploy --templates -e /tmp/nonexistant.yaml -e /tmp/foo2.yaml
Deploying templates in the directory /usr/share/openstack-tripleo-heat-templates
Error: The following files were not found: /tmp/nonexistant.yaml, /tmp/foo2.yaml
Change-Id: I05bcd5e42d553cdac507d5e31a63cbcef4ab975c
Closes-Bug: #1548385
This commit is contained in:
@@ -733,6 +733,20 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.cmd._validate_args,
|
||||
parsed_args)
|
||||
|
||||
def test_validate_args_missing_environment_files(self):
|
||||
arglist = ['--templates',
|
||||
'-e', 'nonexistent.yaml']
|
||||
verifylist = [
|
||||
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
|
||||
('environment_files', ['nonexistent.yaml']),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.assertRaises(oscexc.CommandError,
|
||||
self.cmd._validate_args,
|
||||
parsed_args)
|
||||
|
||||
def test_validate_args_no_tunnel_type(self):
|
||||
arglist = ['--templates',
|
||||
'--neutron-network-type', 'nettype']
|
||||
@@ -919,25 +933,27 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
net.configure_mock(__getitem__=lambda x, y: 'testnet')
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode="w+t") as answerfile:
|
||||
yaml.dump(
|
||||
{'templates': '/dev/null',
|
||||
'environments': ['/tmp/foo.yaml']
|
||||
},
|
||||
answerfile
|
||||
)
|
||||
answerfile.flush()
|
||||
with open('/tmp/environment.yaml', "w+t") as environmentfile:
|
||||
yaml.dump(
|
||||
{'templates': '/dev/null',
|
||||
'environments': ['/tmp/foo.yaml']
|
||||
},
|
||||
answerfile
|
||||
)
|
||||
answerfile.flush()
|
||||
|
||||
arglist = ['--answers-file', answerfile.name,
|
||||
'--environment-file', '/tmp/environment.yaml',
|
||||
'--block-storage-scale', '3']
|
||||
verifylist = [
|
||||
('answers_file', answerfile.name),
|
||||
('environment_files', ['/tmp/environment.yaml']),
|
||||
('block_storage_scale', 3)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
arglist = ['--answers-file', answerfile.name,
|
||||
'--environment-file', environmentfile.name,
|
||||
'--block-storage-scale', '3']
|
||||
verifylist = [
|
||||
('answers_file', answerfile.name),
|
||||
('environment_files', [environmentfile.name]),
|
||||
('block_storage_scale', 3)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.assertTrue(result)
|
||||
self.assertTrue(mock_heat_deploy.called)
|
||||
self.assertTrue(mock_oc_endpoint.called)
|
||||
|
||||
@@ -510,6 +510,16 @@ class DeployOvercloud(command.Command):
|
||||
raise oscexc.CommandError(
|
||||
"You must specify either --templates or --answers-file")
|
||||
|
||||
if parsed_args.environment_files:
|
||||
nonexisting_envs = []
|
||||
for env_file in parsed_args.environment_files:
|
||||
if not os.path.isfile(env_file):
|
||||
nonexisting_envs.append(env_file)
|
||||
if nonexisting_envs:
|
||||
raise oscexc.CommandError(
|
||||
"Error: The following files were not found: {0}".format(
|
||||
", ".join(nonexisting_envs)))
|
||||
|
||||
network_type = parsed_args.neutron_network_type
|
||||
tunnel_types = parsed_args.neutron_tunnel_types
|
||||
tunnel_disabled = parsed_args.neutron_disable_tunneling
|
||||
|
||||
Reference in New Issue
Block a user