1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!c:/perl/bin/perl.exe
use strict;
use warnings;
use Infoblox;
#Create a session to the Infoblox Appliance
my $session = Infoblox::Session->new(
master => "xxxxxxx",
username => "xxxxx",
password => "xxxxxx"
);
unless ($session) {
die("Construct session failed: ",
Infoblox::status_code() . ":" . Infoblox::status_detail());
}
my $filename = 'c:/liste_ipam.txt';
open my($file), '<', $filename
or die "Couldn't open $filename : $!\n";
while (my $line = <$file>){
my ($hostname, $ip) = split /\s*,\s*/, $line;
$ip =~ s/\s+//g;
my $host = Infoblox::DNS::Host->new(
name => "$hostname",
ipv4addrs => [$ip],
configure_for_dns => "false",
);
unless ($host) {
die("Construct DNS host record failed: ",
Infoblox::status_code() . ":" . Infoblox::status_detail());
}
print "DNS host object created successfully\n";
#Add the DNS host record object to Infoblox appliance through a session
$session->add($host)
or die("Add host record failed: ",
$session->status_code() . ":" . $session->status_detail());
print "DNS host object added to server successfully\n";
}
close $file; |
Partager