Merge "User server side env merging with osc plugin"

This commit is contained in:
Jenkins 2016-12-14 08:34:15 +00:00 committed by Gerrit Code Review
commit 0c246f3259
2 changed files with 36 additions and 2 deletions

View File

@ -124,9 +124,11 @@ class CreateStack(command.ShowOne):
parsed_args.template,
object_request=http.authenticated_fetcher(client))
env_files_list = []
env_files, env = (
template_utils.process_multiple_environments_and_files(
env_paths=parsed_args.environment))
env_paths=parsed_args.environment,
env_list_tracker=env_files_list))
parameters = heat_utils.format_all_parameters(
parsed_args.parameter,
@ -146,6 +148,10 @@ class CreateStack(command.ShowOne):
'environment': env
}
# If one or more environments is found, pass the listing to the server
if env_files_list:
fields['environment_files'] = env_files_list
if parsed_args.tags:
fields['tags'] = parsed_args.tags
if parsed_args.timeout:
@ -286,9 +292,11 @@ class UpdateStack(command.ShowOne):
object_request=http.authenticated_fetcher(client),
existing=parsed_args.existing)
env_files_list = []
env_files, env = (
template_utils.process_multiple_environments_and_files(
env_paths=parsed_args.environment))
env_paths=parsed_args.environment,
env_list_tracker=env_files_list))
parameters = heat_utils.format_all_parameters(
parsed_args.parameter,
@ -308,6 +316,10 @@ class UpdateStack(command.ShowOne):
'environment': env
}
# If one or more environments is found, pass the listing to the server
if env_files_list:
fields['environment_files'] = env_files_list
if parsed_args.tags:
fields['tags'] = parsed_args.tags
if parsed_args.timeout:

View File

@ -43,6 +43,7 @@ class TestStack(orchestration_fakes.TestOrchestrationv1):
class TestStackCreate(TestStack):
template_path = 'heatclient/tests/test_templates/empty.yaml'
env_path = 'heatclient/tests/unit/var/environment.json'
defaults = {
'stack_name': 'my_stack',
@ -71,6 +72,16 @@ class TestStackCreate(TestStack):
self.stack_client.create.assert_called_with(**self.defaults)
def test_stack_create_with_env(self):
arglist = ['my_stack', '-t', self.template_path, '-e', self.env_path]
parsed_args = self.check_parser(self.cmd, arglist, [])
self.cmd.take_action(parsed_args)
self.assertEqual(1, self.stack_client.create.call_count)
args = self.stack_client.create.call_args[1]
self.assertEqual({'parameters': {}}, args.get('environment'))
self.assertIn(self.env_path, args.get('environment_files')[0])
def test_stack_create_rollback(self):
arglist = ['my_stack', '-t', self.template_path, '--enable-rollback']
kwargs = copy.deepcopy(self.defaults)
@ -162,6 +173,7 @@ class TestStackCreate(TestStack):
class TestStackUpdate(TestStack):
template_path = 'heatclient/tests/test_templates/empty.yaml'
env_path = 'heatclient/tests/unit/var/environment.json'
defaults = {
'stack_id': 'my_stack',
@ -193,6 +205,16 @@ class TestStackUpdate(TestStack):
self.stack_client.update.assert_called_with(**self.defaults)
def test_stack_update_with_env(self):
arglist = ['my_stack', '-t', self.template_path, '-e', self.env_path]
parsed_args = self.check_parser(self.cmd, arglist, [])
self.cmd.take_action(parsed_args)
self.assertEqual(1, self.stack_client.update.call_count)
args = self.stack_client.update.call_args[1]
self.assertEqual({'parameters': {}}, args.get('environment'))
self.assertIn(self.env_path, args.get('environment_files')[0])
def test_stack_update_rollback_enabled(self):
arglist = ['my_stack', '-t', self.template_path, '--rollback',
'enabled']