spacewalk/setup/lib/Spacewalk/Setup.pm | 53 ++++++-----------
spacewalk/setup/share/upgrade/rhn-update-monitoring.pl | 10 ++-
2 files changed, 29 insertions(+), 34 deletions(-)
New commits:
commit b1bf70d3c2d1912827956c745674b58c7e0402af
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Tue Sep 14 16:47:34 2010 +0200
use standard perl dbi in update_monitoring_scout
We cannot call RHN::DB->connect at this point of the setup, since
the db connection information is not set in master rhn.conf yet.
diff --git a/spacewalk/setup/lib/Spacewalk/Setup.pm
b/spacewalk/setup/lib/Spacewalk/Setup.pm
index ad40452..408b5d6 100644
--- a/spacewalk/setup/lib/Spacewalk/Setup.pm
+++ b/spacewalk/setup/lib/Spacewalk/Setup.pm
@@ -20,9 +20,7 @@ use Fcntl qw(F_GETFD F_SETFD FD_CLOEXEC);
use Params::Validate qw(validate);
Params::Validate::validation_options(strip_leading => "-");
-use RHN::SatInstall;
use RHN::Utils;
-use RHN::DataSource::Simple;
=head1 NAME
@@ -1541,62 +1539,51 @@ sub update_monitoring_scout {
return unless ($opts->{'upgrade'});
- my $org_id = RHN::SatInstall->get_satellite_org_id();
- my $ds = new RHN::DataSource::Simple(-querybase => "scout_queries",
- -mode => 'scouts_for_org');
- my $data = $ds->execute_query(-org_id => $org_id);
- my ($scout) = grep { not $_->{SERVER_ID} } @{$data};
-
- return 0 unless $scout;
-
- my ($ip, $vip) = ($scout->{IP}, $scout->{VIP});
- my ($sn_id, $sc_id) = ($scout->{SAT_NODE_ID}, $scout->{ID});
my $ip_addr = RHN::Utils::find_ip_address($answers->{'hostname'});
- my $dbh = RHN::DB->connect;
+ my $dbh = get_dbh($answers);
# If IP address for satellite / spacewalk scout was set to 127.0.0.1, it needs to be
updated
- my $sql1 = q{
+ my $sql1 = qq/
update rhn_sat_node
- set ip = :ip,
+ set ip = '$ip_addr',
last_update_user = 'upgrade',
last_update_date = sysdate
where ip = '127.0.0.1' and
- recid = :recid
- };
- my $sql2 = q{
+ recid = 2/;
+
+ my $sql2 = qq/
update rhn_sat_cluster
- set vip = :vip,
+ set vip = '$ip_addr',
last_update_user = 'upgrade',
last_update_date = sysdate
where vip = '127.0.0.1' and
- recid = :recid
- };
+ recid = 1/;
# If IP address for satellite / spacewalk scout was not set, it needs to be updated
- my $sql3 = q{
+ my $sql3 = qq/
update rhn_sat_node
- set ip = :ip,
+ set ip = '$ip_addr',
last_update_user = 'upgrade',
last_update_date = sysdate
where ip is null and
- recid = :recid
- };
- my $sql4 = q{
+ recid = 2/;
+
+ my $sql4 = qq/
update rhn_sat_cluster
- set vip = :vip,
+ set vip = '$ip_addr',
last_update_user = 'upgrade',
last_update_date = sysdate
where vip is null and
- recid = :recid
- };
+ recid = 1/;
- $dbh->do_h($sql1, ip => $ip_addr, recid => $sn_id, );
- $dbh->do_h($sql2, vip => $ip_addr, recid => $sc_id,);
- $dbh->do_h($sql3, ip => $ip_addr, recid => $sn_id, );
- $dbh->do_h($sql4, vip => $ip_addr, recid => $sc_id,);
+ $dbh->do($sql1);
+ $dbh->do($sql2);
+ $dbh->do($sql3);
+ $dbh->do($sql4);
$dbh->commit;
+ $dbh->disconnect;
}
sub update_monitoring_ack_enqueuer {
diff --git a/spacewalk/setup/share/upgrade/rhn-update-monitoring.pl
b/spacewalk/setup/share/upgrade/rhn-update-monitoring.pl
index 662bf2a..ed24fb5 100755
--- a/spacewalk/setup/share/upgrade/rhn-update-monitoring.pl
+++ b/spacewalk/setup/share/upgrade/rhn-update-monitoring.pl
@@ -10,8 +10,9 @@ use strict;
use warnings;
use Sys::Hostname;
-use RHN::SatInstall;
+use PXT::Config;
use Spacewalk::Setup;
+use RHN::SatInstall;
my $db_connect = RHN::SatInstall->test_db_connection();
die "Could not connect to the database" unless $db_connect;
@@ -20,6 +21,13 @@ my %answers;
my %opts;
$answers{'hostname'} = Sys::Hostname::hostname;
+$answers{'db-backend'} = PXT::Config->get('db_backend');
+$answers{'db-host'} = PXT::Config->get('db_host');
+$answers{'db-port'} = PXT::Config->get('db_port');
+$answers{'db-name'} = PXT::Config->get('db_name');
+$answers{'db-user'} = PXT::Config->get('db_user');
+$answers{'db-password'} = PXT::Config->get('db_password');
+
$opts{'upgrade'} = 1;
Spacewalk::Setup::update_monitoring_scout(\%opts, \%answers);
Show replies by date