Handles discovery for a domain
971688
def discover_site(domain)
      url = fetch_host_meta(domain)
      if url.nil?
        return nil # Not a Google Apps domain
      end
      xrds = fetch_xrds(domain, url)
      unless xrds.nil?
          endpoints = OpenID::OpenIDServiceEndpoint.from_xrds(domain, xrds)
          return [domain, OpenID.get_op_or_user_services(endpoints)]
      end
      return nil
    end
1140990
def _populate_domain(self):
        '''
        '''

        self.domain = {}
        for device in self.devices:
            device_name = get_device_info(device).name
            ca_devices = \
                device.tm.cm.trust_domains.trust_domain.load(
                    name='Root'
                ).caDevices
            self.domain[device_name] = [
                d.replace('/%s/' % self.partition, '') for d in ca_devices
            ]
664709
def _domain_event_watchdog_cb(conn, domain, action, opaque):
    '''
    
    '''
    _salt_send_domain_event(opaque, conn, domain, opaque['event'], {
        'action': _get_libvirt_enum_string('VIR_DOMAIN_EVENT_WATCHDOG_', action)
    })
1188340
def get_domain_events(self, originator_id, gt=None, gte=None, lt=None, lte=None, limit=None, is_ascending=True,
                          page_size=None):
        
547728
def perform_discovery(uri)
      begin
        parsed_uri = URI::parse(uri)
        if parsed_uri.scheme.nil?
          return discover_site(uri)
        end
        return discover_user(parsed_uri.host, uri)
      rescue
        # If we fail, just return nothing and fallback on default discovery mechanisms
        return nil
      end
    end
795315
def append_domain():
    '''
    
    '''

    grain = {}

    if salt.utils.platform.is_proxy():
        return grain

    if 'append_domain' in __opts__:
        grain['append_domain'] = __opts__['append_domain']
    return grain
310162
def _domain_event_lifecycle_cb(conn, domain, event, detail, opaque):
    '''
    
    '''
    event_str, detail_str = _get_domain_event_detail(event, detail)

    _salt_send_domain_event(opaque, conn, domain, opaque['event'], {
        'event':  event_str,
        'detail': detail_str
    })
399581
def discovery(self, url=None):
        
        if url:
            data = self.session.get(url).content
        elif self.discovery_url:
            response = self.session.get(self.discovery_url)
            if self.format == 'xml':
                # Because, SF doesn't follow the spec.
                data = xml(response.text)
            else:
                # Spec calls for discovery always allowing JSON.
                data = response.json()
        else:
            data = self.get('discovery')
        return data
212078
function createARecord (domain, subdomain, ip, cb) {
        var body = {
            name: subdomain,
            type: 'A',
            content: ip
        };
        _hoverRequest('POST', '/domains/' + domain + '/dns', body, cb);
    }
408653
def create_domain(self, domain_name):
        
        params = {'DomainName':domain_name}
        d = self.get_object('CreateDomain', params, Domain)
        d.name = domain_name
        return d
695092
def get(cls, domain, name):
        
        Site = cls
        return Session.query(Site).filter(Site.domain == domain).filter(collate(Site.name, 'NOCASE') == name).first()
1156143
def find_subdomains(domain):
    """"""
    result = set()
    response = get('https://findsubdomains.com/subdomains-of/' + domain).text
    matches = findall(r'(?s)<div class="domains js-domain-name">(.*?)</div>', response)
    for match in matches:
        result.add(match.replace(' ', '').replace('\n', ''))
    return list(result)
992252
function checkDomain(result) {
  // TODO: check against some config value for the domain or similar
  return function(domain, options, callback) {
    result.domain = domain;
    return callback(null, true);
  };
}
602933
def filter_by_domain(self, domain):
        
        query = self._copy()
        query.domain = domain
        return query
559432
function domain() {
        return wrap('domain', function domainCheckTLD() {
            var result = or(obsDomain, dotAtom, domainLiteral)();
            if (opts.rejectTLD) {
                if (result && result.semantic && result.semantic.indexOf('.') < 0) {
                    return null;
                }
            }
            // strip all whitespace from domains
            if (result) {
                result.semantic = result.semantic.replace(/\s+/g, '');
            }
            return result;
        }());
    }
979693
def on_discovery_update(self, name, new_config):
        
        for service in self.configurables[Service].values():
            if service.discovery == name:
                service.reset_status()
226285
def lookup_domains(self):
        
        thread_error = False
        thread_wait_timeout = 200
        ind = 1
        total_item_count = len(self.domains)
        for domain in self.domains:
            for nameserver in self.nameservers:
                wait_time = 0
                while threading.active_count() > self.max_threads:
                    time.sleep(1)
                    wait_time += 1
                    if wait_time > thread_wait_timeout:
                        thread_error = True
                        break

                if thread_error:
                    self.results["error"] = "Threads took too long to finish."
                    break
                log_prefix = "%d/%d: " % (ind, total_item_count)
                thread = threading.Thread(target=self.lookup_domain,
                                          args=(domain, nameserver,
                                                log_prefix))
                thread.setDaemon(1)

                thread_open_success = False
                retries = 0
                while not thread_open_success and retries < MAX_THREAD_START_RETRY:
                    try:
                        thread.start()
                        self.threads.append(thread)
                        thread_open_success = True
                    except:
                        retries += 1
                        time.sleep(THREAD_START_DELAY)
                        logging.error("%sThread start failed for %s, retrying... (%d/%d)" % (log_prefix, domain, retries, MAX_THREAD_START_RETRY))

                if retries == MAX_THREAD_START_RETRY:
                    logging.error("%sCan't start a new thread for %s after %d retries." % (log_prefix, domain, retries))

            if thread_error:
                break
            ind += 1

        for thread in self.threads:
            thread.join(self.timeout * 3)
        return self.results