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 & Integration, DevOps,NetOps,SecOps

Reply

WAPI call pull all network and some extattrs?

[ Edited ]
Authority
Posts: 12
3540     1

I have been trying to do this myself but after beating myself up I'm "phoning a friend"

 

GOAL:

Utilize a curl call to pull all networks and include just some extensible attributes (UN-LOCODE, SubnetName, VLANdescrip)

 

What do I have so far?

I can pull all networks using this command:

curl --tlsv1 --insecure --user 'admin:infoblox' 'https://ddi.domain.corp/wapi/v2.5/network?_max_results=5000'
What I can't do is put that into a CSV file so I am cheating with just showing networks by running an ugly command like this
curl --tlsv1 --insecure --user 'admin:infoblox' 'https://ddi.domain.corp/wapi/v2.5/network?_max_results=5000' 2>&1 | grep '"network":' > output.txt
 
ISSUE: doesn't include the extensible attributes but I can grab all extensible attributes by using this command
curl --tlsv1 --insecure --user 'admin:infoblox' 'https://ddi.domain.corp/wapi/v2.11/network?_max_results=50005&_return_fields=network,extattrs'
This pulls ALL extensible attributes and not just UN-LOCODE, SubnetName, VLANdescrip and the output is ugly.
 
Was hoping someone has done this and could help me understand how to do this call to include just
  • network
  • extattrs: UN-LOCODE
  • extattrs: SubnetName
  • extattrs: VLANdescrip
 
EXTRA CREDIT:
Anyone output all information for all networks into a php or html file in table format that someone could download into CSV.  Our customers always want a list of the most up to date networks in our environment and to have the ability to put this up on a webpage and make it searchable, downloadable/export to CSV, sortable would be exactly what the doctor/customer ordered.  I would make the command run via cron and always have it available to anyone who has the link.

Re: WAPI call pull all network and some extattrs?

Moderator
Moderator
Posts: 289
3540     1

You will always get all the extensible attributes when you ask for them.  You would need to filter them client-side side if you don't want to use them all.

Re: WAPI call pull all network and some extattrs?

Superuser
Posts: 20
3541     1

You can use the fileop object to do a CSV export or all network objects, it is a 3-step process that works like this:

 

Step 1: Export Objects in CSV format

Call the csv_export function on the special fileop object, and export all objects of the type "network".

 

POST /wapi/v2.10/fileop
 Content-Type: application/json

{
"_function":"csv_export",
"_object":"network"
}

 

You will get back a hash/dictionary that gives you a token and a url, that looks like this:

{
    "token": "eJydkMFOwzAMhu9+k......",
    "url": "https://192.168.1.2/...."
}

Make sure you extract these two and store them into variables to be used later. For this example, let's say I created $TOKEN and $URL to store these values.

 

 

Step 2: Download the CSV File

 

You can use any tool you want, wget or a web browser, if using curl, it could be like this ($URL is set to the value from the previous result):

 

curl -s -k -u admin:infoblox ' -H 'Content-Type:application/force-download' \
  -O "$URL"

 

Step 3: Remove Temporary File

Signal to the Grid Master that you are done with the file by cleaning it out from the storage. This is good practice, so you don't leave garbage behind. If you forget or was uanble to remove, it is not the end of the world, as NIOS will do its own file clean-up when it is running low on space and delete these files eventually.

 

POST /wapi/v2.10/fileop
 Content-Type: application/json

{
    "_function":"downloadcomplete",
    "token":"'$TOKEN'"
}
Showing results for 
Search instead for 
Did you mean: 

Recommended for You