コード例 #1
0
 def register_domain(self,
                     domain,
                     purchase_period,
                     user,
                     user_id,
                     password,
                     nameservers=None,
                     private_reg=False,
                     reg_domain=None,
                     extras=None):
     extras = extras or {}
     attrs = self._make_domain_reg_attrs(domain, purchase_period, user,
                                         user_id, password, nameservers,
                                         private_reg, reg_domain, **extras)
     if extras:
         attrs.update(extras)
     try:
         rsp = self._sw_register_domain(attrs)
         order_id = rsp.get_data()['attributes']['id']
         return {
             'domain_name': domain,
             'registrar_data': {
                 'ref_number': order_id
             }
         }
     except errors.XCPError as e:
         if e.response_code == self.CODE_DOMAIN_REGISTRATION_TAKEN:
             raise errors.DomainTaken(e)
         if e.response_code == self.CODE_DOMAIN_REGISTRATION_FAILED:
             if (e.response_text.startswith('Invalid domain syntax')
                     or e.response_text.startswith(
                         'Invalid syntax on domain')):
                 raise errors.InvalidDomain(e)
             raise errors.DomainRegistrationFailure(e)
         raise
コード例 #2
0
 def _capture(self, *args, **kwargs):
     try:
         return fn(self, *args, **kwargs)
     except errors.XCPError as e:
         if e.response_code == self.CODE_DOMAIN_REGISTRATION_TAKEN:
             raise errors.DomainTaken(e)
         if e.response_code == self.CODE_DOMAIN_REGISTRATION_FAILED:
             if (e.response_text.startswith('Invalid domain syntax') or
                     e.response_text.startswith(
                         'Invalid syntax on domain')):
                 raise errors.InvalidDomain(e)
             raise errors.DomainRegistrationFailure(e)
         if e.response_code == self.CODE_CLIENT_TIMED_OUT:
             raise errors.DomainRegistrationTimedOut(e)
         raise