コード例 #1
0
ファイル: service.py プロジェクト: wffeige/trove
 def update(self, req, body, tenant_id, instance_id, id):
     """Change attributes for one user."""
     LOG.info("Updating user attributes for instance '%(id)s'\n"
              "req : '%(req)s'\n\n",
              {"id": instance_id, "req": strutils.mask_password(req)})
     context = req.environ[wsgi.CONTEXT_KEY]
     self.authorize_target_action(context, 'user:update', instance_id)
     id = correct_id_with_req(id, req)
     username, hostname = unquote_user_host(id)
     user = None
     user_attrs = body['user']
     context.notification = notification.DBaaSUserUpdateAttributes(
         context, request=req)
     with StartNotification(context, instance_id=instance_id,
                            username=username):
         try:
             user = models.User.load(context, instance_id, username,
                                     hostname)
         except (ValueError, AttributeError) as e:
             raise exception.BadRequest(_("Error loading user: %(e)s")
                                        % {'e': e})
         if not user:
             raise exception.UserNotFound(uuid=id)
         try:
             models.User.update_attributes(context, instance_id, username,
                                           hostname, user_attrs)
         except (ValueError, AttributeError) as e:
             raise exception.BadRequest(_("User update error: %(e)s")
                                        % {'e': e})
     return wsgi.Result(None, 202)
コード例 #2
0
ファイル: service.py プロジェクト: raman-mystack/tesora-trove
 def update(self, req, body, tenant_id, instance_id, id):
     """Change attributes for one user."""
     LOG.info(_("Updating user attributes for instance '%s'") % instance_id)
     LOG.info(_("req : '%s'\n\n") % strutils.mask_password(req))
     context = req.environ[wsgi.CONTEXT_KEY]
     id = correct_id_with_req(id, req)
     username, hostname = unquote_user_host(id)
     user = None
     user_attrs = body['user']
     context.notification = notification.DBaaSUserUpdateAttributes(
         context, request=req)
     with StartNotification(context,
                            instance_id=instance_id,
                            username=username):
         try:
             user = models.User.load(context, instance_id, username,
                                     hostname)
         except (ValueError, AttributeError) as e:
             raise exception.BadRequest(msg=str(e))
         if not user:
             raise exception.UserNotFound(uuid=id)
         try:
             models.User.update_attributes(context, instance_id, username,
                                           hostname, user_attrs)
         except (ValueError, AttributeError) as e:
             raise exception.BadRequest(msg=str(e))
     return wsgi.Result(None, 202)