Reply

How to export zone to file in CSV via an API

Authority
Posts: 23
10230     0

Alle  I am new in this forum, i have question how te export the zone to CSV file via the API. I need to export about 500 domains.to somene else which not allows zone transfers

Can some advise how to solve this or can share a script already made.

On forhand Thanks for your help

Chris Alberts

you really want to find a way

Community Manager
Community Manager
Posts: 248
10230     0

you really want to find a way to use zone transfers, it will be a lot faster and easier.

if you can't do that, then you can use the Perl api and CSV export, but it will be slow and will chew the CPU as the DB has to reformat the data into a the CSV file (with headers for each record type), use the 'Infoblox:Smiley Very HappyNS::AllRecords' type :

                $session->export_data(
                                      type        => "csv",
                                      path        => "/tmp/infoblox/exported_data.csv",
                                      object_type => "Infoblox:Smiley Very HappyNS::AllRecords",
                                      separator   => "comma",

                                      # search parameters
                                      zone        => "test_exportimport.com");

and just repeat that for each zone.

I've tried this in my code

Not applicable
Posts: 2
10230     0
I've tried this in my code and it did not generate any data. Here is what I am using for my code: Am I doing something wrong here? Obvious information changes asside (host/user/pass) #!/usr/bin/perl use strict; use Infoblox:Smiley Frustratedession; use Infoblox; use warnings; open (MYFILE, '<', 'domainlist.txt') or die "Unable to open file: $1"; my $session = Infoblox:Smiley Frustratedession->new( master => "", #appliance host ip username => "", #appliance user login password => "" #appliance password ); while () { chomp; print "$_\n"; $session->export_data( type => "csv", path => "/tmp/$_.csv", object_type => "Infoblox:Smiley Very HappyNS::AllRecords", separator => "comma", # search parameters zone => "$_", ); } close (MYFILE);

Hi,

Techie
Posts: 6
10230     0

Hi,

I've run your script and it works but from what I found, the export_data method does not seem to give all expected records, as it does not completly export all wanted data to the csv output. First run gave 350 records, second run 800 records, third run over 1000 records. Maybe it's a resource issue on the GM.

I tested also by exporting DHCP::Network and I see various results, between 0-400 networks in the csv and there's 3000 in the Grid.

I've opened up a ticket and the support says it works fine in the lab though.

Regards,

Fredrik

 

 

Every time I run it I get no

Not applicable
Posts: 2
10230     0

Every time I run it I get no CSV file created.  So the question is, how best to output the data...

If using a Win7-client, be

Techie
Posts: 6
10230     0

If using a Win7-client, be sure to use Perl 5.12. Version 5.16 does not work 100% with CSV-exports

This will create a exportfile per zone with all dns records, zones defined in file opened by the script.

Output will be in csv-importable format with headers.

open (MYFILE, '<', 'zonelist.txt')
 or die "Unable to open file: $1";
 
while (<MYFILE>) {
 chomp;
 print "$_\n";
 $session->export_data(
 type => "csv",
 path => "/output/export_dnsallrecords_$_.csv",
  object_type => "Infoblox:Smiley Very HappyNS::AllRecords",
 separator => "comma",
 # search parameters - define dns view if needed,
# views => "Internal",

# zone from infile
 zone => "$_",
 
 );
 }

close (MYFILE);

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You