MT#15261 Fix YML merging order for tt2-daemon

The default Hash::Merge->merge() behaviour is LEFT_PRECEDENT:
http://search.cpan.org/~rehsack/Hash-Merge-0.200/lib/Hash/Merge.pm

Which means:
> The values buried in the left hash will never be lost;
> any values that can be added from the right hash will be attempted.

So, the values from HOST_CONFIG never overwrites default NGCPCTL_CONFIG:
> NGCPCTL_CONFIG="${NGCPCTL_MAIN}/config.yml"
> HOST_CONFIG="${NGCPCTL_MAIN}/config.$(hostname).yml"

We need to use RIGHT_PRECEDENT order to be in sync with 'scripts/build':
> ${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES:-} ${CONSTANTS_CONFIG:-}

Change-Id: I597bb082a1791c1f06072d85c4a26fbb8b8320ce
changes/98/2698/1
Alexander Lutay 11 years ago
parent 986030b1f2
commit fe7644d241

@ -72,7 +72,8 @@ sub handle_connections {
next if(exists $loaded_ymls{$file});
$loaded_ymls{$file} = undef;
print $client "Loading $file in memory:" unless $quiet;
$config = merge($config, LoadFile($file) || die $ERRNO);
my $hm = Hash::Merge->new('RIGHT_PRECEDENT');
$config = $hm->merge( $config, LoadFile($file) || die $ERRNO);
print $client " OK \n" unless $quiet;
};
};

Loading…
Cancel
Save