예제 #1
0
 def show(self, req, tenant_id, instance_id, id):
     """Return a single user."""
     LOG.info(_("Showing a user for instance '%s'") % instance_id)
     LOG.info(_("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     username, host = unquote_user_host(id)
     user = None
     try:
         user = models.User.load(context, instance_id, username, host)
     except (ValueError, AttributeError) as e:
         raise exception.BadRequest(msg=str(e))
     if not user:
         raise exception.UserNotFound(uuid=id)
     view = views.UserView(user)
     return wsgi.Result(view.data(), 200)
예제 #2
0
파일: service.py 프로젝트: wffeige/trove
 def show(self, req, tenant_id, instance_id, id):
     """Return a single user."""
     LOG.info("Showing a user for instance '%(id)s'\n"
              "req : '%(req)s'\n\n",
              {"id": instance_id, "req": req})
     context = req.environ[wsgi.CONTEXT_KEY]
     self.authorize_target_action(context, 'user:show', instance_id)
     id = correct_id_with_req(id, req)
     username, host = unquote_user_host(id)
     user = None
     try:
         user = models.User.load(context, instance_id, username, host)
     except (ValueError, AttributeError) as e:
         raise exception.BadRequest(_("User show error: %(e)s")
                                    % {'e': e})
     if not user:
         raise exception.UserNotFound(uuid=id)
     view = views.UserView(user)
     return wsgi.Result(view.data(), 200)