DNS DHCP IPAM

Reply
Highlighted

Host record A and PTR entities

RWhitney
Techie
Posts: 4
18435     0

Hello all.

I am creating and deleting Host records succesfully via REST  /wapi/%apiVer%/record:host.

Should I expect to have A and PTR entities for each Host record via record:a and recordSmiley Tonguetr respectively? When I query the A and PTR I get nothing back.

Thx - Rock

HOST vs. A/PTR

Adviser
Posts: 194
18436     0

No, you should expect to have a HOST object.  This gets translated automatically at the protocol level into A and PTR records but you cannot access them as A and PTR records via the API.

Thanks Don! I have reset my

RWhitney
Techie
Posts: 4
18436     0

Thanks Don! I have reset my expectations Smiley Happy

Create a Host with DNS Record Using the REST API

HMokhtari
Techie
Posts: 6
18436     0

Hello,

I' m trying to create a host wit dns record:
https://.../wapi/v1.0/record:a -d '{ "name": "hostname.domainname.com", "ipv4addr":"192.168.200.11"}'
Is that the right WAPI call?
FYI: I' m using WAPI version 1.0

Thanks a lot

Create a Host with DNS Record Using the REST API

Adviser
Posts: 194
18436     0

That call would create an A record.  If you want to create a HOST record, you would make a call to "record:host" instead.

 

Hi,

HMokhtari
Techie
Posts: 6
18436     0

Hi,

I tried it with record:host and this parameter  
{"ipv4addrs":[{{"configure_for_dhcp": false, "ipv4addr": "123.123.123.123"}}], "name": "hostname.domanin.com", "configure_for_dns": true}

but i got the error
{ "Error": "AdmConDataError: None (IBDataConflictError: IB.Data.Conflict:Host records cannot be added to the zone domain.com while Microsoft servers are configured for the zone.)",
  "code": "Client.Ibap.Data.Conflict",
  "text": "Host records cannot be added to the zone domain.com while Microsoft servers are configured for the zone."
}

Have someone an idee, what the problem is?

Thanks a lot

Create Host records in MSFT "owned" zones

Adviser
Posts: 194
18436     0

Host records can only be created for zones which are fully Infoblox managed.  If the zone resides on a Microsoft Primary, only A/AAAA and PTR records can be created (in addition to other "regular" supported DNS records).  To take advantage of Host records, you would need to migrate the zone "primary" to an Infoblox DNS server.  You could then either continue to use MSFT DNS servers as secondaries or replace them all with Infoblox DNS servers and gain the advanced functionality offered as a fully integrated Infoblox zone.

 

Trying to create a new host by using wapi.

qjin
Techie
Posts: 2
18436     0

Hi, 

I am tyring to create a host by using infoblox wapi, 

 Here is the code I was using.

import requests
>>> session = requests.Session()
>>> session.auth = ('root', 'a!')
>>> session.verify = False
>>> url = 'https://infoblox.example.com/wapi/v1.4/'

data = {'ipv4addrs':[{'ipv4addr':'10.7.191.225', 'configure_for_dhcp':'false'}], 'name':'aaa.host.com'}

>>> r= session.post(url+'record:host', data=data)
r.status_code
r.content

Getting errors as follows.

{ "Error": "AdmConProtoError: Arguments can not be repeated (ipv4addrs)", \n  "code": "Client.Ibap.Proto", \n  "text": "Arguments can not be repeated (ipv4addrs)"\n}'

 

I am curious about the errors I am getting.

Thanks

 

 

 

 

Using Python requests module to create host records

Adviser
Posts: 129
18436     0

It looks as if you are using the Python requests module. I've done some work with that myself, and I think I know what your problem is.

First, when using the 'data' keyword argument to session.post you can't pass a dictionary directly; instead you have to convert it using json.dumps():

  import json
 
r = session.post(url+'record:host', data=json.dumps(data))

That's the immediate cause of the 'Arguments can not be repeated' error you're seeing.

Next, you need to use a Boolean instead of a string when setting the values of parameters like 'configure_for_dhcp':

  data = {'ipv4addrs': [{'ipv4addr': '10.7.191.225', 'configure_for_dhcp': False}], 'name': 'aaa.host.com'}

With these changes I was able to get your code to work on my system. The returned r.status_code should be 201 and the returned r.text should be a reference to the just-created host record.

Please let me know if this works for you as well.

Frank

 

It's working, and thanks a lot.

qjin
Techie
Posts: 2
18436     0

It's working perfectly, and appreciate again for the fast response.

python query

JMedina
Techie
Posts: 2
18436     0
I am using the python infoblox module and am trying to do queries on both hostnames and IP addresses. I am able to do this via web REST API, but cannot figure it out with the python infoblox module. For example, how do I do this in python? curl -k -H "Content-Type: application/json" -X GET https://infobloxserver.com/wapi/v1.0/record:host?name~=somehostname I tried something like this: import infoblox s = infoblox.Session('https://server.com', 'user', 'password’) host = infoblox.Host(session, 'hostname') print host.ipv4addrs # gives empty list, even though there is a host with that name with ip addresses And the same for getting a IP address record.

Using the RESTful API from Python

Adviser
Posts: 129
18436     0

I haven't used the infoblox module for Python, and unfortunately I don't have time to try it out right now. However here is a sample Python program using the requests module (http://docs.python-requests.org/en/latest/):

# Import the required Python modules.
import requests
import getpass
import sys

# Set parameters to access the NIOS WAPI.
url = 'https://gm.example.com/wapi/v1.0/'
id = 'api'  # Userid with WAPI access
valid_cert = False  # True if GM uses a CA-issued certificate

# Prompt for the WAPI user password.
pw = getpass.getpass('Password for user ' + id + ': ')

# Retrieve host records matching a search string.
search_str = 'example'
r = requests.get(url + 'record:host' + '?name~=' + search_str,
                 auth=(id, pw),
                 verify=valid_cert)
if r.status_code != requests.codes.ok:
    print r.text
    exit_msg = 'Error {} finding host(s): {}'
    sys.exit(exit_msg.format(r.status_code, r.reason))
results = r.json()

# Print the raw output for each host found.
for result in results:
    print result

Thanks! That works great!

JMedina
Techie
Posts: 2
18436     0
Thanks! That works great!

Error - cannot register A record in DNS infoblox

rhaneef
Techie
Posts: 1
18436     0
Hi Guys, I'm new in Infoblox and clueless on this matter. I received a message when register the A record. Error message says "The IP address XX.XXX.XXX.XXX cannot be used for the zone drac.local. Verify the network association in the zone properties." Please advise how to solve this problem. Thank you in advance.

Re: Using Python requests module to create host records

Thiyagu
Techie
Posts: 1
18436     0

Hi FHecker,

 

I am new to coding and learning WAPI with python. Trying with python requests module to create HOST record. Which I am abel to but when I try to create the record with 'ttl' value also set, I getting error back as 'BAD REQUEST'. I tried multiple options but no success. Can you help?

 

Options I tried:

hostdata = {'ipv4addrs':[{'ipv4addr': ipaddress},{'ttl':'30'}],'name': hostname}
addHostRec = session.post(hostaddurl, data=json.dumps(hostdata))
-------
hostdata = {'ipv4addrs':[{'ipv4addr': ipaddress,'ttl':'30'}],'name': hostname}
addHostRec = session.post(hostaddurl, data=json.dumps(hostdata))
-------
hostdata = {'ipv4addrs':[{'ipv4addr': ipaddress]},'name': hostname,'ttl':'30'}
addHostRec = session.post(hostaddurl, data=json.dumps(hostdata))

 

Re: Using Python requests module to create host records

Adviser
Posts: 51
18436     0

Hi,

 

The issue may be that you are providing the TTL value as a string. An integer is expected there.

 

The below sample worked for me.

 

 

 

Sample script:

 

 

#!/usr/bin/python

import requests, json, sys
from requests.auth import HTTPBasicAuth
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

hostname = sys.argv[1]
ip = sys.argv[2]
labgridip = '10.192.33.12'
labgriduser = 'admin'
labgridpassword = 'infoblox'

def createhost(n, i ):
  data = json.dumps({"ipv4addrs":[{"ipv4addr": i}],"name": hostname,"view": "default", "ttl": 30})
  response = requests.post("https://"+labgridip+"/wapi/v2.6/record:host", data, auth=(labgriduser, labgridpassword), verify=False)
  print response.text
createhost(hostname, ip)

Showing results for 
Search instead for 
Do you mean 

Recommended for You