web/modules/rhn/RHN/Action.pm | 8
web/modules/rhn/RHN/DB/CryptoKey.pm | 9
web/modules/rhn/RHN/DB/Entitlements.pm | 14 -
web/modules/rhn/RHN/DB/ServerGroup.pm | 200 --------------------
web/modules/rhn/RHN/DB/Set.pm | 41 ----
web/modules/rhn/RHN/Daemon.pm | 322 ---------------------------------
web/modules/rhn/RHN/Org.pm | 8
web/modules/rhn/RHN/SystemSnapshot.pm | 8
web/spacewalk-web.spec | 1
9 files changed, 611 deletions(-)
New commits:
commit c39564c0f673ad78e5143522df71db2ff26c8ad5
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 18:02:06 2010 +0100
RHN::Daemon not use'd anywhere, removing.
diff --git a/web/modules/rhn/RHN/Daemon.pm b/web/modules/rhn/RHN/Daemon.pm
deleted file mode 100644
index e9fcb85..0000000
--- a/web/modules/rhn/RHN/Daemon.pm
+++ /dev/null
@@ -1,322 +0,0 @@
-#
-# Copyright (c) 2008 Red Hat, Inc.
-#
-# This software is licensed to you under the GNU General Public License,
-# version 2 (GPLv2). There is NO WARRANTY for this software, express or
-# implied, including the implied warranties of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
-# along with this software; if not, see
-#
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
-#
-# Red Hat trademarks are not licensed under GPLv2. No permission is
-# granted to use or replicate Red Hat trademarks that are incorporated
-# in this software or its documentation.
-#
-
-use strict;
-
-package RHN::Daemon;
-
-use PXT::Config;
-
-use Params::Validate;
-Params::Validate::validation_options(strip_leading => "-");
-
-use Proc::Daemon;
-use Unix::Syslog qw/:subs :macros/;
-use POSIX ":sys_wait_h", 'strftime';
-
-use constant TRACE => 3;
-use constant DEBUG => 2;
-use constant INFO => 1;
-use constant SILENT => 0;
-
-sub new {
- my $class = shift;
- my $name = shift;
-
- my $self = bless {}, $class;
- $self->{name} = $name if $name;
- $self->{loglevel} = LOG_LOCAL7;
-
- return $self;
-}
-
-sub become_daemon {
- my $self = shift;
-
- $self->die("can't call become_daemon unless no children and not a
child") if $self->{children} or $self->{parent};
- Proc::Daemon::Init();
-
- umask 077;
-
- my %facilities =
- (
- local0 => LOG_LOCAL0,
- local1 => LOG_LOCAL1,
- local2 => LOG_LOCAL2,
- local3 => LOG_LOCAL3,
- local4 => LOG_LOCAL4,
- local5 => LOG_LOCAL5,
- local6 => LOG_LOCAL6,
- local7 => LOG_LOCAL7,
- );
-
- my $facility = PXT::Config->get('daemon_logging_facility');
- die "Invalid daemon logging facility '$facility'"
- unless exists $facilities{$facility};
-
- openlog $0, LOG_ODELAY|LOG_PID, $facilities{$facility};
- $self->{logging} = 1;
-}
-
-sub info {
- my $self = shift;
- my $msg = shift;
-
- $self->log_message(-level => INFO, -msg => $msg);
-}
-
-sub debug {
- my $self = shift;
- my $msg = shift;
-
- $self->log_message(-level => DEBUG, -msg => $msg);
-}
-
-sub trace {
- my $self = shift;
- my $msg = shift;
-
- $self->log_message(-level => TRACE, -msg => $msg);
-}
-
-sub log_message {
- my $self = shift;
- my %params = validate(@_, { -level => 1, -msg => 1 });
-
- return if $self->current_log_level < $params{level};
-
- if ($self->{logging}) {
- syslog(LOG_INFO, $params{msg});
- }
- else {
- warn sprintf "[ %s ] %s\n", strftime("%Y-%m-%d %H:%M:%S",
localtime time), $params{msg};
- }
-}
-
-sub current_log_level {
- my $level = PXT::Config->get('daemon_debug_level');
-
- die "Invalid log level: $level" if $level < SILENT or $level > TRACE;
-
- return $level;
-}
-
-sub die {
- my $self = shift;
- my $msg = shift;
-
- $self->info($msg) if $self->{logging};
- die $msg;
-}
-
-sub write_pidfile {
- my $self = shift;
- my $file = shift;
-
- $self->die("pidfile called but no name or file") unless $file or
$self->{name};
- $file ||= "/var/run/" . $self->{name} . ".pid";
-
- open PID, ">$file"
- or $self->die("Can't write pidfile $file: $!");
- print PID "$$\n";
- close PID;
-}
-
-sub new_child {
- my $self = shift;
- my $coderef = shift;
-
- $self->die("$coderef not a CODEREF") if $coderef and ref($coderef) ne
'CODE';
-
- $self->die("process is already a child") if $self->{parent};
-
- my $parent = $$;
- my $pid = fork();
- $self->die("bad fork? $!") unless defined $pid;
-
- if ($pid) {
- my $child = RHN::Daemon::Child->new($pid);
- push @{$self->{children}}, $child;
-
- return $child;
- }
- else {
- $self->{parent} = $parent;
-
- # coderef passed? if so, call it, then exit.
- if ($coderef) {
- eval {
- $coderef->($self);
- };
- $self->info($@) if $@;
-
- exit 0;
- }
-
- return;
- }
-}
-
-sub parent_alive {
- my $self = shift;
-
- return (getppid() == $self->{parent}) ? 1 : 0;
-}
-
-sub find_child {
- my $self = shift;
- my $pid = shift;
-
- my ($child) = grep { $_->pid == $pid } @{$self->{children}};
- $self->die("no child with pid $pid?") unless $child;
-
- return $child;
-}
-
-sub remove_child {
- my $self = shift;
- my $pid = shift;
-
- my @new_children;
- my $ret;
-
- foreach my $child (@{$self->{children}}) {
- if ($child->pid == $pid) {
- $ret = $child;
- }
- else {
- push @new_children, $child;
- }
- }
-
- $self->{children} = \@new_children;
- return $ret;
-}
-
-sub wait_for_children {
- my $self = shift;
- my $nohang = shift;
-
- my $pid = waitpid(-1, $nohang ? WNOHANG : 0);
-
- # if error was no processes, ignore it, otherwise die
- if ($nohang and $pid == 0) {
- return;
- }
- if ($pid < 0) {
- if (0 + $! != 10) {
- $self->die("waitpid: $!");
- }
- return;
- }
-
- my $child = $self->remove_child($pid);
- $child->exit_status($?);
-
- return $child;
-}
-
-sub signal_children {
- my $self = shift;
- my $sig = shift;
-
- foreach my $child (@{$self->{children}}) {
- kill $sig, $child->pid;
- }
-}
-
-sub reap_children {
- my $self = shift;
-
- my @ret;
- while (my $child = $self->wait_for_children(1)) {
- push @ret, $child;
- }
-
- return @ret;
-}
-
-sub kill_children {
- my $self = shift;
-
- return unless $self->{children} and @{$self->{children}};
-
- my @ret;
- my $tries = 0;
-
- while($tries < 3 and @{$self->{children}}) {
- $self->signal_children("TERM");
- sleep 1;
-
- push @ret, $self->reap_children;
-
- $tries++;
- }
-
- if (not @{$self->{children}}) {
- return @ret;
- }
-
- warn "Children still left after $tries tries. Killing harder.";
-
- $self->signal_children("KILL");
- sleep 1;
-
- push @ret, $self->reap_children;
-
- return @ret;
-}
-
-package RHN::Daemon::Child;
-use POSIX ":sys_wait_h";
-
-sub new {
- my $class = shift;
- my $pid = shift;
- die "no pid" unless $pid;
-
- my $self = bless { pid => $pid }, $class;
-
- return $self;
-}
-
-sub pid {
- return shift->{pid};
-}
-
-sub running {
- my $self = shift;
-
- my $result = waitpid($self->pid, WNOHANG);
-
- if ($result == 0) {
- return 1;
- }
- else {
- $self->exit_status($?);
- return 0;
- }
-}
-
-sub exit_status {
- my $self = shift;
- my $exit_status = shift;
-
- $self->{exit_status} = $exit_status if defined $exit_status;
-
- return $self->{exit_status};
-}
-
-1;
diff --git a/web/spacewalk-web.spec b/web/spacewalk-web.spec
index fd0aae5..72db751 100644
--- a/web/spacewalk-web.spec
+++ b/web/spacewalk-web.spec
@@ -158,7 +158,6 @@ rm -rf $RPM_BUILD_ROOT
%{perl_vendorlib}/RHN/CryptoKey.pm
%{perl_vendorlib}/RHN/CustomInfoKey.pm
%{perl_vendorlib}/RHN/DB/
-%{perl_vendorlib}/RHN/Daemon.pm
%{perl_vendorlib}/RHN/DataSource.pm
%{perl_vendorlib}/RHN/DataSource/
%{perl_vendorlib}/RHN/Date.pm
commit 7dfac9a027785449ccd0b1b726f679aecf5aa3ae
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 18:01:08 2010 +0100
lookup_org is not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/Org.pm b/web/modules/rhn/RHN/Org.pm
index c4a5dd5..2a2e29c 100644
--- a/web/modules/rhn/RHN/Org.pm
+++ b/web/modules/rhn/RHN/Org.pm
@@ -36,12 +36,4 @@ sub lookup {
}
}
-sub lookup_org {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ',
caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
1;
commit cac906bbb922860ac8b104d59171104766f80e01
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 18:00:49 2010 +0100
lookup_action is not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/Action.pm b/web/modules/rhn/RHN/Action.pm
index 0e257c1..43af538 100644
--- a/web/modules/rhn/RHN/Action.pm
+++ b/web/modules/rhn/RHN/Action.pm
@@ -36,12 +36,4 @@ sub lookup {
}
}
-sub lookup_action {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ',
caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
1;
commit 19d42341aa3e2cea20108f7d639589118c036080
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:58:01 2010 +0100
lookup_snapshot is not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/SystemSnapshot.pm
b/web/modules/rhn/RHN/SystemSnapshot.pm
index 5049c1b..5043bc3 100644
--- a/web/modules/rhn/RHN/SystemSnapshot.pm
+++ b/web/modules/rhn/RHN/SystemSnapshot.pm
@@ -36,12 +36,4 @@ sub lookup {
}
}
-sub lookup_snapshot {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ',
caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
1;
commit 9dc1e2c55debbfea83427cc6d00fd4a5a553bd80
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:57:45 2010 +0100
lookup_group_type_id is not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/DB/Entitlements.pm
b/web/modules/rhn/RHN/DB/Entitlements.pm
index efd653a..ef5dccf 100644
--- a/web/modules/rhn/RHN/DB/Entitlements.pm
+++ b/web/modules/rhn/RHN/DB/Entitlements.pm
@@ -50,20 +50,6 @@ sub is_valid_entitlement {
}
-sub lookup_group_type_id {
- my $class = shift;
- my $entitlement = shift;
-
- my @all = $class->valid_system_entitlements();
- my ($match) = grep { $_->{LABEL} eq $entitlement } @all;
-
- unless ($match) {
- throw "(no_group_type) No server group type '$entitlement' found";
- }
-
- return $match->{ID};
-}
-
sub entitlement_feature_map {
my $class = shift;
commit d4e5d2ae21736123b6f5e7ac892f8c39c04a9245
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:57:31 2010 +0100
org_key_list is not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/DB/CryptoKey.pm b/web/modules/rhn/RHN/DB/CryptoKey.pm
index f928929..7f1d55d 100644
--- a/web/modules/rhn/RHN/DB/CryptoKey.pm
+++ b/web/modules/rhn/RHN/DB/CryptoKey.pm
@@ -161,15 +161,6 @@ EOQ
$self->crypto_key_type_id($row->{ID});
}
-sub org_key_list {
- my $class = shift;
- my $org_id = shift;
-
- my $ds = new RHN::DataSource::Simple(-querybase => "General_queries");
- $ds->mode("crypto_keys_for_org");
- return $ds->execute_query(-org_id => $org_id);
-}
-
sub key_type_list {
my $class = shift;
commit e2a9ed0e9bb12dc0f92fc430792340bb3f534495
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:56:51 2010 +0100
retrieve is not called from Perl stack, removing.
diff --git a/web/modules/rhn/RHN/DB/ServerGroup.pm
b/web/modules/rhn/RHN/DB/ServerGroup.pm
index 94f97f2..db6fe27 100644
--- a/web/modules/rhn/RHN/DB/ServerGroup.pm
+++ b/web/modules/rhn/RHN/DB/ServerGroup.pm
@@ -239,28 +239,6 @@ EOQ
$dbh->commit();
}
-=head1 retrieve
-
-arguments - $group_id (scalar) - the group_id to be retrieved
-returns - list
-
-=cut
-
-sub retrieve {
- my $class = shift;
- my $group_id = shift;
-
- my $dbh = RHN::DB->connect;
-
- my $query ='SELECT ' . join(', ', @server_group) . ' FROM ' .
$t->table_name . ' where id = ?';
- my $sth = $dbh->prepare($query);
- $sth->execute($group_id);
- my @data = $sth->fetchrow();
- $sth->finish;
-
- return @data;
-}
-
sub server_group_list {
my $self = shift;
my $org_id = shift;
commit 14b1a86313bcc6bc4a5b20f1f8e2cfe3c1cc4c64
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:54:35 2010 +0100
Removing bunch of unused methods from RHN::DB::ServerGroup:
servers_in_groups
groups_in_org_overview
group_overview
tri_state_server_group_list
diff --git a/web/modules/rhn/RHN/DB/ServerGroup.pm
b/web/modules/rhn/RHN/DB/ServerGroup.pm
index 199e8d8..94f97f2 100644
--- a/web/modules/rhn/RHN/DB/ServerGroup.pm
+++ b/web/modules/rhn/RHN/DB/ServerGroup.pm
@@ -261,184 +261,6 @@ sub retrieve {
return @data;
}
-=head1 list
-
-arguments - $group_id
-returns - list of serverId's in group
-
-=cut
-
-sub servers_in_groups {
- my $class = shift;
- my $groups = shift;
- my $bounds = shift;
- my @columns = @_;
-
- if (not ref $bounds or ref $bounds ne 'ARRAY') {
- unshift @columns, $bounds;
- $bounds = [ 1, 1_000_000 ];
- }
-
- $groups = [ $groups ] unless ref $groups;
- @columns = ('S.ID') unless @columns;
-
- my $dbh = RHN::DB->connect;
-
- my $query = sprintf <<EOQ, join(", ", @columns), join(", ",
("?") x @$groups);
-SELECT %s
-FROM rhnServerGroupMembers SGM, rhnServer S, rhnServerArch SA
-WHERE SGM.server_group_id IN (%s) AND
- SGM.server_id = S.id AND
- S.server_arch_id = SA.id
-EOQ
-
- my $sth = $dbh->prepare($query);
- $sth->execute(@$groups);
-
- my @result;
-
- my $i = 1;
- while ( my (@data) = $sth->fetchrow ) {
- if ( $i >= $bounds->[0] and $i <= $bounds->[1]) {
- push ( @result, \@data );
- } else {
- last;
- }
- $i++
- }
-
- $sth->finish;
-
- return @result;
-}
-
-sub groups_in_org_overview {
- my $class = shift;
- my %params = @_;
-
- my ($org_id, $user_id, $lower, $upper, $total_ref, $mode, $mode_params, $all_ids) =
- map { $params{"-" . $_} } qw/org_id user_id lower upper total_rows mode
mode_params all_ids/;
-
- my $dbh = RHN::DB->connect;
- my $query;
-
- if ($mode eq 'server') {
- $query = <<EOS;
-SELECT SECURITY_ERRATA, BUG_ERRATA, ENHANCEMENT_ERRATA, GO.GROUP_ID, GROUP_NAME,
GROUP_ADMINS, SERVER_COUNT, NOTE_COUNT, GO.MODIFIED, GO.MAX_MEMBERS
- FROM rhnVisServerGroupOverview GO, rhnServerGroupMembers SGM
- WHERE GO.ORG_ID = ?
- AND SGM.server_group_id = GO.group_id
- AND SGM.server_id = ?
- AND EXISTS (SELECT 1 FROM rhnUserServerGroupPerms WHERE server_group_id =
GO.group_id AND user_id = ?)
-ORDER BY UPPER(GROUP_NAME), GO.GROUP_ID
-EOS
- }
- elsif ($mode eq 'user') {
- $query = <<EOS;
-SELECT SECURITY_ERRATA, BUG_ERRATA, ENHANCEMENT_ERRATA, GO.GROUP_ID, GROUP_NAME,
GROUP_ADMINS, SERVER_COUNT, NOTE_COUNT, GO.MODIFIED, GO.MAX_MEMBERS
- FROM rhnVisServerGroupOverview GO, rhnUserManagedServerGroups UMSG
- WHERE GO.ORG_ID = ?
- AND GO.GROUP_ID = UMSG.server_group_id
- AND UMSG.user_id = ?
-ORDER BY UPPER(GROUP_NAME), GO.GROUP_ID
-EOS
- }
- elsif ($mode eq 'set') {
- $query = <<EOS;
-SELECT SECURITY_ERRATA, BUG_ERRATA, ENHANCEMENT_ERRATA, GROUP_ID, GROUP_NAME,
GROUP_ADMINS, SERVER_COUNT, NOTE_COUNT, MODIFIED, MAX_MEMBERS
- FROM rhnVisServerGroupOverview, rhnSet RS
- WHERE ORG_ID = ? AND GROUP_ID = RS.element AND RS.label = ? AND RS.user_id = ?
-ORDER BY UPPER(GROUP_NAME), GROUP_ID
-EOS
- }
- else {
- $query = <<EOS;
-SELECT SECURITY_ERRATA, BUG_ERRATA, ENHANCEMENT_ERRATA, GROUP_ID, GROUP_NAME,
GROUP_ADMINS, SERVER_COUNT, NOTE_COUNT, MODIFIED, MAX_MEMBERS
- FROM rhnVisServerGroupOverview
- WHERE ORG_ID = ?
-ORDER BY UPPER(GROUP_NAME), GROUP_ID
-EOS
- }
-
- my $sth = $dbh->prepare($query);
- $sth->execute($org_id, @{ref $mode_params ? $mode_params : [ $mode_params ]});
-
- my @result;
- my $i = 1;
- $$total_ref = 0;
-
- while (my @data = $sth->fetchrow) {
- push @$all_ids, $data[3] if $all_ids;
- $$total_ref = $i;
- if ($i >= $lower and $i <= $upper) {
- push @result, [ @data ];
- }
- $i++;
- }
- $sth->finish;
- return @result;
-}
-
-# return is:
-# [ server_id, server_name, numadmins, numgroups_server_is_in, updated ]
-sub group_overview {
- my $class = shift;
- my $group_id = shift;
- my ($lower, $upper) = @_;
- $lower ||= 1;
- $upper ||= 100000;
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOQ;
-SELECT SERVER_ID, SERVER_NAME, 0, GROUP_COUNT, MODIFIED
-FROM rhnServerOverview
-WHERE SERVER_GROUP_ID = ?
-ORDER BY UPPER(S.NAME), S.ID
-EOQ
-
- my $sth = $dbh->prepare($query);
-
- $sth->execute($group_id);
-
- my @result;
- my $i = 1;
- while (my @data = $sth->fetchrow) {
- if ($i >= $lower and $i <= $upper) {
- push @result, [ @data, 0 ];
- } else {
- last;
- }
- $i++;
- }
- $sth->finish;
- return @result;
-}
-
-sub tri_state_server_group_list {
- my $self = shift;
- my $org_id = shift;
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOS;
-SELECT SGO.group_id, SGO.group_name
- FROM rhnServerGroup SG, rhnServerGroupOverview SGO
- WHERE SGO.org_id = ?
- AND SGO.group_id = SG.id
- AND SG.group_type IS NULL
-ORDER BY UPPER (SGO.group_name)
-EOS
-
- my $sth = $dbh->prepare($query);
- $sth->execute($org_id);
-
- my @ret;
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
sub server_group_list {
my $self = shift;
my $org_id = shift;
commit 89cda6992163d78aa614f92449c928b571e99f8a
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:53:06 2010 +0100
immediate_add and immediate_remove not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/DB/Set.pm b/web/modules/rhn/RHN/DB/Set.pm
index 801e751..cebf2f0 100644
--- a/web/modules/rhn/RHN/DB/Set.pm
+++ b/web/modules/rhn/RHN/DB/Set.pm
@@ -99,47 +99,6 @@ sub add {
@{$self->{contents}}{@vals} = (1) x @vals;
}
-sub immediate_add {
- my $self = shift;
- my @vals = @_;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare("INSERT INTO rhnSet (user_id, label, element,
element_two) VALUES (?, ?, ?, ?)");
-
- for my $val (@vals) {
- if (ref $val) {
- $sth->execute($self->uid, $self->label, $val->[0], $val->[1])
- unless exists $self->{contents}->{join("|", @$val)};
- }
- else {
- $sth->execute($self->uid, $self->label, $val, undef)
- unless exists $self->{contents}->{$val};
- }
- }
-
- $self->add(@vals);
-}
-
-sub immediate_remove {
- my $self = shift;
- my @vals = @_;
-
- my $dbh = RHN::DB->connect;
-
- for my $val (@vals) {
- if (ref $val) {
- my $sth = $dbh->prepare("DELETE FROM rhnSet WHERE user_id = ? AND label = ?
AND element = ? AND element_two = ?");
- $sth->execute($self->uid, $self->label, $val->[0], $val->[1]);
- }
- else {
- my $sth = $dbh->prepare("DELETE FROM rhnSet WHERE user_id = ? AND label = ?
AND element = ?");
- $sth->execute($self->uid, $self->label, $val);
- }
- }
-
- $self->remove(@vals);
-}
-
sub remove {
my $self = shift;
my @vals = @_;