Add missing domain name to novaclient

Domain name is needed when using keystone v3 to create keystoneauth
session[1], otherwise the following error will be raised:

InvalidInput: Invalid input received: Expecting to find domain in
project - the server could not comply with the request since it is
either malformed or otherwise incorrect

[1]: https://docs.openstack.org/keystoneauth/latest/authentication-plugins.html#v3-identity-plugins

Change-Id: I557a7107b51ae4ffab15d045a4be6e3ed1940bd8
Closes-bug: #1710570
This commit is contained in:
liyingjun 2017-08-15 08:47:32 +08:00
parent 237bee37f8
commit 6139da28da
4 changed files with 29 additions and 8 deletions

View File

@ -107,10 +107,13 @@ def novaclient(context, timeout=None):
# project_name, let's build a Keystone session.
loader = keystoneauth1.loading.get_plugin_loader(
CONF.keystone_authtoken.auth_type)
auth = loader.load_from_options(auth_url=url,
username=context.user_id,
password=context.auth_token,
project_name=context.project_name)
auth = loader.load_from_options(
auth_url=url,
username=context.user_id,
password=context.auth_token,
project_name=context.project_name,
user_domain_name=CONF.os_user_domain_name,
project_domain_name=CONF.os_project_domain_name)
keystone_session = keystoneauth1.session.Session(auth=auth)
client_obj = nova_client.Client(

View File

@ -45,6 +45,14 @@ nova_opts = [
cfg.URIOpt('os_privileged_user_auth_url',
help='Auth URL associated with the OpenStack privileged '
'account.'),
cfg.StrOpt('os_user_domain_name',
default="default",
help='User domain name associated with the OpenStack '
'privileged account.'),
cfg.StrOpt('os_project_domain_name',
default="default",
help='Project domain name associated with the OpenStack '
'privileged account.'),
]

View File

@ -51,7 +51,8 @@ class NovaClientTestCase(test.TestCase):
nova.novaclient(self.ctx)
p_plugin_loader.return_value.load_from_options.assert_called_once_with(
auth_url='http://keystonehost/identity',
password='strongpassword', project_name=None, username='adminuser'
password='strongpassword', project_domain_name='default',
project_name=None, user_domain_name='default', username='adminuser'
)
p_client.assert_called_once_with(
p_api_version(nova.NOVA_API_VERSION),
@ -69,7 +70,8 @@ class NovaClientTestCase(test.TestCase):
nova.novaclient(self.ctx)
p_plugin_loader.return_value.load_from_options.assert_called_once_with(
auth_url='http://keystonehost/identity',
password='strongpassword', project_name=None, username='adminuser'
password='strongpassword', project_domain_name='default',
project_name=None, user_domain_name='default', username='adminuser'
)
p_client.assert_called_once_with(
p_api_version(nova.NOVA_API_VERSION),
@ -89,7 +91,8 @@ class NovaClientTestCase(test.TestCase):
nova.novaclient(self.ctx)
p_plugin_loader.return_value.load_from_options.assert_called_once_with(
auth_url='http://keystonehost/identity',
password='strongpassword', project_name=None, username='adminuser'
password='strongpassword', project_domain_name='default',
project_name=None, user_domain_name='default', username='adminuser'
)
p_client.assert_called_once_with(
p_api_version(nova.NOVA_API_VERSION),
@ -108,7 +111,8 @@ class NovaClientTestCase(test.TestCase):
nova.novaclient(self.ctx)
p_plugin_loader.return_value.load_from_options.assert_called_once_with(
auth_url='http://keystonehost/identity',
password='strongpassword', project_name=None, username='adminuser'
password='strongpassword', project_domain_name='default',
project_name=None, user_domain_name='default', username='adminuser'
)
p_client.assert_called_once_with(
p_api_version(nova.NOVA_API_VERSION),

View File

@ -0,0 +1,6 @@
---
prelude: >
Domain name is needed when using keystone v3 to create keystone session,
if not provided, InvalidInput exception will be raised. Two new options
"os_user_domain_name" and "os_project_domain_name" with default value
"default" are added to fix the issue.