Fix environment files parsing bug for stack-adopt
Should use process_multiple_environments_and_files to parse the environment file arguments instead. Change-Id: I2f00df78462f1468ff12f7f9f8ca8a5d4c2d181b Closes-Bug: #1510818
This commit is contained in:
		@@ -1834,6 +1834,37 @@ class ShellTestUserPass(ShellBase):
 | 
			
		||||
        for r in required:
 | 
			
		||||
            self.assertRegexpMatches(adopt_text, r)
 | 
			
		||||
 | 
			
		||||
    def test_stack_adopt_with_environment(self):
 | 
			
		||||
        self.register_keystone_auth_fixture()
 | 
			
		||||
        resp = fakes.FakeHTTPResponse(
 | 
			
		||||
            201,
 | 
			
		||||
            'Created',
 | 
			
		||||
            {'location': 'http://no.where/v1/tenant_id/stacks/teststack/1'},
 | 
			
		||||
            None)
 | 
			
		||||
        if self.client is http.HTTPClient:
 | 
			
		||||
            headers = {'X-Auth-Key': 'password', 'X-Auth-User': 'username'}
 | 
			
		||||
        else:
 | 
			
		||||
            headers = {}
 | 
			
		||||
        if self.client == http.SessionClient:
 | 
			
		||||
            self.client.request(
 | 
			
		||||
                '/stacks', 'POST', data=mox.IgnoreArg(),
 | 
			
		||||
                headers=headers).AndReturn(resp)
 | 
			
		||||
        else:
 | 
			
		||||
            self.client.json_request(
 | 
			
		||||
                'POST', '/stacks', data=mox.IgnoreArg(),
 | 
			
		||||
                headers=headers
 | 
			
		||||
            ).AndReturn((resp, None))
 | 
			
		||||
 | 
			
		||||
        fakes.script_heat_list(client=self.client)
 | 
			
		||||
        self.m.ReplayAll()
 | 
			
		||||
 | 
			
		||||
        adopt_data_file = os.path.join(TEST_VAR_DIR, 'adopt_stack_data.json')
 | 
			
		||||
        environment_file = os.path.join(TEST_VAR_DIR, 'environment.json')
 | 
			
		||||
        self.shell(
 | 
			
		||||
            'stack-adopt teststack '
 | 
			
		||||
            '--adopt-file=%s '
 | 
			
		||||
            '--environment-file=%s' % (adopt_data_file, environment_file))
 | 
			
		||||
 | 
			
		||||
    def test_stack_adopt_without_data(self):
 | 
			
		||||
        self.register_keystone_auth_fixture()
 | 
			
		||||
        failed_msg = 'Need to specify --adopt-file'
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								heatclient/tests/unit/var/environment.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								heatclient/tests/unit/var/environment.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
{
 | 
			
		||||
    "parameters": {}
 | 
			
		||||
}
 | 
			
		||||
@@ -193,8 +193,8 @@ def hooks_to_env(env, arg_hooks, hook):
 | 
			
		||||
           help=_('Name of the stack to adopt.'))
 | 
			
		||||
def do_stack_adopt(hc, args):
 | 
			
		||||
    '''Adopt a stack.'''
 | 
			
		||||
    env_files, env = template_utils.process_environment_and_files(
 | 
			
		||||
        env_path=args.environment_file)
 | 
			
		||||
    env_files, env = template_utils.process_multiple_environments_and_files(
 | 
			
		||||
        env_paths=args.environment_file)
 | 
			
		||||
 | 
			
		||||
    if not args.adopt_file:
 | 
			
		||||
        raise exc.CommandError(_('Need to specify %(arg)s') %
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user