uses SharedDns to find an available set of DNS records and sets them on the deployment
2927
def setup_dns(domain)
# TODO should we just use the ID instead of the full href?
      owner=@deployment.href
      @dns = SharedDns.new(domain)
      raise "Unable to reserve DNS" unless @dns.reserve_dns(owner)
      @dns.set_dns_inputs(@deployment)
    end
363642
def _set_bucket_dns(self):
        """"""
        # Different regions have different s3 endpoint formats
        dotformat_regions = ["eu-west-2", "eu-central-1", "ap-northeast-2", "ap-south-1", "ca-central-1", "us-east-2"]
        if self.region in dotformat_regions:
            s3_endpoint = "{0}.s3-website.{1}.amazonaws.com".format(self.bucket, self.region)
        else:
            s3_endpoint = "{0}.s3-website-{1}.amazonaws.com".format(self.bucket, self.region)

        zone_ids = get_dns_zone_ids(env=self.env, facing="public")
        dns_kwargs = {
            'dns_name': self.bucket,
            'dns_name_aws': s3_endpoint,
            'dns_ttl': self.properties['dns']['ttl']
        }

        for zone_id in zone_ids:
            LOG.debug('zone_id: %s', zone_id)
            update_dns_zone_record(self.env, zone_id, **dns_kwargs)
        LOG.info("Created DNS %s for Bucket", self.bucket)
445997
def execute
      options = {}
      opts = OptionParser.new do |opts|
        opts.banner = "Usage: vagrant dns [vm-name] [-i|--install] [-u|--uninstall] [--with-sudo] [--pruge] [-s|--start] [-S|--stop] [-r|--restart] [--status] [-l|--list] [-o|--ontop]"
        opts.separator ""

        opts.on("--install", "-i", "Install DNS config for machine domain") do
          options[:install] = true
          options[:build_config] = true
          options[:manage_installation] = true
        end

        opts.on("--uninstall", "-u", "Uninstall DNS config for machine domain") do
          options[:uninstall] = true
          options[:build_config] = false
          options[:manage_installation] = true
          options[:stop] = true
        end

        opts.on("--purge", "Uninstall DNS config and remove DNS configurations of all machines.") do
          options[:purge] = true
          options[:build_config] = false
          options[:manage_installation] = true
          options[:stop] = true
        end

        opts.on("--start", "-s", "Start the DNS service") do
          options[:start] = true
          options[:build_config] = true
        end

        opts.on("--stop", "-S", "Stop the DNS service") do
          options[:stop] = true
          options[:build_config] = false
        end

        opts.on("--restart", "-r", "Restart the DNS service") do
          options[:restart] = true
          options[:build_config] = true
        end

        opts.on("--status", "Show DNS service running status and PID.") do
          options[:status] = true
          options[:build_config] = false
        end

        opts.on("--list", "-l", "Show the current DNS service config. This works in conjunction with --start --stop --restart --status.") do
          options[:show_config] = true
          options[:build_config] = false
        end

        opts.on("--with-sudo", "In conjunction with `--install`, `--uninstall`, `--purge`: Run using `sudo` instead of `osascript`. Useful for automated scripts running as sudoer.") do
          options[:installer_opts] = { exec_style: :sudo }
        end

        opts.on("--ontop", "-o", "Start the DNS service on top. Debugging only, this blocks Vagrant!") do
          options[:ontop] = true
        end
      end

      argv = parse_options(opts)
      return if !argv

      vms = argv unless argv.empty?

      build_config(vms, options)        if options[:build_config]
      manage_service(vms, options)
      manage_installation(vms, options) if options[:manage_installation]
      show_config(vms, options)         if options[:show_config]
    end
973779
public function addDNSRecord($domain, $rec, $type, $val, $priority)
    {
        $this->send('v-add-dns-record', $this->userName, $domain, $rec, $type, $val, $priority);
    }
34969
def create_dns_file(opts, record):
    """"""
    info("[+] \033[92mUpdating dns.txt file\033[0m")
    filename = os.path.join(opts.mirrordir, 'dns.txt')
    localmd5 = get_file_md5(filename)
    remotemd5 = get_md5(record)
    if localmd5 != remotemd5:
        create_file(filename, record)
        info("=> dns.txt file updated")
    else:
        info("=> No update required L: %s => R: %s" % (localmd5, remotemd5))
759156
def dns_rr(self, ips):
        
        api_name = 'opendns-dns_rr'
        fmt_url_path = u'dnsdb/name/a/{0}.json'
        return self._multi_get(api_name, fmt_url_path, ips)
443164
def post_dns_record(**kwargs):
    '''
    
    '''
    if 'kwargs' in kwargs:  # flatten kwargs if called via salt-cloud -f
        f_kwargs = kwargs['kwargs']
        del kwargs['kwargs']
        kwargs.update(f_kwargs)
    mandatory_kwargs = ('dns_domain', 'name', 'record_type', 'record_data')
    for i in mandatory_kwargs:
        if kwargs[i]:
            pass
        else:
            error = '{0}="{1}" ## all mandatory args must be provided: {2}'.format(i, kwargs[i], mandatory_kwargs)
            raise SaltInvocationError(error)

    domain = query(method='domains', droplet_id=kwargs['dns_domain'])

    if domain:
        result = query(
            method='domains',
            droplet_id=kwargs['dns_domain'],
            command='records',
            args={'type': kwargs['record_type'], 'name': kwargs['name'], 'data': kwargs['record_data']},
            http_method='post'
        )
        return result

    return False
488584
def _request_add_dns_record(self, record):
        """"""
        return self._request_internal("Add_DNS_Record",
                                      domain=self.domain,
                                      record=record)
487509
def create_dns(self):
        """"""
        utils.banner("Creating DNS")
        elb_subnet = self.configs[self.env]['elb']['subnet_purpose']
        regions = self.configs[self.env]['regions']
        failover = self.configs[self.env]['dns']['failover_dns']
        primary_region = self.configs['pipeline']['primary_region']
        regionspecific_dns = self.configs[self.env]['dns']['region_specific']

        dnsobj = dns.SpinnakerDns(
            app=self.app, env=self.env, region=self.region, prop_path=self.json_path, elb_subnet=elb_subnet)

        if len(regions) > 1 and failover:
            dnsobj.create_elb_dns(regionspecific=True)
            dnsobj.create_failover_dns(primary_region=primary_region)
        else:
            if regionspecific_dns:
                dnsobj.create_elb_dns(regionspecific=True)

            if self.region == primary_region:
                dnsobj.create_elb_dns(regionspecific=False)
803012
def get_axfr_records(self, server, domains):
        
        zones = []
        for zoneName in domains:
            try:
                zone = {
                    'zone_id': get_resource_id('axfrz', zoneName),
                    'name': zoneName,
                    'source': 'AXFR',
                    'comment': None,
                    'tags': {},
                    'records': []
                }

                z = dns_zone.from_xfr(query.xfr(server, zoneName))
                rdata_fields = ('name', 'ttl', 'rdata')
                for rr in [dict(zip(rdata_fields, x)) for x in z.iterate_rdatas()]:
                    record_name = rr['name'].derelativize(z.origin).to_text()
                    zone['records'].append(
                    {
                        'id': get_resource_id('axfrr', record_name, ['{}={}'.format(k, str(v)) for k, v in rr.items()]),
                        'zone_id': zone['zone_id'],
                        'name': record_name,
                        'value': sorted([rr['rdata'].to_text()]),
                        'type': type_to_text(rr['rdata'].rdtype)
                    })

                if len(zone['records']) > 0:
                    zones.append(zone)

            except Exception as ex:
                self.log.exception('Failed fetching DNS zone information for {}: {}'.format(zoneName, ex))
                raise

        return zones
1092012
def lookupAllRecords(self, name, timeout = None):
        
        return self._lookup(name, dns.IN, dns.A, timeout)
403375
def create_elb_dns(self, regionspecific=False):
        
        if regionspecific:
            dns_elb = self.generated.dns()['elb_region']
        else:
            dns_elb = self.generated.dns()['elb']

        dns_elb_aws = find_elb(name=self.app_name, env=self.env, region=self.region)

        zone_ids = get_dns_zone_ids(env=self.env, facing=self.elb_subnet)

        self.log.info('Updating Application URL: %s', dns_elb)

        dns_kwargs = {
            'dns_name': dns_elb,
            'dns_name_aws': dns_elb_aws,
            'dns_ttl': self.dns_ttl,
        }

        for zone_id in zone_ids:
            self.log.debug('zone_id: %s', zone_id)
            update_dns_zone_record(self.env, zone_id, **dns_kwargs)

        return dns_elb
302156
def dns():
    '''
    
    '''
    # Provides:
    #   dns
    if salt.utils.platform.is_windows() or 'proxyminion' in __opts__:
        return {}

    resolv = salt.utils.dns.parse_resolv()
    for key in ('nameservers', 'ip4_nameservers', 'ip6_nameservers',
                'sortlist'):
        if key in resolv:
            resolv[key] = [six.text_type(i) for i in resolv[key]]

    return {'dns': resolv} if resolv else {}
1351953
function(key, dest, containerName) {

      // Attempt to connect to redis
      return getRedisClient()

      // Run the redis query and then quit
      .then(function(redis) {
        log.debug(format('Setting DNS. %s => %s', key, dest));
        return Promise.fromNode(function(cb) {
          redis.multi()
          .del(key)
          .rpush(key, containerName)
          .rpush(key, dest)
          .exec(cb);
        })
        .then(function() {
          redis.quit();
        });
      });

    }
307703
def update_route53_records(self, domain_name, dns_name):
        
        zone_id = self.get_hosted_zone_id_for_domain(domain_name)

        is_apex = self.route53.get_hosted_zone(Id=zone_id)['HostedZone']['Name'][:-1] == domain_name
        if is_apex:
            record_set = {
                'Name': domain_name,
                'Type': 'A',
                'AliasTarget': {
                    'HostedZoneId': 'Z2FDTNDATAQYW2', # This is a magic value that means "CloudFront"
                    'DNSName': dns_name,
                    'EvaluateTargetHealth': False
                }
            }
        else:
            record_set = {
                'Name': domain_name,
                'Type': 'CNAME',
                'ResourceRecords': [
                    {
                        'Value': dns_name
                    }
                ],
                'TTL': 60
            }

        # Related: https://github.com/boto/boto3/issues/157
        # and: http://docs.aws.amazon.com/Route53/latest/APIReference/CreateAliasRRSAPI.html
        # and policy: https://spin.atomicobject.com/2016/04/28/route-53-hosted-zone-managment/
        # pure_zone_id = zone_id.split('/hostedzone/')[1]

        # XXX: ClientError: An error occurred (InvalidChangeBatch) when calling the ChangeResourceRecordSets operation:
        # Tried to create an alias that targets d1awfeji80d0k2.cloudfront.net., type A in zone Z1XWOQP59BYF6Z,
        # but the alias target name does not lie within the target zone
        response = self.route53.change_resource_record_sets(
            HostedZoneId=zone_id,
            ChangeBatch={
                'Changes': [
                    {
                        'Action': 'UPSERT',
                        'ResourceRecordSet': record_set
                    }
                ]
            }
        )

        return response
1256496
def _generate_create_dict(record, record_type, data, ttl, **kwargs):
        """"""

        # Basic dns record structure
        resource_record = {
            'host': record,
            'data': data,
            'ttl': ttl,
            'type': record_type
        }

        for (key, value) in kwargs.items():
            resource_record.setdefault(key, value)

        return resource_record
999522
def get_recordInfo(self, headers, zoneID, zone, records):
        """"""
        if 'None' in records: #If ['None'] in record argument, query all.
            recordQueryEnpoint = '/' + zoneID + '/dns_records&per_page=100'
            recordUrl = self.BASE_URL + recordQueryEnpoint
            recordRequest = requests.get(recordUrl, headers=headers)
            recordResponse = recordRequest.json()['result']
            dev = []
            num = 0
            for value in recordResponse:
                recordName = recordResponse[num]['name']
                dev.append(recordName)
                num = num + 1
            records = dev
        updateRecords = []
        for record in records:
            if zone in record:
                recordFullname = record
            else:
                recordFullname = record + '.' + zone
            recordQuery = '/' + zoneID + '/dns_records?name=' + recordFullname
            recordUrl = self.BASE_URL + recordQuery
            recordInfoRequest = requests.get(recordUrl, headers=headers)
            recordInfoResponse = recordInfoRequest.json()['result'][0]
            recordID = recordInfoResponse['id']
            recordType = recordInfoResponse['type']
            recordProxy = str(recordInfoResponse['proxied'])
            recordContent = recordInfoResponse['content']
            if recordProxy == 'True':
                recordProxied = True
            else:
                recordProxied = False
            updateRecords.append([recordID, recordFullname, recordType,
                recordContent, recordProxied])
        return updateRecords