我正在设置一个 perl 脚本来与一些运行 NIOS 5.1 的 infoblox 设备进行通信,但我被困在代码的下面部分。这部分用于创建反向区域记录。
任何指针我可能做错了什么?
#!/usr/bin/perl
require Infoblox;
use Getopt::Std;
use Term::GetKey;
use JSON;
use Data::Dumper;
use VCIM qw ( load_config getline unpack_netmask pack_netmask validate_netmask validate_vlan get_first_ip get_last_ip get_next_ip dprint
write_config i18n hash_merge dqtobin bintodq binmax binmin ip_is_used );
my $DEBUG=1;
my $overwrite=0;
my $match;
my %options;
getopts('yp:', \%options);
if (defined $options{'y'}) {
$overwrite = 1;
}
# read settings from settings.conf
my %config;
%config = %{load_config()};
# acquire infoblox handle
dprint("\nConnecting to $infobloxip as $infobloxuser" . ($infobloxpass eq 'default' ? " using default password 'default'":"")."\n");
my $ibh = Infoblox::Session->new(
master => $infobloxip,
password => $infobloxpass,
username => $infobloxuser
);
my @searchres = $ibh->search(
"object" => "Infoblox::Grid::Member",
"name" => ".*"
);
unless (@searchres) {
if ( defined $config{'credentials'}{'infobloxPass'} ) {
dprint("Connection failed. (Status Code " . $ibh->status_code() . ": " . $ibh->status_detail() . ").\n");
dprint("Trying again. Will use config password instead.\n");
$infobloxpass = $config{'credentials'}{'infobloxPass'};
$ibh = Infoblox::Session->new(
master => $infobloxip,
password => $infobloxpass,
username => $infobloxuser);
@searchres = $ibh->search(
"object" => "Infoblox::Grid::Member",
"name" => ".*"
);
unless (@searchres) {
die ($ibh->status_code() . ':' . $ibh->status_detail());
}
} else {
die ($ibh->status_code() . ':' . $ibh->status_detail());
}
}
sub create_zones {
my $oct0 = shift;
my $oct1 = shift;
my $oct2 = shift;
my $netbits = shift;
$netbits = ($netbits>24?24:$netbits);
#one network for /8, /16, /24, or 2^x where x is each bit less than the classful boundary
$networks = ($netbits%8==0?1:(2**(8-($netbits%8))));
my $snb = ($netbits<24 && $netbits>16 ? \$oct2 : ($netbits > 8 ? \$oct1 : \$oct0));
for (my $i=0;$i<$networks;$i++) {
if ($i>0) {
${$snb}++;
}
dprint("Creating Reverse zone $oct2.$oct1.$oct0.in-addr.arpa... ");
my $newzone = Infoblox::DNS::Zone->new(
name => $oct2.".".$oct1.".".$oct0."."."0"."/".($netbits%8==0?$netbits:$netbits + (8 - ($netbits%8))),
enable_rfc2317_exclusion => "true",
disable => "false",
primary => $dns_member
);
unless (my $response = $ibh->add($newzone)) {
unless ($ibh->status_code() == 1005) {
die ($ibh->status_code() . ":" . $ibh->status_detail());
}
完整的错误代码是1002:One or more arguments in request are missing or incorrect at infobloxSetup.pl line 601, <RUC> line 657.