summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRohit Jaiswal <rohit.jaiswal@hp.com>2015-07-31 05:24:39 +0000
committerRohit Jaiswal <rohit.jaiswal@hp.com>2015-07-31 20:35:20 +0000
commit803c59fbc7682dbfbd8f32c191c3e5e45d9fb8ca (patch)
tree75147d12b4afa45f22169de7910268489682aa29
parent09bfc70de417595e3026b0a0e5258de4f7df56fe (diff)
downloadpython-ceilometerclient-803c59fbc7682dbfbd8f32c191c3e5e45d9fb8ca.tar.gz
tenant_id not required with keystone v3
Ceilometer-client requires tenant_id when authenticating with keystone v3. This fix removes this requirement. Change-Id: I36bf3f7a75713976c56dd95b4fd22da4e64d01df Closes-Bug: 1440463
-rw-r--r--ceilometerclient/client.py10
-rw-r--r--ceilometerclient/shell.py6
-rw-r--r--ceilometerclient/tests/unit/test_shell.py3
3 files changed, 10 insertions, 9 deletions
diff --git a/ceilometerclient/client.py b/ceilometerclient/client.py
index 4f9f3da..02194be 100644
--- a/ceilometerclient/client.py
+++ b/ceilometerclient/client.py
@@ -283,8 +283,14 @@ class AuthPlugin(auth.BaseAuthPlugin):
"""
has_token = self.opts.get('token') or self.opts.get('auth_token')
no_auth = has_token and self.opts.get('endpoint')
- has_tenant = self.opts.get('tenant_id') or self.opts.get('tenant_name')
- has_credential = (self.opts.get('username') and has_tenant
+ has_project_domain_or_tenant = (self.opts.get('project_id') or
+ (self.opts.get('project_name') and
+ (self.opts.get('user_domain_name') or
+ self.opts.get('user_domain_id'))) or
+ (self.opts.get('tenant_id') or
+ self.opts.get('tenant_name')))
+ has_credential = (self.opts.get('username')
+ and has_project_domain_or_tenant
and self.opts.get('password')
and self.opts.get('auth_url'))
missing = not (no_auth or has_credential)
diff --git a/ceilometerclient/shell.py b/ceilometerclient/shell.py
index 23a9dc1..565bd45 100644
--- a/ceilometerclient/shell.py
+++ b/ceilometerclient/shell.py
@@ -228,12 +228,6 @@ class CeilometerShell(object):
"--os-user-domain-id or via "
"env[OS_USER_DOMAIN_ID]")
- if not (self.auth_plugin.opts['tenant_id']
- or self.auth_plugin.opts['tenant_name']):
- raise exc.CommandError("You must provide a tenant_id via "
- "either --os-tenant-id or via "
- "env[OS_TENANT_ID]")
-
if not self.auth_plugin.opts['auth_url']:
raise exc.CommandError("You must provide an auth url via "
"either --os-auth-url or via "
diff --git a/ceilometerclient/tests/unit/test_shell.py b/ceilometerclient/tests/unit/test_shell.py
index 129df2f..d9bbcff 100644
--- a/ceilometerclient/tests/unit/test_shell.py
+++ b/ceilometerclient/tests/unit/test_shell.py
@@ -140,7 +140,8 @@ class ShellKeystoneV2Test(ShellTestBase):
class ShellKeystoneV3Test(ShellTestBase):
@mock.patch.object(ks_session, 'Session')
- def test_debug_switch_raises_error(self, mock_ksclient):
+ @mock.patch('ceilometerclient.client.AuthPlugin.redirect_to_aodh_endpoint')
+ def test_debug_switch_raises_error(self, aodh_redirect, mock_ksclient):
mock_ksclient.side_effect = exc.HTTPUnauthorized
self.make_env(FAKE_V3_ENV)
args = ['--debug', 'event-list']