From 636289268e9a94fdb94e33e098f8f59878718ce0 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Thu, 27 Nov 2014 08:56:49 +0100 Subject: [PATCH] MT#9285 [CARRIER] ngcp-sync-constants: add --force-grants option. - removes node users before copying grants - while at it, update password on already created user when copying grants Change-Id: Ic15a7c27772a071d42e4e4d4bddd4204453b5be9 --- sbin/ngcp-sync-constants | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sbin/ngcp-sync-constants b/sbin/ngcp-sync-constants index ff732164..d1b311d8 100755 --- a/sbin/ngcp-sync-constants +++ b/sbin/ngcp-sync-constants @@ -70,6 +70,7 @@ Options: -init-passwords|-i -- generate new passwords (constants.yml is updated) -slave|-s -- sync repuser and replication on slave cluster instance -no-grant-nodes -- skip copy grants for external nodes + -force-grants -- force grants (remove and create user if exists) -test|-t -- test mode (no updates) -verbose|-v -- verbose mode USAGE @@ -87,6 +88,7 @@ my $init_passwords = 0; my $debug = 0; my $test_mode = 0; my $error = 0; +my $force_grants = 0; GetOptions("h|?|help" => \&Usage, "i|init-passwords" => \$init_passwords, @@ -94,6 +96,7 @@ GetOptions("h|?|help" => \&Usage, "s|slave" => \$slave, "no-grant-nodes" => \$skip_grant_nodes, "t|test" => \$test_mode, + "force-grants" => \$force_grants, "v|verbose" => \$debug); #---------------------------------------------------------------------- sub pwgen { @@ -355,7 +358,8 @@ SQL $sth_cr->execute($host, $user, $host_orig) unless $test_mode; } else { - print "--> user ${user} already created\n" if $debug; + print "--> user ${user} already created. Set password again\n" if $debug; + $dbh->do("SET PASSWORD FOR '${user}'\@'${host}' = PASSWORD('${pass}');") unless $test_mode; } } $sth_sel->finish; @@ -606,7 +610,7 @@ sub do_grant_nodes grant_user(dbh => $dbh, user => $mysql_user, hosts => \@hosts, repuser => 0 ); sync_user( dbh => $dbh, user => $mysql_user, pass => $mysql_pass ); # all mysql users except repuser - copy_grants(dbh => $dbh, hosts => \@hosts); + copy_grants(dbh => $dbh, hosts => \@hosts, force => $force_grants); }; if ($@) { $dbh->rollback; @@ -724,6 +728,9 @@ Sync repuser and check replication of the read-only dbcluster instance (mysqld2) =item B<--no-grant-nodes> Skip creation of grants for external nodes. This is useful on installation phase at sp2 +=item B<--force-grants> +Remove and recreate users for slave hosts + =item B<--test> No real updates, only for checks