Reply
Highlighted

Extract Host data through WAPI

jsnukis
Techie
Posts: 5
8149     0

If this is covered elsewhere, my apologies. Is there a way to pull the host data for everything in the system through the WAPI? I've already used it to pull the network info with extensible attributes. I've just been tasked with figuring out what is up with the current installation on a new assignment and it looks as if some major cleanup will be needed. I'll have to pull the host data with IP and, hopefully, be able to dump it into csv format. Thanks in advance.

Re: Extract Host data through WAPI

jsnukis
Techie
Posts: 5
8150     0

OK, I've figured out the syntax to extract the host and cname records - I'll be comparing them. Is there any way to dump them into a csv format? And what is the limit for the total number of records extracted? I have it currently set to 10000 but I want to make sure I'm pulling everything.

Re: Extract Host data through WAPI

Adviser
Posts: 95
8150     0

If you need CSV, you could use the CSV Export feature

 

Data Management -> Toolbar -> CSV Job Manager -> CSV Export -> New

 

Select the object types you want to export. It gives you all elements in the db for the respective type.

 

 

 

With WAPI if you want all fields, you need to add them to the list of _return_fields:

 

curl -k -u admin:infoblox -X GET https://192.168.0.111/wapi/v1.6/record:host?_return_fields=extattrs,comment [etc.]

Re: Extract Host data through WAPI

Adviser
Posts: 131
8150     0

Which language are you writing your API scripts in? If you are writing in Python there is a "csv" module you can import into your script that can be used to write a CSV file row by row. If you are writing in PowerShell there is an Export-Csv cmdlet that will take PowerShell objects and write them out as a CSV file. I have example code for both cases.

 

Or are you writing in another language, like Perl or something else?

Re: Extract Host data through WAPI

[ Edited ]
PeteyHall
Techie
Posts: 5
8150     0

I have the same question as the original poster, trying to dump hostnames/IP's out into a CSV but I'm using Python. I"m completely new to this API so if there's anyone out there that has the base code of how to get into the WAPI and dump the IP/hostnames into a CSV I would GREATLY appreciate it.


Thanks

Re: Extract Host data through WAPI

Adviser
Posts: 95
8150     0

Again, simpelest would be to use the CSV export:

 

But here is how you use the Infoblox WAPI with Python:

 

#RestfulClient.py

import warnings
warnings.filterwarnings("ignore")

import requests
from requests.auth import HTTPDigestAuth
import json


url = "https://192.168.0.12/wapi/v2.5/record:host?_return_fields=name"

# It is a good practice not to hardcode the credentials. So ask the user to enter credentials at runtime
                
myResponse = requests.get(url, verify=False, auth=('admin', 'infoblox'))
#print (myResponse.status_code)

# For successful API call, response code will be 200 (OK)
if(myResponse.ok):
    
    jData = json.loads(myResponse.content)
    
    print("Found {0} elements".format(len(jData)))
    print("")
    
    for item in jData:
        for key in item:
            print key + " : " + item[key]
        print ''
else:
    myResponse.raise_for_status()

Re: Extract Host data through WAPI

[ Edited ]
PeteyHall
Techie
Posts: 5
8150     0

Thanks for that, but when I try to execute it, after customizing it for my environment, I get a 400 Client Error: Bad Request for url:https://myhost/wapi/v2.5/record:host?_return_fields=name.

 

I've confirmed with other python scripts that 2.5 works fine for me, is it the '?' after host?

 

Any thoughts?

 

Sorry, and the reason I need it to run through the API is that I have a cron job that takes the hostnames/IP's and matches them up in another system and this needs to be automated.

 

Re: Extract Host data through WAPI

Adviser
Posts: 95
8150     0

The ? is the separator for the parameters.

 

Try to open

 

   https://myhost/wapi/v2.5/record:host?_return_fields=name

 

in your Browser and the run the script again.

 

 

Re: Extract Host data through WAPI

PeteyHall
Techie
Posts: 5
8150     0

This is what I get:

The webpage cannot be found
 

Re: Extract Host data through WAPI

Adviser
Posts: 95
8150     0

Replace myhost with the IP of the Grid Master.

Re: Extract Host data through WAPI

PeteyHall
Techie
Posts: 5
8150     0

Sorry for not explaining better, I did.  I got prompted to authenticate through the grid, did that, then got the error.

Re: Extract Host data through WAPI

Adviser
Posts: 95
8150     0

Please post the output of this (Browser)

 

https://192.168.0.12/wapi/v2.5/?_schema&_return_type=json

 

 

Re: Extract Host data through WAPI

PeteyHall
Techie
Posts: 5
8150     0

Thanks for all of your help:

{"requested_version": "2.5", "supported_objects": ["ad_auth_service", "admingroup", "adminrole", "adminuser", "allendpoints", "allnsgroup", "allrecords", "allrpzrecords", "awsrte53taskgroup", "awsuser", "bfdtemplate", "bulkhost", "bulkhostnametemplate", "cacertificate", "capacityreport", "captiveportal", "certificate:authservice", "ciscoise:endpoint", "csvimporttask", "db_objects", "dbsnapshot", "ddnsSmiley Tonguerincipalcluster", "ddnsSmiley Tonguerincipalcluster:group", "deleted_objects", "dhcp:statistics", "dhcpfailover", "dhcpoptiondefinition", "dhcpoptionspace", "discovery", "discovery:device", "discovery:devicecomponent", "discovery:deviceinterface", "discovery:deviceneighbor", "discovery:gridproperties", "discovery:memberproperties", "discovery:status", "discovery:vrf", "discoverytask", "dtc", "dtc:allrecords", "dtc:certificate", "dtc:lbdn", "dtc:monitor", "dtc:monitor:http", "dtc:monitor:icmp", "dtc:monitorSmiley Tonguedp", "dtc:monitor:sip", "dtc:monitor:snmp", "dtc:monitor:tcp", "dtcSmiley Surprisedbject", "dtcSmiley Tongueool", "dtc:record:a", "dtc:record:aaaa", "dtc:record:cname", "dtc:record:naptr", "dtc:server", "dtc:topology", "dtc:topology:label", "dtc:topology:rule", "extensibleattributedef", "fileop", "filterfingerprint", "filtermac", "filternac", "filteroption", "filterrelayagent", "fingerprint", "fixedaddress", "fixedaddresstemplate", "grid", "grid:cloudapi", "grid:cloudapi:cloudstatistics", "grid:cloudapi:tenant", "grid:cloudapi:vm", "grid:cloudapi:vmaddress", "grid:dashboard", "grid:dhcpproperties", "grid:dns", "grid:license_pool", "grid:license_pool_container", "grid:maxminddbinfo", "grid:member:cloudapi", "grid:servicerestart:group", "grid:servicerestart:groupSmiley Surprisedrder", "grid:servicerestart:request", "grid:servicerestart:request:changedobject", "grid:servicerestart:status", "grid:threatprotection", "grid:x509certificate", "ipam:statistics", "ipv4address", "ipv6address", "ipv6fixedaddress", "ipv6network", "ipv6networkcontainer", "ipv6networktemplate", "ipv6range", "ipv6sharednetwork", "lease", "license:gridwide", "localuser:authservice", "macfilteraddress", "member", "member:dhcpproperties", "member:dns", "member:license", "member:threatprotection", "msserver", "msserver:adsites:domain", "msserver:adsites:site", "msserver:dhcp", "msserver:dns", "namedacl", "network", "network_discovery", "networkcontainer", "networktemplate", "networkuser", "networkview", "notification:rest:endpoint", "notification:rest:template", "notification:rule", "nsgroup", "nsgroup:delegation", "nsgroup:forwardingmember", "nsgroup:forwardstubserver", "nsgroup:stubmember", "orderedranges", "orderedresponsepolicyzones", "permission", "range", "rangetemplate", "record:a", "record:aaaa", "record:cname", "record:dhcid", "record:dtclbdn", "record:host", "record:host_ipv4addr", "record:host_ipv6addr", "record:mx", "record:naptr", "record:ns", "recordSmiley Tonguetr", "record:rpz:a", "record:rpz:a:ipaddress", "record:rpz:aaaa", "record:rpz:aaaa:ipaddress", "record:rpz:cname", "record:rpz:cname:clientipaddress", "record:rpz:cname:clientipaddressdn", "record:rpz:cname:ipaddress", "record:rpz:cname:ipaddressdn", "record:rpz:mx", "record:rpz:naptr", "record:rpzSmiley Tonguetr", "record:rpz:srv", "record:rpz:txt", "record:srv", "record:tlsa", "record:txt", "request", "restartservicestatus", "roaminghost", "ruleset", "scavengingtask", "scheduledtask", "search", "sharednetwork", "sharedrecord:a", "sharedrecord:aaaa", "sharedrecord:cname", "sharedrecord:mx", "sharedrecord:srv", "sharedrecord:txt", "sharedrecordgroup", "snmpuser", "taxii", "threatprotection:rule", "upgradestatus", "userprofile", "vdiscoverytask", "view", "zone_auth", "zone_auth_discrepancy", "zone_delegated", "zone_forward", "zone_rp", "zone_stub"], "supported_versions": ["1.0", "1.1", "1.2", "1.2.1", "1.3", "1.4", "1.4.1", "1.4.2", "1.5", "1.6", "1.6.1", "1.7", "1.7.1", "1.7.2", "1.7.3", "1.7.4", "1.7.5", "2.0", "2.1", "2.1.1", "2.1.2", "2.2", "2.2.1", "2.2.2", "2.3", "2.3.1", "2.4", "2.5"]}

Re: Extract Host data through WAPI

[ Edited ]
Adviser
Posts: 95
8150     0

Okay the problem is confusing. This shows that it does have 2.5 available and it is responding.

 

So now please try this again in your browser:

 

https://192.168.0.12/wapi/v2.5/record:host

 

That should give you something and should not return 'Page not found'

But in either case, I think you need to open a ticket with support.

 

Re: Extract Host data through WAPI

sadaf14
Techie
Posts: 5
8150     0

 Hi,I'm new to making API calls and gathering information using them.I used the code you have provided ,it seems to provide no error for me.However it is simply returning zero elements as the output.I'm not quite sure where I am going wrong.If you could assist me with the possible mistakes,it would be of great help.

Thanks in advance. 

Re: Extract Host data through WAPI

spenumaka Community Manager
Community Manager
Posts: 63
8150     0

Hi sadaf14,

Can you post a new topic as this topic is very old and it it is not clear what you are referring to?

 

Regards,

--------------------------------------
Check out our new Tech docs website for latest documentation on Infoblox products.

Re: Extract Host data through WAPI

priya
Techie
Posts: 1
8150     0

Iam using Vb.net, how can I extract/import all the details from our intranet website/interface to INFOBOX UI

Showing results for 
Search instead for 
Do you mean 

Recommended for You