Skip to content

Commit

Permalink
load domain.conf for both clusters and single node
Browse files Browse the repository at this point in the history
  • Loading branch information
stgmsa committed Jul 11, 2024
1 parent 819481f commit 637cb96
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/pfconfig/namespaces/config/Domain.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This module creates the configuration hash associated to domain.conf

use strict;
use warnings;
use JSON;

use pfconfig::namespaces::config;
use Data::Dumper;
Expand All @@ -42,16 +43,28 @@ sub build_child {
# Inflate %h to the host machine name
# This is done since Samba 4+ doesn't inflate it itself anymore
while(my ($id, $cfg) = each(%tmp_cfg)){
if(lc($cfg->{server_name}) =~ /%h/) {
if(exists($cfg->{server_name}) && lc($cfg->{server_name}) =~ /%h/) {
my $name = [split(/\./,( $self->{host_id} // hostname() ) )]->[0];
$cfg->{server_name} =~ s/%h/$name/;
}
}

$self->{cfg} = \%tmp_cfg;

return \%tmp_cfg;
my $host_id;
my %filtered = ();

unless (defined($self->{host_id}) && $self->{host_id} ne "") {
$host_id = hostname();
} else {
$host_id = $self->{host_id};
}
foreach my $key (keys %tmp_cfg) {
if (index($key, $host_id) == 0 && $key =~/^\S+\s+(\S+)$/) {
$filtered{$1} = $tmp_cfg{$key};
}
}
return \%filtered;
}

=head1 AUTHOR
Expand Down

0 comments on commit 637cb96

Please sign in to comment.