group_hosts_by: Add support for wantipv4, wantipv6

This commit is contained in:
Richard Hansen 2024-05-28 02:54:26 -04:00
parent ce0a362fd0
commit 343fcff625

View file

@ -3421,9 +3421,8 @@ sub get_ipv6 {
## group_hosts_by ## group_hosts_by
###################################################################### ######################################################################
sub group_hosts_by { sub group_hosts_by {
##TODO - Update for wantipv4 and wantipv6
my ($hosts, $attributes) = @_; my ($hosts, $attributes) = @_;
my %attrs = (map({ ($_ => 1) } @$attributes), 'wantip' => 1); my %attrs = map({ ($_ => 1) } @$attributes);
my @attrs = sort(keys(%attrs)); my @attrs = sort(keys(%attrs));
my %groups = (); my %groups = ();
for my $h (@$hosts) { for my $h (@$hosts) {
@ -3980,7 +3979,7 @@ sub nic_dyndns2_update {
debug("\nnic_dyndns2_update -------------------"); debug("\nnic_dyndns2_update -------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(login password server static custom wildcard mx backupmx) ]); my %groups = group_hosts_by(\@_, [qw(login password server static custom wildcard mx backupmx wantip)]);
my %errors = ( my %errors = (
'badauth' => 'Bad authorization (username or password)', 'badauth' => 'Bad authorization (username or password)',
@ -4275,7 +4274,7 @@ sub nic_noip_update {
debug("\nnic_noip_update -------------------"); debug("\nnic_noip_update -------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(login password server static custom wildcard mx backupmx) ]); my %groups = group_hosts_by(\@_, [qw(login password server static custom wildcard mx backupmx wantip)]);
my %errors = ( my %errors = (
'badauth' => 'Invalid username or password', 'badauth' => 'Invalid username or password',
@ -4622,7 +4621,7 @@ sub nic_zoneedit1_update {
debug("\nnic_zoneedit1_update -------------------"); debug("\nnic_zoneedit1_update -------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(login password server zone) ]); my %groups = group_hosts_by(\@_, [qw(login password server zone wantip)]);
## update each set of hosts that had similar configurations ## update each set of hosts that had similar configurations
for my $sig (keys %groups) { for my $sig (keys %groups) {
@ -5709,7 +5708,7 @@ sub nic_godaddy_update {
debug("\nnic_godaddy_update --------------------"); debug("\nnic_godaddy_update --------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(server login password zone) ]); my %groups = group_hosts_by(\@_, [qw(server login password zone wantip)]);
## update each set of hosts that had similar configurations ## update each set of hosts that had similar configurations
for my $sig (keys %groups) { for my $sig (keys %groups) {
@ -5846,7 +5845,7 @@ sub nic_googledomains_update {
debug("\nnic_googledomains_update -------------------"); debug("\nnic_googledomains_update -------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(server login password) ]); my %groups = group_hosts_by(\@_, [qw(server login password wantip)]);
## update each set of hosts that had similar configurations ## update each set of hosts that had similar configurations
for my $sig (keys %groups) { for my $sig (keys %groups) {
@ -6026,7 +6025,7 @@ sub nic_nsupdate_update {
debug("\nnic_nsupdate_update -------------------"); debug("\nnic_nsupdate_update -------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(login password server zone) ]); my %groups = group_hosts_by(\@_, [qw(login password server zone wantip)]);
## update each set of hosts that had similar configurations ## update each set of hosts that had similar configurations
for my $sig (keys %groups) { for my $sig (keys %groups) {
@ -6143,7 +6142,7 @@ sub nic_cloudflare_update {
debug("\nnic_cloudflare_update -------------------"); debug("\nnic_cloudflare_update -------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(ssh login password server wildcard mx backupmx zone) ]); my %groups = group_hosts_by(\@_, [qw(ssh login password server wildcard mx backupmx zone wantip)]);
## update each set of hosts that had similar configurations ## update each set of hosts that had similar configurations
for my $sig (keys %groups) { for my $sig (keys %groups) {
@ -6291,7 +6290,7 @@ sub nic_hetzner_update {
debug("\nnic_hetzner_update -------------------"); debug("\nnic_hetzner_update -------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(ssh login password server wildcard mx backupmx zone) ]); my %groups = group_hosts_by(\@_, [qw(ssh login password server wildcard mx backupmx zone wantip)]);
## update each set of hosts that had similar configurations ## update each set of hosts that had similar configurations
for my $sig (keys %groups) { for my $sig (keys %groups) {
@ -6448,7 +6447,7 @@ sub nic_yandex_update {
debug("\nnic_yandex_update -------------------"); debug("\nnic_yandex_update -------------------");
## group hosts with identical attributes together ## group hosts with identical attributes together
my %groups = group_hosts_by([ @_ ], [ qw(server login pasword) ]); my %groups = group_hosts_by(\@_, [qw(server login pasword wantip)]);
## update each set of hosts that had similar configurations ## update each set of hosts that had similar configurations
for my $sig (keys %groups) { for my $sig (keys %groups) {
@ -7339,7 +7338,7 @@ EoEXAMPLE
} }
sub nic_cloudns_update { sub nic_cloudns_update {
my %groups = group_hosts_by([ @_ ], [ qw(dynurl) ]); my %groups = group_hosts_by(\@_, [qw(dynurl wantip)]);
for my $hr (values(%groups)) { for my $hr (values(%groups)) {
my @hosts = @$hr; my @hosts = @$hr;
my $hosts = join(',', @hosts); my $hosts = join(',', @hosts);