~tr3buchet/nova/lock

« back to all changes in this revision

Viewing changes to nova/auth/manager.py

  • Committer: Vishvananda Ishaya
  • Date: 2010-12-22 20:59:53 UTC
  • mto: This revision was merged to the branch mainline in revision 482.
  • Revision ID: vishvananda@gmail.com-20101222205953-j2j5t0qjwlcd0t2s
merge trunk and upgrade to cheetah templating

Show diffs side-by-side

added added

removed removed

Lines of Context:
257
257
        # TODO(vish): check for valid timestamp
258
258
        (access_key, _sep, project_id) = access.partition(':')
259
259
 
260
 
        logging.info('Looking up user: %r', access_key)
 
260
        logging.info(_('Looking up user: %r'), access_key)
261
261
        user = self.get_user_from_access_key(access_key)
262
262
        logging.info('user: %r', user)
263
263
        if user == None:
264
 
            raise exception.NotFound('No user found for access key %s' %
265
 
                                     access_key)
 
264
            raise exception.NotFound(_('No user found for access key %s')
 
265
                                     % access_key)
266
266
 
267
267
        # NOTE(vish): if we stop using project name as id we need better
268
268
        #             logic to find a default project for user
271
271
 
272
272
        project = self.get_project(project_id)
273
273
        if project == None:
274
 
            raise exception.NotFound('No project called %s could be found' %
275
 
                                     project_id)
 
274
            raise exception.NotFound(_('No project called %s could be found')
 
275
                                     % project_id)
276
276
        if not self.is_admin(user) and not self.is_project_member(user,
277
277
                                                                  project):
278
 
            raise exception.NotFound('User %s is not a member of project %s' %
279
 
                                     (user.id, project.id))
 
278
            raise exception.NotFound(_('User %s is not a member of project %s')
 
279
                                     % (user.id, project.id))
280
280
        if check_type == 's3':
281
281
            sign = signer.Signer(user.secret.encode())
282
282
            expected_signature = sign.s3_authorization(headers, verb, path)
284
284
            logging.debug('expected_signature: %s', expected_signature)
285
285
            logging.debug('signature: %s', signature)
286
286
            if signature != expected_signature:
287
 
                raise exception.NotAuthorized('Signature does not match')
 
287
                raise exception.NotAuthorized(_('Signature does not match'))
288
288
        elif check_type == 'ec2':
289
289
            # NOTE(vish): hmac can't handle unicode, so encode ensures that
290
290
            #             secret isn't unicode
294
294
            logging.debug('expected_signature: %s', expected_signature)
295
295
            logging.debug('signature: %s', signature)
296
296
            if signature != expected_signature:
297
 
                raise exception.NotAuthorized('Signature does not match')
 
297
                raise exception.NotAuthorized(_('Signature does not match'))
298
298
        return (user, project)
299
299
 
300
300
    def get_access_key(self, user, project):
364
364
        with self.driver() as drv:
365
365
            if role == 'projectmanager':
366
366
                if not project:
367
 
                    raise exception.Error("Must specify project")
 
367
                    raise exception.Error(_("Must specify project"))
368
368
                return self.is_project_manager(user, project)
369
369
 
370
370
            global_role = drv.has_role(User.safe_id(user),
398
398
        @param project: Project in which to add local role.
399
399
        """
400
400
        if role not in FLAGS.allowed_roles:
401
 
            raise exception.NotFound("The %s role can not be found" % role)
 
401
            raise exception.NotFound(_("The %s role can not be found") % role)
402
402
        if project is not None and role in FLAGS.global_roles:
403
 
            raise exception.NotFound("The %s role is global only" % role)
 
403
            raise exception.NotFound(_("The %s role is global only") % role)
404
404
        with self.driver() as drv:
405
405
            drv.add_role(User.safe_id(user), role, Project.safe_id(project))
406
406
 
546
546
                                             Project.safe_id(project))
547
547
 
548
548
        if not network_ref['vpn_public_port']:
549
 
            raise exception.NotFound('project network data has not been set')
 
549
            raise exception.NotFound(_('project network data has not '
 
550
                                       'been set'))
550
551
        return (network_ref['vpn_public_address'],
551
552
                network_ref['vpn_public_port'])
552
553
 
659
660
                                  port=vpn_port)
660
661
            zippy.writestr(FLAGS.credential_vpn_file, config)
661
662
        else:
662
 
            logging.warn("No vpn data for project %s" %
663
 
                                  pid)
 
663
            logging.warn(_("No vpn data for project %s"), pid)
664
664
 
665
665
        zippy.writestr(FLAGS.ca_file, crypto.fetch_ca(user.id))
666
666
        zippy.close()