Beispiel #1
0
 def create(self, req, body, tenant_id, instance_id):
     """Creates a set of users."""
     LOG.info(
         _("Creating users for instance '%(id)s'\n"
           "req : '%(req)s'\n\n"
           "body: '%(body)s'\n'n") % {
               "id": instance_id,
               "req": strutils.mask_password(req),
               "body": strutils.mask_password(body)
           })
     context = req.environ[wsgi.CONTEXT_KEY]
     self.authorize_target_action(context, 'user:create', instance_id)
     context.notification = notification.DBaaSUserCreate(context,
                                                         request=req)
     users = body['users']
     with StartNotification(context,
                            instance_id=instance_id,
                            username="******".join(
                                [user['name'] for user in users])):
         try:
             model_users = populate_users(users)
             models.User.create(context, instance_id, model_users)
         except (ValueError, AttributeError) as e:
             raise exception.BadRequest(
                 _("User create error: %(e)s") % {'e': e})
     return wsgi.Result(None, 202)
Beispiel #2
0
 def create(self, req, body, tenant_id, instance_id):
     """Creates a set of users."""
     LOG.info(_("Creating users for instance '%s'") % instance_id)
     LOG.info(_("req : '%s'\n\n") % strutils.mask_password(req))
     LOG.info(_("body : '%s'\n\n") % strutils.mask_password(body))
     context = req.environ[wsgi.CONTEXT_KEY]
     context.notification = notification.DBaaSUserCreate(context,
                                                         request=req)
     users = body['users']
     with StartNotification(context,
                            instance_id=instance_id,
                            username="******".join(
                                [user['name'] for user in users])):
         try:
             model_users = populate_users(users)
             models.User.create(context, instance_id, model_users)
         except (ValueError, AttributeError) as e:
             raise exception.BadRequest(msg=str(e))
     return wsgi.Result(None, 202)