Infoblox::Grid::CSVImportStatus - CSV import status object
This object is used to represent the status of the current CSV import task. All methods are read-only.
The following functions can be applied to a Grid::CSVImportStatus object.
Use this method to retrieve matching objects from the Infoblox appliance. See Infoblox::Session->get() for parameters and return values.
Apply the following attributes to get a specific CSV import status object
object - Required. It must be set to "Infoblox::Grid::CSVImportStatus". import_id - Optional. ID of the import task that the status object is describing. If not specified, the status of the first import task is returned.
my $import_id = $session->import_data( type => 'csv', path => "/tmp/zone.csv", separator => 'semicolon', );
unless($import_id){ die("Import failed: ", Infoblox::status_code(). ":" .Infoblox::status_detail()); }
my @retrieved_objs = $session->get( object => "Infoblox::Grid::CSVImportStatus", import_id => $import_id, );
This section describes all the methods that you can use to retrieve the status of a CSV import operation.
Use this method to retrieve the name of the administrator that started the import.
The method returns the attribute value.
#Get admin my $admin = $service_status->admin();
Use this method to retrieve the time the CSV import ended.
The method returns the attribute value.
#Get end_time my $end_time = $service_status->end_time();
Use this method to retrieve the name of the file used for the CSV import.
The method returns the attribute value.
#Get file_name my $file_name = $service_status->file_name();
Use this method to retrieve the ID of the import task that the status object is describing.
The method returns the attribute value.
#Get import_id my $import_id = $service_status->import_id();
Use this method to retrieve the number of lines that had failures in the CSV file used for the current CSV import.
The method returns the attribute value.
#Get lines_failed my $lines_failed = $service_status->lines_failed();
Use this method to retrieve the number of lines processed in the CSV file used for the current CSV import.
The method returns the attribute value.
#Get lines_processed my $lines_processed = $service_status->lines_processed();
Use this method to retrieve the total number of lines read from the CSV file during the current CSV import.
The method returns the attribute value.
#Get lines_total my $lines_total = $service_status->lines_total();
Use this method to retrieve the number of lines that had warnings in the CSV file used for the current CSV import.
The method returns the attribute value.
#Get lines_warning my $lines_warning = $service_status->lines_warning();
Use this method to retrieve the time the CSV import started.
The method returns the attribute value.
#Get start_time my $start_time = $service_status->start_time();
Use this method to retrieve the status of the current CSV import. The returned status is one of the following: 'Uploaded', 'Pending', 'Running', 'Failed', 'Stopped' or 'Completed'.
The method returns the attribute value.
#Get status my $status = $service_status->status();
The following sample code demonstrates how to export / import data by using CSV files.
#PROGRAM STARTS: Include all the modules that will be used use strict; use Infoblox;
#Create a session to the Infoblox appliance my $host_ip = "192.168.1.2"; my $session = Infoblox::Session->new( master => $host_ip, username => "admin", password => "infoblox" ); unless($session){ die("Constructor for session failed: ", Infoblox::status_code(). ":" . Infoblox::status_detail()); } print "Session created successfully.\n";
#Create a DNS zone my $memberns1 = Infoblox::DNS::Member->new( name => "infoblox.localdomain", ipv4addr => $host_ip, lead => "false", stealth => "false" );
#Add the zone my $firstzone = Infoblox::DNS::Zone->new( name => "test.com", email => "admin\@infoblox.com", comment => "add a zone test.com", primary => $memberns1, );
unless($firstzone){ die("Construct test.com zone object failed: ", Infoblox::status_code(). ":" .Infoblox::status_detail()); } print "test.com zone object created successfully.\n";
$session->add($firstzone) or die("Add zone for test.com failed: ", $session->status_code(). ":" .$session->status_detail());
print"Zone test.com added successfully.\n";
#Export the newly created zone $session->export_data( type => 'csv', path => '/tmp/zone.csv', object_type => 'Infoblox::DNS::Zone', separator => 'semicolon',
# search parameters name => '.*test.com', ) or die("Export zone for test.com failed: ", $session->status_code(). ":" .$session->status_detail());
# Wait for the export to complete sleep(5);
print "The zone was exported\n";
# Remove the zone from the database $session->remove($firstzone) or die("Remove zone for test.com failed: ", $session->status_code(). ":" .$session->status_detail());
print "The zone was removed\n";
# Import the zone by using the CSV file that was exported
my $import_id = $session->import_data( type => 'csv', path => "/tmp/zone.csv", separator => 'semicolon', );
unless($import_id){ die("Import failed: ", Infoblox::status_code(). ":" .Infoblox::status_detail()); }
# Wait for the import to complete sleep(5);
my $status = $session->get( object => 'Infoblox::Grid::CSVImportStatus', );
unless($status){ die("Failed to fetch the import status: ", Infoblox::status_code(). ":" .Infoblox::status_detail()); }
print "The zone was re-imported\n";
# The code should be cycling to sleep, fetch and wait until the import is finished. unless($status->status() eq 'Completed'){ die("The import took too long to complete: " . $status->status()); }
unless($status->lines_failed() == 0){ die("There were some import failures: " . $status->lines_failed()); }
print "The zone re-import was successful\n";
# The zone was re-imported. If we import the file again without merging, # an error occurs.
$import_id = $session->import_data( type => 'csv', path => "/tmp/zone.csv", separator => 'semicolon', );
unless($import_id){ die("Import failed: ", Infoblox::status_code(). ":" .Infoblox::status_detail()); }
# Wait for the import to complete sleep(5);
print "The zone re-re-import was completed\n";
my $status = $session->get( object => 'Infoblox::Grid::CSVImportStatus', );
unless($status){ die("Failed to fetch the import status: ", Infoblox::status_code(). ":" .Infoblox::status_detail()); }
# The code should be cycling to sleep, fetch and wait until the import is finished. unless($status->status() eq 'Completed'){ die("The import took too long to complete: " . $status->status()); }
if($status->lines_failed() == 0){ die("There were no import failures: " . $status->lines_failed()); }
print "The zone re-re-import correctly failed\n";
# Review the failure $session->export_data( type => 'csv_error_log', path => '/tmp/error_log.txt', import_id => $import_id, ) or die("Export error log failed: ", $session->status_code(). ":" .$session->status_detail());
# The failure is in this file print "Error log for the failed import\n-------\n"; print `cat /tmp/error_log.txt`;
#Remove the zone $session->remove( object => "Infoblox::DNS::Zone", name => "test.com", ) or die("Remove zone test.com failed: ", $session->status_code(). ":" .$session->status_detail());
print "The zone was removed\n";
####PROGRAM ENDS####
Infoblox Inc. http://www.infoblox.com/
Infoblox::Session,Infoblox::Session->get()
Copyright (c) 2017 Infoblox Inc.