Get A record

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.get_a name=abc.example.com
        salt-call infoblox.get_a ipv4addr=192.168.3.5
322970
def get_a(name=None, ipv4addr=None, allow_array=True, **api_opts):
    '''
    
    '''
    data = {}
    if name:
        data['name'] = name
    if ipv4addr:
        data['ipv4addr'] = ipv4addr
    r = get_object('record:a', data=data, **api_opts)
    if r and len(r) > 1 and not allow_array:
        raise Exception('More than one result, use allow_array to return the data')
    return r
591842
def get(self, record_id):
        
        record_url = self.record_url(record_id)
        return self._get(record_url)
1087570
def get_ip(interface=0):
    
    log = logging.getLogger(mod_logger + '.get_ip')

    log.info('Getting the IP address for this system...')
    ip_address = None
    try:
        log.info('Attempting to get IP address by hostname...')
        ip_address = socket.gethostbyname(socket.gethostname())
    except socket.error:
        log.info('Unable to get IP address for this system using hostname, '
                 'using a bash command...')
        command = 'ip addr show eth%s | grep inet | grep -v inet6 | ' \
                  'awk \'{ print $2 }\' | cut -d/ -f1 ' \
                  '>> /root/ip' % interface
        try:
            log.info('Running command: %s', command)
            subprocess.check_call(command, shell=True)
        except(OSError, subprocess.CalledProcessError):
            _, ex, trace = sys.exc_info()
            msg = 'Unable to get the IP address of this system\n{e}'.format(
                e=str(ex))
            log.error(msg)
            raise CommandError, msg, trace
        else:
            ip_file = '/root/ip'
            log.info('Command executed successfully, pulling IP address from '
                     'file: %s', ip_file)
            if os.path.isfile(ip_file):
                with open(ip_file, 'r') as f:
                    for line in f:
                        ip_address = line.strip()
                        log.info('Found IP address from file: %s', ip_address)
            else:
                msg = 'File not found: {f}'.format(f=ip_file)
                log.error(msg)
                raise CommandError(msg)
    log.info('Returning IP address: %s', ip_address)
    return ip_address
766267
def get_record(self, dns_record_type, host):
        """"""
        record_list = self._entries
        for record in record_list:
            if record._record_type == dns_record_type \
                    and record.host == host:
                return record
        return False
533678
def get_host_ipv6addr_info(ipv6addr=None, mac=None,
                                        discovered_data=None,
                                        return_fields=None, **api_opts):
    '''
    
    '''
    infoblox = _get_infoblox(**api_opts)
    return infoblox.get_host_ipv6addr_object(ipv6addr, mac, discovered_data, return_fields)
651869
def handle_getinfo(self, conn, args):
        """"""
        result = None
        if args[0] == b'version':
            result = self.version
        elif args[0] == b's2k_count':
            # Use highest number of S2K iterations.
            # https://www.gnupg.org/documentation/manuals/gnupg/OpenPGP-Options.html
            # https://tools.ietf.org/html/rfc4880#section-3.7.1.3
            result = '{}'.format(64 << 20).encode('ascii')
        else:
            log.warning('Unknown GETINFO command: %s', args)

        if result:
            keyring.sendline(conn, b'D ' + result)
1173252
public static InetAddress
    getByName(String name) throws UnknownHostException {
        try {
            return getByAddress(name);
        } catch (UnknownHostException e) {
            Record[] records = lookupHostName(name);
            return addrFromRecord(name, records[0]);
        }
    }
116451
def getPublicIPaddress(timeout=c.DEFAULT_TIMEOUT):
    """"""
    start = time.time()
    my_public_ip = None
    e = Exception
    while my_public_ip == None:
        if time.time() - start > timeout:
            break
        try: #httpbin.org -- site is useful to test scripts / applications.
            my_public_ip = json.load(urlopen('http://httpbin.org/ip'))['origin'] # takes ~0.14s as ipv4
            if my_public_ip: break
        except Exception as e:
            print(type(e), e, "http://httpbin.org/ip")
        try: #jsonip.com -- Seemingly the sole purpose of this domain is to return IP address in JSON.
            my_public_ip = json.load(urlopen('http://jsonip.com'))['ip']  # takes ~0.24s as ipv6
            if my_public_ip: break
        except Exception as e:
            print(type(e), e, "http://jsonip.com")
        try: #ipify.org -- Power of this service results from lack of limits (there is no rate limiting), infrastructure (placed on Heroku, with high availability in mind) and flexibility (works for both IPv4 and IPv6).
            my_public_ip = load(urlopen('https://api.ipify.org/?format=json'))['ip']  # takes ~0.33s
            if my_public_ip: break
        except Exception as e:
            print(type(e), e, "https://api.ipify.org/")
        try: #ip.42.pl -- This is very convenient for scripts, you don't need JSON parsing here.
            my_public_ip = urlopen('http://ip.42.pl/raw').read()  # takes ~0.35s
            if my_public_ip: break
        except Exception as e:
            print(type(e), e, "http://ip.42.pl/raw")
    if not my_public_ip:
        raise e
    return my_public_ip
811845
def do_get_block(req, proxy, conn, &block)
    @request_filter.each do |filter|
      filter.filter_request(req)
    end
    if str = @test_loopback_response.shift
      dump_dummy_request_response(req.body.dump, str) if @debug_dev
      conn.push(HTTP::Message.new_response(str))
      return
    end
    content = ''
    res = HTTP::Message.new_response(content)
    @debug_dev << "= Request\n\n" if @debug_dev
    sess = @session_manager.query(req, proxy)
    res.peer_cert = sess.ssl_peer_cert
    @debug_dev << "\n\n= Response\n\n" if @debug_dev
    do_get_header(req, res, sess)
    conn.push(res)
    sess.get_data() do |str|
      block.call(str) if block
      content << str
    end
    @session_manager.keep(sess) unless sess.closed?
    commands = @request_filter.collect { |filter|
      filter.filter_response(req, res)
    }
    if commands.find { |command| command == :retry }
      raise Client::RetryableResponse.new
    end
  end
1210410
def get(**kwargs):
    '''
    
    '''

    cmd = 'sysrc -v'

    if 'file' in kwargs:
        cmd += ' -f '+kwargs['file']

    if 'jail' in kwargs:
        cmd += ' -j '+kwargs['jail']

    if 'name' in kwargs:
        cmd += ' '+kwargs['name']
    elif kwargs.get('includeDefaults', False):
        cmd += ' -A'
    else:
        cmd += ' -a'

    sysrcs = __salt__['cmd.run'](cmd)
    if "sysrc: unknown variable" in sysrcs:
        # raise CommandExecutionError(sysrcs)
        return None

    ret = {}
    for sysrc in sysrcs.split("\n"):
        line_components = sysrc.split(': ')
        rcfile = line_components[0]
        if len(line_components) > 2:
            var = line_components[1]
            val = line_components[2]
        else:
            var = line_components[1].rstrip(':')
            val = ''
        if rcfile not in ret:
            ret[rcfile] = {}
        ret[rcfile][var] = val
    return ret
1113558
def _get_static_info(interface):
    '''
    
    '''
    data = {
        'connectionid': interface.name,
        'label': interface.name,
        'hwaddr': interface.hwaddr[:-1],
        'up': False,
        'ipv4': {
            'supportedrequestmodes': ['static', 'dhcp_linklocal', 'disabled'],
            'requestmode': 'static'
        },
        'wireless': False
    }
    hwaddr_section_number = ''.join(data['hwaddr'].split(':'))
    if os.path.exists(INTERFACES_CONFIG):
        information = _load_config(hwaddr_section_number, ['IPv4', 'Nameservers'], filename=INTERFACES_CONFIG)
        if information['IPv4'] != '':
            ipv4_information = information['IPv4'].split('/')
            data['ipv4']['address'] = ipv4_information[0]
            data['ipv4']['dns'] = information['Nameservers'].split(',')
            data['ipv4']['netmask'] = ipv4_information[1]
            data['ipv4']['gateway'] = ipv4_information[2]
    return data
653624
def get_vm_ip(name=None, session=None, call=None):
    '''
    

    '''
    if call == 'function':
        raise SaltCloudException(
            'This function must be called with -a or --action.'
        )
    if session is None:
        log.debug('New session being created')
        session = _get_session()
    vm = _get_vm(name, session=session)
    ret = None
    # -- try to get ip from vif
    vifs = session.xenapi.VM.get_VIFs(vm)
    if vifs is not None:
        for vif in vifs:
            if session.xenapi.VIF.get_ipv4_addresses(vif):
                cidr = session.xenapi.VIF.get_ipv4_addresses(vif).pop()
                ret, subnet = cidr.split('/')
                log.debug(
                    'VM vif returned for instance: %s ip: %s', name, ret)
                return ret
    # -- try to get ip from get tools metrics
    vgm = session.xenapi.VM.get_guest_metrics(vm)
    try:
        net = session.xenapi.VM_guest_metrics.get_networks(vgm)
        if "0/ip" in net.keys():
            log.debug(
                'VM guest metrics returned for instance: %s 0/ip: %s',
                name, net["0/ip"]
            )
            ret = net["0/ip"]
    # except Exception as ex:
    except XenAPI.Failure:
        log.info('Could not get vm metrics at this time')
    return ret
201587
def getGUA(self, filterByPrefix=None):
        
        print '%s call getGUA' % self.port
        print filterByPrefix
        globalAddrs = []
        try:
            # get global addrs set if multiple
            globalAddrs = self.getGlobal()

            if filterByPrefix is None:
                return self.__padIp6Addr(globalAddrs[0])
            else:
                for line in globalAddrs:
                    line = self.__padIp6Addr(line)
                    print "Padded IPv6 Address:" + line
                    if line.startswith(filterByPrefix):
                        return line
                print 'no global address matched'
                return str(globalAddrs[0])
        except Exception, e:
            ModuleHelper.WriteIntoDebugLogger('getGUA() Error: ' + str(e))
            return e
354542
def getACLs(self, base, searchstr):
		
		acls = dict()
		res = self.query(base, searchstr, ['cn', 'ipHostNumber'])
		for dn,attr in res:
			cn = attr['cn'][0]
			dests = dict()
			if attr.has_key('ipHostNumber'):
				for entry in attr['ipHostNumber']:
					dest = entry.split('#', 1)[0].replace(" ", "")
					if len(entry.split('#', 1)) == 2:
						desc = entry.split('#', 1)[1].strip()
					else:
						desc = ""
					if not is_ip(dest):
						print dest, desc
						raise InputError(dest, "Invalid IP format")
					dests[dest] = desc
			acls[cn] = dests
		return acls
269890
def get_client_address(self, use_x_forwarded=True):
        
        xfor = self.environ.get('HTTP_X_FORWARDED_FOR')
        if use_x_forwarded and xfor:
            return xfor.split(',')[-1].strip()
        else:
            return self.environ['REMOTE_ADDR']
1205644
def get_record(identifier)
      doc = client.get!(CGI.escape(identifier)).body.to_json
      @record_class.build(mint_id(identifier), doc, 'application/json')
    end
755174
def AAAA(host, nameserver=None):
    '''
    
    '''
    if _has_dig():
        return __salt__['dig.AAAA'](host, nameserver)
    elif nameserver is None:
        # fall back to the socket interface, if we don't care who resolves
        try:
            addresses = [sock[4][0] for sock in socket.getaddrinfo(host, None, socket.AF_INET6, 0, socket.SOCK_RAW)]
            return addresses
        except socket.gaierror:
            return 'Unable to resolve {0}'.format(host)

    return 'This function requires dig, which is not currently available'