def handle_put_account(self, req):
if not self.is_reseller_admin(req):<EOL><INDENT>return self.denied_response(req)<EOL><DEDENT>account = req.path_info_pop()<EOL>if req.path_info or not account or account[<NUM_LIT:0>] == '<STR_LIT:.>':<EOL><INDENT>return HTTPBadRequest(request=req)<EOL><DEDENT>account_suffix = req.headers.get('<STR_LIT>')<EOL>if not account_suffix:<EOL><INDENT>account_suffix = str(uuid4())<EOL><DEDENT>path = quote('<STR_LIT>' % (self.dsc_parsed2.path,<EOL>self.reseller_prefix, account_suffix))<EOL>try:<EOL><INDENT>conn = self.get_conn()<EOL>conn.request('<STR_LIT>', path,<EOL>headers={'<STR_LIT>': self.get_itoken(req.environ),<EOL>'<STR_LIT>': '<STR_LIT:0>'})<EOL>resp = conn.getresponse()<EOL>resp.read()<EOL>if resp.status // <NUM_LIT:100> != <NUM_LIT:2>:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>' % (path, resp.status, resp.reason))<EOL><DEDENT><DEDENT>except (Exception, TimeoutError):<EOL><INDENT>self.logger.error(_('<STR_LIT>'<EOL>'<STR_LIT>'),<EOL>{'<STR_LIT>': self.dsc_parsed2.scheme,<EOL>'<STR_LIT:host>': self.dsc_parsed2.hostname,<EOL>'<STR_LIT:port>': self.dsc_parsed2.port, '<STR_LIT:path>': path})<EOL>raise<EOL><DEDENT>path = quote('<STR_LIT>' % (self.auth_account, account))<EOL>resp = self.make_pre_authed_request(<EOL>req.environ, '<STR_LIT>', path).get_response(self.app)<EOL>if resp.status_int == <NUM_LIT>:<EOL><INDENT>resp = self.make_pre_authed_request(<EOL>req.environ, '<STR_LIT>', path).get_response(self.app)<EOL>if resp.status_int // <NUM_LIT:100> != <NUM_LIT:2>:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>' % (path, resp.status))<EOL><DEDENT><DEDENT>elif resp.status_int // <NUM_LIT:100> == <NUM_LIT:2>:<EOL><INDENT>if '<STR_LIT>' in resp.headers:<EOL><INDENT>return HTTPAccepted(request=req)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>' % (path, resp.status))<EOL><DEDENT>path = quote('<STR_LIT>' %<EOL>(self.auth_account, self.reseller_prefix, account_suffix))<EOL>resp = self.make_pre_authed_request(<EOL>req.environ, '<STR_LIT>', path, account).get_response(self.app)<EOL>if resp.status_int // <NUM_LIT:100> != <NUM_LIT:2>:<EOL><INDENT>raise Exception('<STR_LIT>' %<EOL>(path, resp.status))<EOL><DEDENT>path = quote('<STR_LIT>' % (self.auth_account, account))<EOL>services = {'<STR_LIT>': {}}<EOL>services['<STR_LIT>'][self.dsc_name] = '<STR_LIT>' % (self.dsc_url,<EOL>self.reseller_prefix, account_suffix)<EOL>services['<STR_LIT>']['<STR_LIT:default>'] = self.dsc_name<EOL>resp = self.make_pre_authed_request(<EOL>req.environ, '<STR_LIT>', path,<EOL>json.dumps(services)).get_response(self.app)<EOL>if resp.status_int // <NUM_LIT:100> != <NUM_LIT:2>:<EOL><INDENT>raise Exception('<STR_LIT>' %<EOL>(path, resp.status))<EOL><DEDENT>path = quote('<STR_LIT>' % (self.auth_account, account))<EOL>resp = self.make_pre_authed_request(<EOL>req.environ, '<STR_LIT:POST>', path,<EOL>headers={'<STR_LIT>': '<STR_LIT>' % (<EOL>self.reseller_prefix, account_suffix)}).get_response(self.app)<EOL>if resp.status_int // <NUM_LIT:100> != <NUM_LIT:2>:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>' % (path, resp.status))<EOL><DEDENT>return HTTPCreated(request=req)<EOL>
Handles the PUT v2/<account> call for adding an account to the auth
        system. Can only be called by a .reseller_admin.

        By default, a newly created UUID4 will be used with the reseller prefix
        as the account id used when creating corresponding service accounts.
        However, you can provide an X-Account-Suffix header to replace the
        UUID4 part.

        :param req: The swob.Request to process.
        :returns: swob.Response, 2xx on success.