Add domain information into auth cred.

If we use v3 keystone, these information should be passed
into tacker server.

Change-Id: Ieb5612c966b2110930faac0401f5dabde064ffc1
Partial-Bug: #1603851
(cherry picked from commit 0aa7efd292)
This commit is contained in:
gong yong sheng 2016-07-18 12:50:30 +08:00 committed by Sripriya Seetharam
parent 56e3f5f5bb
commit f8bb518893
4 changed files with 71 additions and 7 deletions

View File

@ -25,11 +25,15 @@ def args2body_vim(config_param, vim):
:return: vim body with args populated
"""
vim['vim_project'] = {'id': config_param.pop('project_id', ''),
'name': config_param.pop('project_name', '')}
'name': config_param.pop('project_name', ''),
'project_domain_name':
config_param.pop('project_domain_name', '')}
if not vim['vim_project']['id'] and not vim['vim_project']['name']:
raise exceptions.TackerClientException(message='Project Id or name '
'must be specified',
status_code=404)
vim['auth_cred'] = {'username': config_param.pop('username', ''),
'password': config_param.pop('password', ''),
'user_id': config_param.pop('user_id', '')}
'user_id': config_param.pop('user_id', ''),
'user_domain_name':
config_param.pop('user_domain_name', '')}

View File

View File

@ -0,0 +1,52 @@
# Copyright 2016 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from mock import sentinel
import testtools
from tackerclient.common import exceptions
from tackerclient.tacker.v1_0.nfvo import vim_utils
class CLITestAuthNoAuth(testtools.TestCase):
def test_args2body_vim(self):
config_param = {'project_id': sentinel.prj_id1,
'username': sentinel.usrname1,
'password': sentinel.password1,
'project_domain_name': sentinel.prj_domain_name1,
'user_domain_name': sentinel.user_domain.name, }
vim = {}
auth_cred = config_param.copy()
auth_cred.pop('project_id')
auth_cred.pop('project_domain_name')
auth_cred.update({'user_id': ''})
expected_vim = {'auth_cred': auth_cred,
'vim_project':
{'id': sentinel.prj_id1,
'name': '',
'project_domain_name': sentinel.prj_domain_name1}}
vim_utils.args2body_vim(config_param.copy(), vim)
self.assertEqual(expected_vim, vim)
def test_args2body_vim_no_project(self):
config_param = {'username': sentinel.usrname1,
'password': sentinel.password1,
'user_domain_name': sentinel.user_domain.name, }
vim = {}
self.assertRaises(exceptions.TackerClientException,
vim_utils.args2body_vim,
config_param, vim)

View File

@ -34,9 +34,11 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
def setUp(self):
plurals = {'vims': 'vim'}
super(CLITestV10VIMJSON, self).setUp(plurals=plurals)
self.vim_project = {'name': 'abc', 'id': ''}
self.vim_project = {
'name': 'abc', 'id': '',
'project_domain_name': 'prj_domain_name'}
self.auth_cred = {'username': 'xyz', 'password': '12345', 'user_id':
''}
'', 'user_domain_name': 'user_domain_name'}
self.auth_url = 'http://1.2.3.4:5000'
def test_register_vim_all_params(self):
@ -45,7 +47,9 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
name = 'test_vim'
description = 'Vim Description'
vim_config = {'auth_url': 'http://1.2.3.4:5000', 'username': 'xyz',
'password': '12345', 'project_name': 'abc'}
'password': '12345', 'project_name': 'abc',
'project_domain_name': 'prj_domain_name',
'user_domain_name': 'user_domain_name'}
args = [
'--config', str(vim_config),
'--name', name,
@ -63,7 +67,9 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
my_id = 'my-id'
vim_config = {'auth_url': 'http://1.2.3.4:5000', 'username': 'xyz',
'password': '12345', 'project_name': 'abc'}
'password': '12345', 'project_name': 'abc',
'project_domain_name': 'prj_domain_name',
'user_domain_name': 'user_domain_name'}
args = [
'--config', str(vim_config),
]
@ -126,7 +132,9 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
def test_update_vim(self):
cmd = vim.UpdateVIM(test_cli10.MyApp(sys.stdout), None)
update_config = {'username': 'xyz', 'password': '12345',
'project_name': 'abc'}
'project_name': 'abc',
'project_domain_name': 'prj_domain_name',
'user_domain_name': 'user_domain_name'}
my_id = 'my-id'
key = 'config'
value = str(update_config)