diff --git a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py index 5014777f9..b85e8735d 100644 --- a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py +++ b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py @@ -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) diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index 593817b4c..83c7ca754 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -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