Merge "Client V3 shouldn't inherit V2"

This commit is contained in:
Jenkins
2013-07-28 05:40:26 +00:00
committed by Gerrit Code Review
3 changed files with 27 additions and 30 deletions

View File

@@ -428,8 +428,29 @@ class HTTPClient(object):
def process_token(self): def process_token(self):
"""Extract and process information from the new auth_ref. """Extract and process information from the new auth_ref.
And set the relevant authentication information.
""" """
raise NotImplementedError # if we got a response without a service catalog, set the local
# list of tenants for introspection, and leave to client user
# to determine what to do. Otherwise, load up the service catalog
if self.auth_ref.project_scoped:
if not self.auth_ref.tenant_id:
raise exceptions.AuthorizationFailure(
"Token didn't provide tenant_id")
if self.management_url is None and self.auth_ref.management_url:
self.management_url = self.auth_ref.management_url[0]
self.project_name = self.auth_ref.tenant_name
self.project_id = self.auth_ref.tenant_id
if not self.auth_ref.user_id:
raise exceptions.AuthorizationFailure(
"Token didn't provide user_id")
self.user_id = self.auth_ref.user_id
self.auth_domain_id = self.auth_ref.domain_id
self.auth_tenant_id = self.auth_ref.tenant_id
self.auth_user_id = self.auth_ref.user_id
def get_raw_token_from_identity_service(self, auth_url, username=None, def get_raw_token_from_identity_service(self, auth_url, username=None,
password=None, tenant_name=None, password=None, tenant_name=None,

View File

@@ -138,33 +138,6 @@ class Client(client.HTTPClient):
if self.management_url is None: if self.management_url is None:
self.authenticate() self.authenticate()
def process_token(self):
"""Extract and process information from the new auth_ref.
And set the relevant authentication information.
"""
# if we got a response without a service catalog, set the local
# list of tenants for introspection, and leave to client user
# to determine what to do. Otherwise, load up the service catalog
if self.auth_ref.project_scoped:
if not self.auth_ref.tenant_id:
raise exceptions.AuthorizationFailure(
"Token didn't provide tenant_id")
if self.management_url is None and self.auth_ref.management_url:
self.management_url = self.auth_ref.management_url[0]
self.project_name = self.auth_ref.tenant_name
self.project_id = self.auth_ref.tenant_id
if not self.auth_ref.user_id:
raise exceptions.AuthorizationFailure(
"Token didn't provide user_id")
self.user_id = self.auth_ref.user_id
self.auth_domain_id = self.auth_ref.domain_id
self.auth_tenant_id = self.auth_ref.tenant_id
self.auth_user_id = self.auth_ref.user_id
def get_raw_token_from_identity_service(self, auth_url, username=None, def get_raw_token_from_identity_service(self, auth_url, username=None,
password=None, tenant_name=None, password=None, tenant_name=None,
tenant_id=None, token=None, tenant_id=None, token=None,

View File

@@ -16,7 +16,7 @@ import json
import logging import logging
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.v2_0 import client from keystoneclient import client
from keystoneclient.v3 import credentials from keystoneclient.v3 import credentials
from keystoneclient.v3 import domains from keystoneclient.v3 import domains
from keystoneclient.v3 import endpoints from keystoneclient.v3 import endpoints
@@ -31,7 +31,7 @@ from keystoneclient.v3 import users
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class Client(client.Client): class Client(client.HTTPClient):
"""Client for the OpenStack Identity API v3. """Client for the OpenStack Identity API v3.
:param string user_id: User ID for authentication. (optional) :param string user_id: User ID for authentication. (optional)
@@ -98,6 +98,9 @@ class Client(client.Client):
self.services = services.ServiceManager(self) self.services = services.ServiceManager(self)
self.users = users.UserManager(self) self.users = users.UserManager(self)
if self.management_url is None:
self.authenticate()
def serialize(self, entity): def serialize(self, entity):
return json.dumps(entity, sort_keys=True) return json.dumps(entity, sort_keys=True)