Esempio n. 1
0
 def doReportExisting(self, event, *args, **kwargs):
     """
     Action method.
     """
     if event == 'skip-check':
         return
     existing_domains = []
     results = args[0]['epp']['response']['resData']['chkData']['cd']
     if not results:
         self.outputs.append(zerrors.EPPResponseFailed())
         return
     if not isinstance(results, list):
         results = [results, ]
     for result in results:
         name = result.get('name', {}).get('#text')
         if not name:
             logger.error('unexpected EPP response, unknown domain name: %s' % args[0])
             continue
         if result.get('name', {}).get('@avail') == '0':
             if result.get('reason').lower().count('the domain exists'):
                 existing_domains.append(name)
                 self.check_results[name] = True
             else:
                 self.check_results[name] = zerrors.EPPUnexpectedResponse(response=args[0])
         else:
             self.check_results[name] = False
     self.outputs.append(existing_domains)
     self.outputs.append(args[0])
Esempio n. 2
0
 def doReportFailed(self, event, *args, **kwargs):
     """
     Action method.
     """
     if event == 'error':
         self.outputs.append(args[0])
     else:
         self.outputs.append(zerrors.EPPUnexpectedResponse(response=args[0]))
Esempio n. 3
0
 def _do_find_errors_in_response(self, response):
     results = response['epp']['response']['resData']['chkData']['cd']
     if not results:
         logger.error('unexpected EPP response, no results')
         return [zerrors.EPPResponseFailed(), ]
     if not isinstance(results, list):
         results = [results, ]
     for result in results:
         if not result.get('name', {}).get('#text'):
             logger.error('unexpected EPP response, unknown domain name: %s' % response)
             return [zerrors.EPPResponseFailed(), ]
         if result.get('name', {}).get('@avail') == '0':
             if not result.get('reason').lower().count('the domain exists'):
                 return [zerrors.EPPUnexpectedResponse(response=response), ]
     return []
Esempio n. 4
0
def domain_read_info(domain,
                     auth_info=None,
                     raise_errors=False,
                     log_events=True,
                     log_transitions=True):
    """
    Request from back-end and returns actual info about the domain.
    """
    dc = domains_checker.DomainsChecker(
        skip_check=True,
        skip_info=False,
        verify_registrant=False,
        stop_on_error=True,
        log_events=log_events,
        log_transitions=log_transitions,
        raise_errors=raise_errors,
    )
    dc.event(
        'run',
        [
            domain,
        ],
        auth_info=auth_info,
    )
    outputs = list(dc.outputs)
    del dc
    logger.info('domains_checker(%r) finished with %d outputs', domain,
                len(outputs))

    if not outputs or not outputs[-1] or isinstance(outputs[-1], Exception):
        if outputs and isinstance(outputs[-1], Exception):
            logger.error('domains_checker(%r) failed with: %r', domain,
                         outputs[-1])
        else:
            logger.error('domains_checker(%r) unexpectedly failed with: %r',
                         domain, outputs)
        if raise_errors:
            if not outputs or not outputs[-1]:
                raise zerrors.EPPResponseEmpty()
            elif isinstance(outputs[-1], Exception):
                raise outputs[-1]
            else:
                raise zerrors.EPPCommandFailed(outputs[-1])
        return None

    if not outputs[-1].get(domain):
        logger.error('domains_checker(%r) failed because domain not exist',
                     domain)
        if raise_errors:
            raise zerrors.EPPDomainNotExist()
        return None

    if len(outputs) < 2:
        logger.error('domains_checker(%r) failed with: %r', domain,
                     outputs[-1])
        if raise_errors:
            raise zerrors.EPPUnexpectedResponse(outputs)
        return None

    logger.info('domains_checker(%r) OK', domain)
    return outputs[-2]