- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
WAPI call pull all network and some extattrs?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 09:52 AM - edited 09-11-2020 09:55 AM
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'
curl --tlsv1 --insecure --user 'admin:infoblox' 'https://ddi.domain.corp/wapi/v2.5/network?_max_results=5000' 2>&1 | grep '"network":' > output.txt
curl --tlsv1 --insecure --user 'admin:infoblox' 'https://ddi.domain.corp/wapi/v2.11/network?_max_results=50005&_return_fields=network,extattrs'
- network
- extattrs: UN-LOCODE
- extattrs: SubnetName
- extattrs: VLANdescrip
Re: WAPI call pull all network and some extattrs?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 05:06 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2020 08:23 AM
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'" }