~ubuntu-branches/ubuntu/quantal/keystone/quantal-security

« back to all changes in this revision

Viewing changes to keystone/catalog/core.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-06-22 12:27:50 UTC
  • mto: (35.1.1 quantal-proposed)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: package-import@ubuntu.com-20120622122750-4urdq17en1990apn
Tags: upstream-2012.2~f2~20120622.2353
ImportĀ upstreamĀ versionĀ 2012.2~f2~20120622.2353

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import uuid
21
21
 
 
22
from keystone.common import manager
 
23
from keystone.common import wsgi
22
24
from keystone import config
23
25
from keystone import exception
24
26
from keystone import identity
25
27
from keystone import policy
26
28
from keystone import token
27
 
from keystone.common import manager
28
 
from keystone.common import wsgi
29
29
 
30
30
 
31
31
CONF = config.CONF
116
116
class ServiceController(wsgi.Application):
117
117
    def __init__(self):
118
118
        self.catalog_api = Manager()
 
119
        self.identity_api = identity.Manager()
 
120
        self.policy_api = policy.Manager()
 
121
        self.token_api = token.Manager()
119
122
        super(ServiceController, self).__init__()
120
123
 
121
124
    # CRUD extensions
122
125
    # NOTE(termie): this OS-KSADM stuff is not very consistent
123
126
    def get_services(self, context):
 
127
        self.assert_admin(context)
124
128
        service_list = self.catalog_api.list_services(context)
125
129
        service_refs = [self.catalog_api.get_service(context, x)
126
130
                        for x in service_list]
127
131
        return {'OS-KSADM:services': service_refs}
128
132
 
129
133
    def get_service(self, context, service_id):
 
134
        self.assert_admin(context)
130
135
        service_ref = self.catalog_api.get_service(context, service_id)
131
136
        if not service_ref:
132
137
            raise exception.ServiceNotFound(service_id=service_id)
133
138
        return {'OS-KSADM:service': service_ref}
134
139
 
135
140
    def delete_service(self, context, service_id):
 
141
        self.assert_admin(context)
136
142
        service_ref = self.catalog_api.get_service(context, service_id)
137
143
        if not service_ref:
138
144
            raise exception.ServiceNotFound(service_id=service_id)
139
145
        self.catalog_api.delete_service(context, service_id)
140
146
 
141
147
    def create_service(self, context, OS_KSADM_service):
 
148
        self.assert_admin(context)
142
149
        service_id = uuid.uuid4().hex
143
150
        service_ref = OS_KSADM_service.copy()
144
151
        service_ref['id'] = service_id
145
152
        new_service_ref = self.catalog_api.create_service(
146
 
                context, service_id, service_ref)
 
153
            context, service_id, service_ref)
147
154
        return {'OS-KSADM:service': new_service_ref}
148
155
 
149
156
 
173
180
            raise exception.ServiceNotFound(service_id=service_id)
174
181
 
175
182
        new_endpoint_ref = self.catalog_api.create_endpoint(
176
 
                                context, endpoint_id, endpoint_ref)
 
183
            context, endpoint_id, endpoint_ref)
177
184
        return {'endpoint': new_endpoint_ref}
178
185
 
179
186
    def delete_endpoint(self, context, endpoint_id):