MT#9579 ngcp-sync-constants: fix check for master host

Previously we were using the IP not the hostname

Change-Id: I48e2bb57da5ac32879d11ca51dd675db2b817ba6
changes/89/389/3
Victor Seva 11 years ago
parent fe8b4ad8fd
commit 10ea8aba69

2
debian/control vendored

@ -14,6 +14,7 @@ Build-Depends: asciidoc,
liblist-moreutils-perl,
libnet-netmask-perl,
libregexp-ipv6-perl,
libsocket-perl,
libsys-hostname-long-perl,
libtemplate-perl,
libyaml-perl,
@ -36,6 +37,7 @@ Depends: etckeeper,
liblist-moreutils-perl,
libnet-netmask-perl,
libregexp-ipv6-perl,
libsocket-perl,
libsys-hostname-long-perl,
libtemplate-perl,
libyaml-perl,

@ -8,6 +8,9 @@ use YAML::Tiny;
use Getopt::Long;
use Sys::Hostname;
use Data::Dumper;
use Socket;
use List::MoreUtils qw(any);
use Data::Validate::IP qw(is_ipv4 is_ipv6);
use IPC::System::Simple qw(system capturex);
#----------------------------------------------------------------------
use constant CONSTANTS_YML => "/etc/ngcp-config/constants.yml";
@ -209,6 +212,12 @@ sub sync_repuser {
my $minfo = "/var/lib/mysql$dbid/master.info";
my $mhost = $args{mhost};
my $mport = $args{mport} || 3306;
my $mhost_ip = $args{mhost};
unless ( is_ipv4($mhost) or is_ipv6($mhost) ) {
$mhost_ip = inet_ntoa(scalar(gethostbyname($mhost)));
print " --> $mhost => $mhost_ip\n" if $debug;
}
print " --> syncing replication user '$user' for master host '$mhost'\n" if $debug;
if(-f $minfo) {
@ -220,12 +229,12 @@ sub sync_repuser {
}
my @minfo_content = <$mfh>;
close $mfh;
unless(grep {/^${mhost}\s*$/}@minfo_content) {
print STDERR "${mhost} not found at $minfo. Fix replication manually";
unless(any {/^(${mhost}|${mhost_ip})\s*$/} @minfo_content) {
print STDERR "${mhost} or ${mhost_ip} were not found at $minfo. Fix replication manually";
$error = 2;
return;
}
unless(grep {/^${pass}\s*$/} @minfo_content) {
unless(any {/^${pass}\s*$/} @minfo_content) {
set_master_pass(
dbh => $dbh,
user => $user, pass => $pass

Loading…
Cancel
Save