- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »
Re: RESTful API call to retrieve all records in a particular dns view/zone
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-19-2017 05:04 PM
I got it working thanks to you Clark. Thank You very much!!!
Re: RESTful API call to retrieve all records in a particular dns view/zone
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-19-2017 05:22 PM - edited 05-19-2017 05:23 PM
Make sure you post how you fixed it so others may benefit, myself included.
I will post all of my scripts on Monday. Maybe this weekend if I get ambitious.
Re: RESTful API call to retrieve all records in a particular dns view/zone
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-19-2017 05:33 PM
Here is your script with my tweaks to make it work for our environment. THANKS AGAIN CLARK. Obviously I could use help with a combine csv script. Was thinking of trying to do
cat domain1.com.csv <(tail +2 domain2.com.csv) > mastersheet.csv
Anyhow after I exported all the zone's by going to Data Management - DNS - Public DNS View and clicking export in Infoblox format. I then opened csv and really just copied all the zone files that are forwards (not the delegated stuff) I then opened my linux box and created a text file and just pasted all the zones and saved the file as zonelist.txt
Created another file called extract.sh and pasted the below. Edited the parameters for our environment found at the beginning of the file. Ran chmod 755 extract.sh which made it executable.
Ran ./extract.sh and it ran
#!/bin/bash -
# This script reads a file, zonelist.txt, that contains a
# list of zone files to download. A separate csv file will be
# created for each zone. The csv file will be named the
# same as the zone name. Minimal error checking is
# performed. Use at your own risk.
# All files are located in the same directory as this script.
# Username and password with permission to download csv files
USERNAME="admin"
PASSWORD="Infoblox"
# Grid Master
SERVER="gm.example.corp"
# Define file containing list of zones to export
ZONELIST="zonelist.txt"
# Define file that will contain results of curl command
OUTFILE="result.txt"
# Location of curl on this system. Use -s so curl is silent
CURL="/usr/bin/curl -s"
# WAPI version
VERSION="v2.3"
# What view are these zone in? default maybe
VIEW="Public"
############################################
# No more variables to set below this line #
############################################
# Process the zonelist file one line at a time
while read ZONE
do
echo
echo
echo
echo
echo
echo "Processing zone: $ZONE"
# Create CSV file for this zone
$CURL \
--tlsv1 \
--insecure \
--noproxy '*' \
-u "$USERNAME:$PASSWORD" \
-H "Content-Type: application/json" \
-X POST https://$SERVER/wapi/$VERSION/fileop?_function=csv_export \
-d "{\"_object\":\"allrecords\",\"view\":\"$VIEW\",\"zone\":\"$ZONE\"}" \
> $OUTFILE
ERROR_COUNT=`grep -c Error $OUTFILE`
if [ $ERROR_COUNT -gt 0 ]; then
# Display the error and skip rest of loop
grep Error $OUTFILE
continue
fi
# Get the "token" and "download URL" for later use
TOKEN=`grep "token" $OUTFILE | cut -d"\"" -f4`
URL=` grep "url" $OUTFILE | cut -d"\"" -f4`
echo "Token: $TOKEN"
echo "URL: $URL"
# Download the CSV file
echo "Download CSV file section"
$CURL \
--tlsv1 \
--insecure \
--noproxy '*' \
-u "$USERNAME:$PASSWORD" \
-H "Content-Type: application/force-download" \
-O $URL
# Rename CSV file so the file name matches the zone name
echo "rename CSV file section"
FILENAME="$ZONE.csv"
# Reverse zones will contain the / character which will be interpreted
# as a directory delimiter if included in file name. Replace with +
FILENAME=`echo $FILENAME | tr \/ +`
echo "Filename: $FILENAME"
mv Zonechilds.csv $FILENAME
# Let NIOS know download is complete
echo "Let NIOS know download is complete SECTION"
$CURL \
--tlsv1 \
--insecure \
--noproxy '*' \
-u "$USERNAME:$PASSWORD" \
-H "Content-Type: application/json" \
-X POST https://$SERVER/wapi/$VERSION/fileop?_function=downloadcomplete \
-d "{ \"token\": \"$TOKEN\"}"
done < "$ZONELIST"
exit
Now I'm just at the point where I have all these csv files and I know there must be a way to just combine all this good info into one csv so I can filter, search, etc.
Re: RESTful API call to retrieve all records in a particular dns view/zone
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-19-2017 05:37 PM
You shouldn't need to combine them to filter/search/parse the data. If there is some complex operation you want to perform and you don't know how to do it, give me an example (no company specific data) and I can prob write some bash one-liner to perform the function.
Re: RESTful API call to retrieve all records in a particular dns view/zone
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-30-2018 04:05 AM
HI,
I have problem with this consult.
I do not get the subzones of the domain solved any solution?
This is my consult:
CURL \
--tlsv1 \
--insecure \
-u "$USERNAME:$PASSWORD" \
-H "Content-Type: application/json" \
-X POST https://$SERVER/wapi/$VERSION/fileop?_function=csv_export \
-d "{\"_object\":\"allrecords\",\"type\":\"record:ALL\",\"view\":\"$VIEW\",\"zone\":\"$ZONE\"}" \
> $OUTFILE
Re: RESTful API call to retrieve all records in a particular dns view/zone
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-30-2018 04:11 AM
Hi,
I have a domain that has subzones and with this query I can not get this data. Could you give me a solution
Thanks
Re: RESTful API call to retrieve all records in a particular dns view/zone
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-30-2018 02:43 PM
You would have to export the records from the subzone as a separate search. Those records belong to the subzone, not the parent, and would not be exported with the parent zone.
Re: RESTful API call to retrieve all records in a particular dns view/zone
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-31-2018 03:43 AM
Good morning, and how can I implement this from the API?
- « Previous
-
- 1
- 2
- Next »