11-10-2016 01:01 PM
I am trying to automate the creation of network device interface names in DNS. I want the interfaces on our network in DNS but it would be pretty much impossible to manage that by hand, which is why we haven't done it yet.
After thinking about it, I've come up with the following general workflow to be executed once a month:
- Get a list of all network IP addresses in our system, from a central source. Since we don't have a real asset management software application yet, I'll just use the Statseeker API to export the list from there
- Use the Junos PyEZ stuff to take that list, log into each device, and get a mapping of interfaces to IP addresses. This step is already complete, as I finished writing the script today.
- Empty the network.domain.com zone we've created for network devices. This is to ensure we start with a clean slate every time we import and any devices which may have been removed over the last 30 days.
- Take the output from that script (which is an infoblox formatted CSV file) and import it into infoblox. I found the script here https://community.infoblox.com/t5/API-Integration/The-definitive-list-of-REST-examples/m-p/1233#M21 which worked beautifully
I still have to do #1 and #3. #1 is irrelevant to this forum and should be a simple API call to our monitoring software. #3 on the other hand is also probably very simple. I just need to clear all A and PTR records from a specific zone. Should be pretty straightforward but I'm just not finding the correct API call to make to do this.
Does anyone have any suggestions, can point me in the right direction, or even have a code snippet that may work here?
Solved! Go to Solution.
11-10-2016 02:46 PM
11-10-2016 03:16 PM
I haven't looked at that, but I don't think we're likely to be looking to buy any new software.
I actually now have #1 done in my list as well. The only part I'm still missing at this point is how to empty A and PTR records from a zone. I'm not sure if the best way is to use the API to run through and grab every record and then iterate through that list with a delete api call, or if there's a way to just say "kill everything in this zone". That's really what I'm looking for.
11-11-2016 10:32 AM
There's no "delete all records" API call. I think your two options are to GET the allrecords object then iterate through and delete the objects or to delete the zone itself then recreate it and it will be empty.
11-15-2016 01:26 PM
I went with the former, doing a search on all objects that match some criteria and then deleting them all.
I actually have a full working script now. Of course this is bound to change and get better over time but for now, check out https://github.com/ipv6freely/junos-dns-scrape/blob/master/junos-dns-scrape.py
Thanks for the help!