October 28, 201510 yr Here is the start of a script (not completed) # set set up some defaults: my $REST_REV = "v2.1"; my $rest = Infoblox::REST->new({ # debug => 4, master => $SERVER, version => $REST_REV, username => $USER, password => $PASS }); if ( $rest->errors() ) { print Dumper ( $rest->errors() ) ; exit ; } # say "Getting ALL CNAMES\n"; # the name is always an FQDN my $data = $rest->GET( '/record:cname', { _max_results=>$MAXRESULTS , # '_return_fields+'=>'zone', } ) ; print "GET " . $rest->url() . "\n"; unless ( $data ) { print $rest->errorText() . "\n"; exit ; } # now walk each of these cnames and see if they point to somewhere we # know about foreach my $rec ( @{ $data } ) { my $name = $rec->{name}; my $canon = $rec->{canonical}; say "Check CNAME : $name -> $canon" if $DEBUG ; # see if there is a matching HOST my $hosts = $rest->GET( '/record:host', { name => $canon }) ; next if $hosts; # see if there is a matching A record my $arecs = $rest->GET( '/record:a', { name => $canon }) ; next if $arecs; print "TEST : " if $TEST ; say "DELETE CNAME : $name -> $canon no HOST or A records found" ; say "DELETE : $rec->{_ref}" if $DEBUG ; next if $TEST ; # set up some values we want to change to put into the body... # and don't forget the leading '/' before the key my $res = $rest->DELETE( "/$rec->{_ref}" ) ; print $rest->errorText() . "\n" unless $res; } exit ;
Create an account or sign in to comment