我想使用Infoblox API更改Infoblox设备中nsgroup的辅助DNS服务器。原始nsgroup包含两个辅助DNS服务器,我想放置一个DNS辅助服务器(当然有一个主服务器)。
以下代码更改了nsgroup的注释,但不会更改NS Group的辅助服务器!我总是有两个辅助DNS服务器。代码不会触发任何错误。
sub nsGroupSlave {
# https://ipam.illinois.edu/api/doc/Infoblox/Grid/DNS/Nsgroup.html
my @retrieved_obj = $session->get(
object => "Infoblox::Grid::DNS::Nsgroup",
name => "Interne");
my $nsg1 = $retrieved_obj[0];
unless ($nsg1){
msg(t() . "ERROR : " . Infoblox::status_code() . ":" . Infoblox::status_detail(),$v);
} else {
msg(t() . "OK",$v);
}
my @retrieved_objsp = $session->get(
object => "Infoblox::Grid::Member",
name => "ns1.intra.example.com"
);
my $nsp = $retrieved_objsp[0];
my @retrieved_objssi = $session->get(
object => "Infoblox::Grid::Member",
name => "nsZ.intra.example.com"
);
my $nssi = $retrieved_objssi[0];
my @result_array = $session->get(
"object" => "Infoblox::Grid::DNS" ,
"grid" => "infoblox"
);
my $object = $result_array[0];
$nsg1->primary($nsp);
$nsg1->secondaries([$nssi]);
$nsg1->comment("Modify by restore-backup");
my $response1 = $session->modify($nsg1);
unless ($response1) {
msg(t() . "FAIL : ", $session->status_code() . ":" . $session->status_detail(),$v);
}
$object->nsgroups( [ $nsg1 ] );
my $response3 = $session->modify($object);
unless ($response3) {
msg(t() . "FAIL : ", $session->status_code() . ":" . $session->status_detail(),$v);
}
$session->restart();
}
答案 0 :(得分:2)
Infoblox API的乐趣啊。这是其中一个细微差别。您不能使用现有的成员对象来创建新成员对象。但是您可以使用已检索的辅助对象中的值...
my $newMember = Infoblox::DNS::Member->new(
name => $nssi->name(),
ipv4addr => $nssi->ipv4addr(),
);
$nsg1->primary($nsp);
$nsg1->secondaries([$newMember]);
$nsg1->comment("Modify by restore-backup");
希望这有帮助。