Skip to content

Commit

Permalink
Refactor: get rid of keystone/config.py
Browse files Browse the repository at this point in the history
- The file was unnecessary and the name was confusing.
- Replaced all uses of config.SERVICE with direct references to the
  IdentityService class (which will probably need to be refactored
  away as well).

Change-Id: Id65c2f231376ed76a631e51d91f17023b98636e9
  • Loading branch information
ziadsawalha authored and dolph committed Dec 6, 2011
1 parent a7a9d32 commit 11605fe
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 65 deletions.
8 changes: 0 additions & 8 deletions keystone/config.py

This file was deleted.

12 changes: 6 additions & 6 deletions keystone/controllers/credentials.py
@@ -1,6 +1,6 @@
from keystone import utils
from keystone.common import wsgi
import keystone.config as config
from keystone.logic.service import IdentityService
from keystone.logic.types.credential import PasswordCredentials
from . import get_marker_limit_and_url

Expand All @@ -13,34 +13,34 @@ def __init__(self, options):
@utils.wrap_error
def get_credentials(self, req, user_id):
marker, limit, url = get_marker_limit_and_url(req)
credentials = config.SERVICE.get_credentials(
credentials = IdentityService.get_credentials(
utils.get_auth_token(req), user_id, marker, limit, url)
return utils.send_result(200, req, credentials)

@utils.wrap_error
def get_password_credential(self, req, user_id):
credentials = config.SERVICE.get_password_credentials(
credentials = IdentityService.get_password_credentials(
utils.get_auth_token(req), user_id)
return utils.send_result(200, req, credentials)

@utils.wrap_error
def delete_password_credential(self, req, user_id):
config.SERVICE.delete_password_credentials(utils.get_auth_token(req),
IdentityService.delete_password_credentials(utils.get_auth_token(req),
user_id)
return utils.send_result(204, None)

@utils.wrap_error
def add_credential(self, req, user_id):
credential = utils.get_normalized_request_content(
PasswordCredentials, req)
credential = config.SERVICE.create_password_credentials(
credential = IdentityService.create_password_credentials(
utils.get_auth_token(req), user_id, credential)
return utils.send_result(201, req, credential)

@utils.wrap_error
def update_password_credential(self, req, user_id):
credential = utils.get_normalized_request_content(
PasswordCredentials, req)
credential = config.SERVICE.update_password_credentials(
credential = IdentityService.update_password_credentials(
utils.get_auth_token(req), user_id, credential)
return utils.send_result(200, req, credential)
20 changes: 10 additions & 10 deletions keystone/controllers/endpointtemplates.py
@@ -1,6 +1,6 @@
from keystone import utils
from keystone.common import wsgi
import keystone.config as config
from keystone.logic.service import IdentityService
from keystone.logic.types.endpoint import EndpointTemplate
from . import get_marker_limit_and_url

Expand All @@ -16,11 +16,11 @@ def get_endpoint_templates(self, req):
marker, limit, url = get_marker_limit_and_url(req)
service_id = req.GET["serviceId"] if "serviceId" in req.GET else None
if service_id:
endpoint_templates = config.SERVICE.\
endpoint_templates = IdentityService.\
get_endpoint_templates_by_service(
utils.get_auth_token(req), service_id, marker, limit, url)
else:
endpoint_templates = config.SERVICE.get_endpoint_templates(
endpoint_templates = IdentityService.get_endpoint_templates(
utils.get_auth_token(req), marker, limit, url)
return utils.send_result(200, req, endpoint_templates)

Expand All @@ -29,46 +29,46 @@ def add_endpoint_template(self, req):
endpoint_template = utils.get_normalized_request_content(
EndpointTemplate, req)
return utils.send_result(201, req,
config.SERVICE.add_endpoint_template(utils.get_auth_token(req),
IdentityService.add_endpoint_template(utils.get_auth_token(req),
endpoint_template))

@utils.wrap_error
def modify_endpoint_template(self, req, endpoint_template_id):
endpoint_template = utils.\
get_normalized_request_content(EndpointTemplate, req)
return utils.send_result(201, req,
config.SERVICE.modify_endpoint_template(\
IdentityService.modify_endpoint_template(\
utils.get_auth_token(req),
endpoint_template_id, endpoint_template))

@utils.wrap_error
def delete_endpoint_template(self, req, endpoint_template_id):
rval = config.SERVICE.delete_endpoint_template(
rval = IdentityService.delete_endpoint_template(
utils.get_auth_token(req), endpoint_template_id)
return utils.send_result(204, req, rval)

@utils.wrap_error
def get_endpoint_template(self, req, endpoint_template_id):
endpoint_template = config.SERVICE.get_endpoint_template(
endpoint_template = IdentityService.get_endpoint_template(
utils.get_auth_token(req), endpoint_template_id)
return utils.send_result(200, req, endpoint_template)

@utils.wrap_error
def get_endpoints_for_tenant(self, req, tenant_id):
marker, limit, url = get_marker_limit_and_url(req)
endpoints = config.SERVICE.get_tenant_endpoints(
endpoints = IdentityService.get_tenant_endpoints(
utils.get_auth_token(req), marker, limit, url, tenant_id)
return utils.send_result(200, req, endpoints)

@utils.wrap_error
def add_endpoint_to_tenant(self, req, tenant_id):
endpoint = utils.get_normalized_request_content(EndpointTemplate, req)
return utils.send_result(201, req,
config.SERVICE.create_endpoint_for_tenant(
IdentityService.create_endpoint_for_tenant(
utils.get_auth_token(req), tenant_id, endpoint))

@utils.wrap_error
def remove_endpoint_from_tenant(self, req, tenant_id, endpoint_id):
rval = config.SERVICE.delete_endpoint(utils.get_auth_token(req),
rval = IdentityService.delete_endpoint(utils.get_auth_token(req),
endpoint_id)
return utils.send_result(204, req, rval)
18 changes: 9 additions & 9 deletions keystone/controllers/roles.py
@@ -1,7 +1,7 @@
from keystone import utils
from keystone.common import wsgi
from keystone.logic.types.role import Role
import keystone.config as config
from keystone.logic.service import IdentityService
from . import get_marker_limit_and_url


Expand All @@ -16,46 +16,46 @@ def __init__(self, options):
def create_role(self, req):
role = utils.get_normalized_request_content(Role, req)
return utils.send_result(201, req,
config.SERVICE.create_role(utils.get_auth_token(req), role))
IdentityService.create_role(utils.get_auth_token(req), role))

@utils.wrap_error
def delete_role(self, req, role_id):
rval = config.SERVICE.delete_role(utils.get_auth_token(req), role_id)
rval = IdentityService.delete_role(utils.get_auth_token(req), role_id)
return utils.send_result(204, req, rval)

@utils.wrap_error
def get_roles(self, req):
role_name = req.GET["name"] if "name" in req.GET else None
if role_name:
tenant = config.SERVICE.get_role_by_name(
tenant = IdentityService.get_role_by_name(
utils.get_auth_token(req), role_name)
return utils.send_result(200, req, tenant)
else:
marker, limit, url = get_marker_limit_and_url(req)
roles = config.SERVICE.get_roles(
roles = IdentityService.get_roles(
utils.get_auth_token(req), marker, limit, url)
return utils.send_result(200, req, roles)

@utils.wrap_error
def get_role(self, req, role_id):
role = config.SERVICE.get_role(utils.get_auth_token(req), role_id)
role = IdentityService.get_role(utils.get_auth_token(req), role_id)
return utils.send_result(200, req, role)

@utils.wrap_error
def add_role_to_user(self, req, user_id, role_id, tenant_id=None):
config.SERVICE.add_role_to_user(utils.get_auth_token(req),
IdentityService.add_role_to_user(utils.get_auth_token(req),
user_id, role_id, tenant_id)
return utils.send_result(201, None)

@utils.wrap_error
def delete_role_from_user(self, req, user_id, role_id, tenant_id=None):
config.SERVICE.remove_role_from_user(utils.get_auth_token(req),
IdentityService.remove_role_from_user(utils.get_auth_token(req),
user_id, role_id, tenant_id)
return utils.send_result(204, req, None)

@utils.wrap_error
def get_user_roles(self, req, user_id, tenant_id=None):
marker, limit, url = get_marker_limit_and_url(req)
roles = config.SERVICE.get_user_roles(
roles = IdentityService.get_user_roles(
utils.get_auth_token(req), marker, limit, url, user_id, tenant_id)
return utils.send_result(200, req, roles)
12 changes: 6 additions & 6 deletions keystone/controllers/services.py
@@ -1,7 +1,7 @@
from keystone import utils
from keystone.common import wsgi
from keystone.logic.types.service import Service
import keystone.config as config
from keystone.logic.service import IdentityService
from . import get_marker_limit_and_url


Expand All @@ -15,29 +15,29 @@ def __init__(self, options):
def create_service(self, req):
service = utils.get_normalized_request_content(Service, req)
return utils.send_result(201, req,
config.SERVICE.create_service(utils.get_auth_token(req), service))
IdentityService.create_service(utils.get_auth_token(req), service))

@utils.wrap_error
def get_services(self, req):
service_name = req.GET["name"] if "name" in req.GET else None
if service_name:
tenant = config.SERVICE.get_service_by_name(
tenant = IdentityService.get_service_by_name(
utils.get_auth_token(req), service_name)
return utils.send_result(200, req, tenant)
else:
marker, limit, url = get_marker_limit_and_url(req)
services = config.SERVICE.get_services(
services = IdentityService.get_services(
utils.get_auth_token(req), marker, limit, url)
return utils.send_result(200, req, services)

@utils.wrap_error
def get_service(self, req, service_id):
service = config.SERVICE.get_service(
service = IdentityService.get_service(
utils.get_auth_token(req), service_id)
return utils.send_result(200, req, service)

@utils.wrap_error
def delete_service(self, req, service_id):
rval = config.SERVICE.delete_service(utils.get_auth_token(req),
rval = IdentityService.delete_service(utils.get_auth_token(req),
service_id)
return utils.send_result(204, req, rval)
14 changes: 7 additions & 7 deletions keystone/controllers/tenant.py
@@ -1,6 +1,6 @@
from keystone import utils
from keystone.common import wsgi
import keystone.config as config
from keystone.logic.service import IdentityService
from keystone.logic.types.tenant import Tenant
from . import get_marker_limit_and_url

Expand All @@ -16,37 +16,37 @@ def __init__(self, options, is_service_operation=None):
def create_tenant(self, req):
tenant = utils.get_normalized_request_content(Tenant, req)
return utils.send_result(201, req,
config.SERVICE.create_tenant(utils.get_auth_token(req), tenant))
IdentityService.create_tenant(utils.get_auth_token(req), tenant))

@utils.wrap_error
def get_tenants(self, req):
tenant_name = req.GET["name"] if "name" in req.GET else None
if tenant_name:
tenant = config.SERVICE.get_tenant_by_name(
tenant = IdentityService.get_tenant_by_name(
utils.get_auth_token(req),
tenant_name)
return utils.send_result(200, req, tenant)
else:
marker, limit, url = get_marker_limit_and_url(req)
tenants = config.SERVICE.get_tenants(utils.get_auth_token(req),
tenants = IdentityService.get_tenants(utils.get_auth_token(req),
marker, limit, url, self.is_service_operation)
return utils.send_result(200, req, tenants)

@utils.wrap_error
def get_tenant(self, req, tenant_id):
tenant = config.SERVICE.get_tenant(utils.get_auth_token(req),
tenant = IdentityService.get_tenant(utils.get_auth_token(req),
tenant_id)
return utils.send_result(200, req, tenant)

@utils.wrap_error
def update_tenant(self, req, tenant_id):
tenant = utils.get_normalized_request_content(Tenant, req)
rval = config.SERVICE.update_tenant(utils.get_auth_token(req),
rval = IdentityService.update_tenant(utils.get_auth_token(req),
tenant_id, tenant)
return utils.send_result(200, req, rval)

@utils.wrap_error
def delete_tenant(self, req, tenant_id):
rval = config.SERVICE.delete_tenant(utils.get_auth_token(req),
rval = IdentityService.delete_tenant(utils.get_auth_token(req),
tenant_id)
return utils.send_result(204, req, rval)
14 changes: 7 additions & 7 deletions keystone/controllers/token.py
Expand Up @@ -28,7 +28,7 @@
from keystone.common import wsgi
from keystone.logic.types import auth
from keystone.logic.types import fault
import keystone.config as config
from keystone.logic.service import IdentityService
from . import get_marker_limit_and_url


Expand All @@ -43,12 +43,12 @@ def authenticate(self, req):
try:
auth_with_credentials = utils.get_normalized_request_content(
auth.AuthWithPasswordCredentials, req)
result = config.SERVICE.authenticate(auth_with_credentials)
result = IdentityService.authenticate(auth_with_credentials)
except fault.BadRequestFault as e1:
try:
unscoped = utils.get_normalized_request_content(
auth.AuthWithUnscopedToken, req)
result = config.SERVICE.authenticate_with_unscoped_token(
result = IdentityService.authenticate_with_unscoped_token(
unscoped)
except fault.BadRequestFault as e2:
if e1.msg == e2.msg:
Expand All @@ -62,12 +62,12 @@ def authenticate(self, req):
def authenticate_ec2(self, req):
creds = utils.get_normalized_request_content(auth.Ec2Credentials, req)
return utils.send_result(200, req,
config.SERVICE.authenticate_ec2(creds))
IdentityService.authenticate_ec2(creds))

def _validate_token(self, req, token_id):
"""Validates the token, and that it belongs to the specified tenant"""
belongs_to = req.GET.get('belongsTo')
return config.SERVICE.validate_token(
return IdentityService.validate_token(
utils.get_auth_token(req), token_id, belongs_to)

@utils.wrap_error
Expand All @@ -84,12 +84,12 @@ def check_token(self, req, token_id):
@utils.wrap_error
def delete_token(self, req, token_id):
return utils.send_result(204, req,
config.SERVICE.revoke_token(utils.get_auth_token(req), token_id))
IdentityService.revoke_token(utils.get_auth_token(req), token_id))

@utils.wrap_error
def endpoints(self, req, token_id):
marker, limit, url = get_marker_limit_and_url(req)
return utils.send_result(200, req,
config.SERVICE.get_endpoints_for_token(
IdentityService.get_endpoints_for_token(
utils.get_auth_token(req),
token_id, marker, limit, url))

0 comments on commit 11605fe

Please sign in to comment.