Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API Examples

Reply

Need to save output of the infoblox-client API call to a csv file

New Member
Posts: 1
1770     0

I want to backup all the Extensible attributes for a Network ,NetworkContainer and host to a csv file.
May I know the way to do it with infoblox-client API

I am searching the objects using
"objects.Network.search()"
"objects.NetworkContainer.search()"

My code :
ib_network = objects.Network.search(connection, network='131.226.217.128/27', network_view='default', return_fields=['default', 'extattrs'])

ib_network_container = objects.NetworkContainer.search(connection, network='131.226.192.0/18', network_view='default', return_fields=['default', 'extattrs'])

I am storing the value into "ib_network" & "ib_network_container" variables

Re: Need to save output of the infoblox-client API call to a csv file

New Member
Posts: 4
1771     0

I don't know exactly the code you want to use, but one tool you might be interested in is 'jq'. I just started using it and it has an output that is in CSV (@csv). 

 

 

Re: Need to save output of the infoblox-client API call to a csv file

Superuser
Posts: 38
1771     0

Hi pkumar28

 

You can initiate a CSV export using "fileop" object. When you initiate a CSV Export, you will get a URL that can be used to download the file directly, and a token for the download session. After downloading the CSV file, remember to remove the stored file using the token.

 

Below are sample CURL commands for your reference

 

Initiate a CSV export:
curl -k -u admin:infoblox -H 'content-type: application/json' -X POST
"https://grid-master/wapi/v2.12/fileop?_function=csv_export"  --data-raw '{
    "_object": "network",
    "network": "131.226.217.128/27",
    "network_view": "default"
}'

Sample output:
{
    "token": "eJytjrkKwjAAhl9FMmuuHmm6VaogSAURHENpYg3apibxQnx3zaCri+v38R8PoG6DtnfhdadAPiJp\nSiLKo4hBzlKeJHw8Amd7fCuw935wOUIEQ8JTSHECCUWBCqmtarzY6aMS2iCrTkLLSbnaVstVUU5w\nRmPMKCWMsxhnGaqUvxp7cLBxF/BekLWvheobI3Xfhq3povryzshwDZTFphDr2fwjAkPOG1u3Cvlu\n+M8VLUPvrxh4vgC5A11J\n",
    "url": "https://grid-master/http_direct_file_io/req_id-DOWNLOAD-0824072217974088/Networks.csv"
}

Download the CSV file:
curl -k -u admin:infoblox -H 'content-type: application/force-download' "https://grid-master/http_direct_file_io/req_id-DOWNLOAD-0824072217974088/Networks.csv"

Remove the stored file using the token:
curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://grid-master/wapi/v2.9/fileop?_function=downloadcomplete" --data-raw '{"token" : "eJytjrkKwjAAhl9FMmuuHmm6VaogSAURHENpYg3apibxQnx3zaCri+v38R8PoG6DtnfhdadAPiJp\nSiLKo4hBzlKeJHw8Amd7fCuw935wOUIEQ8JTSHECCUWBCqmtarzY6aMS2iCrTkLLSbnaVstVUU5w\nRmPMKCWMsxhnGaqUvxp7cLBxF/BekLWvheobI3Xfhq3povryzshwDZTFphDr2fwjAkPOG1u3Cvlu\n+M8VLUPvrxh4vgC5A11J\n"}'

 

The network container object doesn't support CSV export but you can get all details for a network exported to CSV file.

 

Shukran

 

Shukran
Showing results for 
Search instead for 
Did you mean: 

Recommended for You