Changes to 'refs/tags/spacewalk-java-1.7.14-1'
by Jan Pazdziora
Tag 'spacewalk-java-1.7.14-1' created by Jan Pazdziora <jpazdziora(a)redhat.com> at 2012-01-31 13:15 +0000
Tagging package [spacewalk-java] version [1.7.14-1] in directory [java/].
Changes since spacewalk-config-1.7.2-1:
Jan Pazdziora (1):
Automatic commit of package [spacewalk-java] release [1.7.14-1].
---
java/spacewalk-java.spec | 6 +++++-
rel-eng/packages/spacewalk-java | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
---
12 years, 2 months
java/spacewalk-java.spec rel-eng/packages
by Jan Pazdziora
java/spacewalk-java.spec | 6 +++++-
rel-eng/packages/spacewalk-java | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
New commits:
commit 585f287735c8b8e04d1d3d17a61da45c0488a20a
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 31 14:15:11 2012 +0100
Automatic commit of package [spacewalk-java] release [1.7.14-1].
diff --git a/java/spacewalk-java.spec b/java/spacewalk-java.spec
index f7c11cf..b4636a8 100644
--- a/java/spacewalk-java.spec
+++ b/java/spacewalk-java.spec
@@ -17,7 +17,7 @@ Name: spacewalk-java
Summary: Spacewalk Java site packages
Group: Applications/Internet
License: GPLv2
-Version: 1.7.13
+Version: 1.7.14
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -555,6 +555,10 @@ fi
%{jardir}/postgresql-jdbc.jar
%changelog
+* Tue Jan 31 2012 Jan Pazdziora 1.7.14-1
+- Removing the web.debug_disable_database option -- it is not supported beyond
+ RHN::DB anyway.
+
* Mon Jan 30 2012 Jan Pazdziora 1.7.13-1
- Casting the user id to string to make rhn_install_org_satellites happy.
diff --git a/rel-eng/packages/spacewalk-java b/rel-eng/packages/spacewalk-java
index 85871a4..92b5f86 100644
--- a/rel-eng/packages/spacewalk-java
+++ b/rel-eng/packages/spacewalk-java
@@ -1 +1 @@
-1.7.13-1 java/
+1.7.14-1 java/
12 years, 2 months
Changes to 'refs/tags/spacewalk-config-1.7.2-1'
by Jan Pazdziora
Tag 'spacewalk-config-1.7.2-1' created by Jan Pazdziora <jpazdziora(a)redhat.com> at 2012-01-31 13:14 +0000
Tagging package [spacewalk-config] version [1.7.2-1] in directory [spacewalk/config/].
Changes since spacewalk-java-1.7.13-1:
Jan Pazdziora (7):
Removing the web.debug_disable_database option -- it is not supported beyond RHN::DB anyway.
Monitoring uses RHN::DB, so no need to have the extra connect parameters.
Removing code which is long commented out.
Factor the connection parameters config read to RHN::DBI, start to use it in RHN::DB, also support just one database connection.
In monitoring, use RHN::DBI instead of RHN::DB because we do not want to reuse the connection.
The RHN::DB::connect does not accept any arguments anymore.
Automatic commit of package [spacewalk-config] release [1.7.2-1].
Miroslav Suchý (1):
code cleanup: users are not created in web any more
---
java/buildconf/builder/config/satellite/default/rhn_web.conf | 3
monitoring/NPalert/AlertDB.pm | 4
monitoring/NPalert/NotificationDB.pm | 4
monitoring/PerlModules/NP/OracleDB/DBRecord.pm | 4
monitoring/PerlModules/NP/OracleDB/OracleDB.pm | 4
monitoring/PerlModules/NP/OracleDB/perl-NOCpulse-OracleDB.spec | 2
monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm | 4
rel-eng/packages/spacewalk-config | 2
spacewalk/config/spacewalk-config.spec | 6
spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf | 2
spacewalk/setup/bin/spacewalk-setup | 12
web/conf/rhn_web.conf | 3
web/modules/pxt/PXT/ApacheHandler.pm | 11
web/modules/rhn/RHN/DB.pm | 139 +---------
web/modules/rhn/RHN/DB/DataSource.pm | 2
web/modules/rhn/RHN/DB/User.pm | 41 --
web/modules/rhn/RHN/DBI.pm | 76 +++++
web/spacewalk-web.spec | 1
18 files changed, 111 insertions(+), 209 deletions(-)
---
12 years, 2 months
rel-eng/packages spacewalk/config
by Jan Pazdziora
rel-eng/packages/spacewalk-config | 2 +-
spacewalk/config/spacewalk-config.spec | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
New commits:
commit 09f05c4ab7c36c3e8f74626b37db8726b7080812
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 31 14:14:40 2012 +0100
Automatic commit of package [spacewalk-config] release [1.7.2-1].
diff --git a/rel-eng/packages/spacewalk-config b/rel-eng/packages/spacewalk-config
index f3f0a3f..c3667f8 100644
--- a/rel-eng/packages/spacewalk-config
+++ b/rel-eng/packages/spacewalk-config
@@ -1 +1 @@
-1.7.1-1 spacewalk/config/
+1.7.2-1 spacewalk/config/
diff --git a/spacewalk/config/spacewalk-config.spec b/spacewalk/config/spacewalk-config.spec
index 0944f93..b3676bf 100644
--- a/spacewalk/config/spacewalk-config.spec
+++ b/spacewalk/config/spacewalk-config.spec
@@ -1,6 +1,6 @@
Name: spacewalk-config
Summary: Spacewalk Configuration
-Version: 1.7.1
+Version: 1.7.2
Release: 1%{?dist}
URL: http://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -105,6 +105,10 @@ chgrp apache /etc/rhn /etc/rhn/rhn.conf /etc/rhn/cluster.ini 2> /dev/null || :
chmod o-rwx /etc/rhn/rhn.conf* /etc/rhn/cluster.ini* /etc/sysconfig/rhn/backup-* /var/lib/rhn/rhn-satellite-prep/* 2> /dev/null || :
%changelog
+* Tue Jan 31 2012 Jan Pazdziora 1.7.2-1
+- Removing the web.debug_disable_database option -- it is not supported beyond
+ RHN::DB anyway.
+
* Mon Jan 23 2012 Tomas Lestach <tlestach(a)redhat.com> 1.7.1-1
- increase ProxyTimeout because of long lasting API calls (tlestach(a)redhat.com)
- Bumping package versions for 1.7. (mzazrivec(a)redhat.com)
12 years, 2 months
web/modules
by Miroslav Suchý
web/modules/rhn/RHN/DB/User.pm | 41 -----------------------------------------
1 file changed, 41 deletions(-)
New commits:
commit 7e234cd19988c1cd411f43b75ba42729e5882092
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Jan 31 14:09:53 2012 +0100
code cleanup: users are not created in web any more
sequence rhn_user_id_seq does not exist since satellite 5.2, thefore __newly_created__ could not been used for ages
diff --git a/web/modules/rhn/RHN/DB/User.pm b/web/modules/rhn/RHN/DB/User.pm
index 1dc804e..2c5692e 100644
--- a/web/modules/rhn/RHN/DB/User.pm
+++ b/web/modules/rhn/RHN/DB/User.pm
@@ -282,16 +282,6 @@ sub _blank_user {
return $self;
}
-sub create {
- my $class = shift;
-
- my $user = $class->_blank_user();
- $user->{__id__} = -1;
- $user->{__newly_created__} = 1;
-
- return $user;
-}
-
# build some accessors
foreach my $field ($j->method_names) {
my $sub = q {
@@ -526,22 +516,6 @@ sub commit {
my @columns_to_use;
my $mode = 'update';
- if ($self->{__newly_created__}) {
- croak "$self->commit called on newly created object when id != -1\nid == $self->{__id__}" unless $self->{__id__} == -1;
- $sth = $dbh->prepare("SELECT rhn_user_id_seq.nextval FROM DUAL");
- $sth->execute;
- my ($id) = $sth->fetchrow;
- die "No new user id from seq rhn_user_id_seq (possible error: " . $sth->errstr . ")" unless $id;
- $sth->finish;
- $self->{":modified:"}->{id} = 1;
- $self->{__id__} = $id;
- $self->{":modified:"}->{web_user_id} = 1;
- $self->{__web_user_id__} = $id;
- $self->{":modified:"}->{contact_web_user_id} = 1;
- $self->{__contact_web_user_id__} = $id;
-
- $mode = 'insert';
- }
die "$self->commit called on user without valid id" unless $self->id;
my @modified = keys %{$self->{":modified:"}};
@@ -619,21 +593,6 @@ sub RHN::DB::UserSite::commit {
my $sth;
my $mode = 'update';
- if ($self->{__newly_created__}) {
- croak "$self->commit called on newly created object when id != -1\nid == $self->{__site_id__}" unless $self->{__site_id__} == -1;
- $sth = $dbh->prepare("SELECT web_user_site_info_id_seq.nextval FROM DUAL");
- $sth->execute;
- my ($id) = $sth->fetchrow;
- #warn "fetched id == ".$id;
- die "No new usersite id from seq web_user_site_id_seq (possible error: " . $sth->errstr . ")" unless $id;
- $sth->finish;
- $self->{":modified:"}->{site_id} = 1;
- $self->{__site_id__} = $id;
-
- $mode = 'insert';
- }
- #RHN::DB->objectify_error("$self->commit called on user_site without valid id") unless $self->site_id;
-
my @modified = keys %{$self->{":modified:"}};
my %modified = map { $_ => 1 } @modified;
12 years, 2 months
6 commits - java/buildconf monitoring/nocpulse-common monitoring/NPalert monitoring/PerlModules spacewalk/config spacewalk/setup web/conf web/modules web/spacewalk-web.spec
by Jan Pazdziora
java/buildconf/builder/config/satellite/default/rhn_web.conf | 3
monitoring/NPalert/AlertDB.pm | 4
monitoring/NPalert/NotificationDB.pm | 4
monitoring/PerlModules/NP/OracleDB/DBRecord.pm | 4
monitoring/PerlModules/NP/OracleDB/OracleDB.pm | 4
monitoring/PerlModules/NP/OracleDB/perl-NOCpulse-OracleDB.spec | 2
monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm | 4
spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf | 2
spacewalk/setup/bin/spacewalk-setup | 12
web/conf/rhn_web.conf | 3
web/modules/pxt/PXT/ApacheHandler.pm | 11
web/modules/rhn/RHN/DB.pm | 139 +---------
web/modules/rhn/RHN/DB/DataSource.pm | 2
web/modules/rhn/RHN/DBI.pm | 76 +++++
web/spacewalk-web.spec | 1
15 files changed, 105 insertions(+), 166 deletions(-)
New commits:
commit 352ec92a5da7efb381d55f49eaa265089b1299b0
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 31 14:07:44 2012 +0100
The RHN::DB::connect does not accept any arguments anymore.
diff --git a/web/modules/rhn/RHN/DB/DataSource.pm b/web/modules/rhn/RHN/DB/DataSource.pm
index f1899b9..df75d9d 100644
--- a/web/modules/rhn/RHN/DB/DataSource.pm
+++ b/web/modules/rhn/RHN/DB/DataSource.pm
@@ -67,7 +67,7 @@ sub run_query {
throw "Empty query for mode " . $self->mode()
unless $query_body;
- my $dbh = $params{-transaction} || RHN::DB->connect($self->dsn);
+ my $dbh = $params{-transaction} || RHN::DB->connect();
my $sth;
$sth = $dbh->prepare_cached($query_body);
commit 355a299175a5913e169555241c8c16e7c7706613
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 31 14:00:33 2012 +0100
In monitoring, use RHN::DBI instead of RHN::DB because we do not want to reuse the connection.
diff --git a/monitoring/NPalert/AlertDB.pm b/monitoring/NPalert/AlertDB.pm
index e0e3c07..fadf552 100644
--- a/monitoring/NPalert/AlertDB.pm
+++ b/monitoring/NPalert/AlertDB.pm
@@ -10,7 +10,7 @@ use Class::MethodMaker
use Data::Dumper; # for debugging
use DBI;
use NOCpulse::Config;
-use RHN::DB;
+use RHN::DBI;
use NOCpulse::Log::Logger;
my $Log = NOCpulse::Log::Logger->new(__PACKAGE__);
@@ -36,7 +36,7 @@ sub connect {
}
# Open a connection to the DB
- my $dbh = RHN::DB->connect;
+ my $dbh = RHN::DBI->connect;
if ($dbh) {
diff --git a/monitoring/NPalert/NotificationDB.pm b/monitoring/NPalert/NotificationDB.pm
index 8b2c034..633ddb1 100644
--- a/monitoring/NPalert/NotificationDB.pm
+++ b/monitoring/NPalert/NotificationDB.pm
@@ -10,7 +10,7 @@ use NOCpulse::Config;
use NOCpulse::Probe::DataSource::AbstractDatabase qw(:constants);
use NOCpulse::Probe::Error;
-use RHN::DB;
+use RHN::DBI;
use base qw(NOCpulse::Probe::DataSource::AbstractDatabase);
use Class::MethodMaker
@@ -76,7 +76,7 @@ sub init {
sub connect {
my ($self, %paramHash) = @_;
# Open a connection to the DB
- $self->dbh(RHN::DB->connect);
+ $self->dbh(RHN::DBI->connect);
return $self->dbh;
}
diff --git a/monitoring/PerlModules/NP/OracleDB/DBRecord.pm b/monitoring/PerlModules/NP/OracleDB/DBRecord.pm
index 9032575..046592c 100644
--- a/monitoring/PerlModules/NP/OracleDB/DBRecord.pm
+++ b/monitoring/PerlModules/NP/OracleDB/DBRecord.pm
@@ -91,8 +91,8 @@ sub DatabaseConnection
if (NOCpulse::DBRecord->getClassInstVar('DatabaseConnection')) {
return NOCpulse::DBRecord->getClassInstVar('DatabaseConnection');
} else {
- use RHN::DB;
- if (my $dbMain = RHN::DB->connect) {
+ use RHN::DBI;
+ if (my $dbMain = RHN::DBI->connect) {
NOCpulse::DBRecord->setClassVar('DatabaseConnection', $dbMain);
return $dbMain;
}
diff --git a/monitoring/PerlModules/NP/OracleDB/OracleDB.pm b/monitoring/PerlModules/NP/OracleDB/OracleDB.pm
index 525bd95..5366c1d 100644
--- a/monitoring/PerlModules/NP/OracleDB/OracleDB.pm
+++ b/monitoring/PerlModules/NP/OracleDB/OracleDB.pm
@@ -9,7 +9,7 @@ use strict;
use DBI;
use NOCpulse::Debug;
use NOCpulse::Config;
-use RHN::DB;
+use RHN::DBI;
# Global defaults
my $DEFAULTDATEFORMAT = 'YYYY-MM-DD HH24:MI:SS';
@@ -128,7 +128,7 @@ sub connect {
my $AutoCommit = $paramHash{AutoCommit} || 0;
$self->dprint(2, "Connecting to DB\n");
- my $dbh = RHN::DB->connect;
+ my $dbh = RHN::DBI->connect;
if ($DBI::err) { $@ = $DBI::errstr ; return undef }
diff --git a/monitoring/PerlModules/NP/OracleDB/perl-NOCpulse-OracleDB.spec b/monitoring/PerlModules/NP/OracleDB/perl-NOCpulse-OracleDB.spec
index 5f6b392..ee726f0 100644
--- a/monitoring/PerlModules/NP/OracleDB/perl-NOCpulse-OracleDB.spec
+++ b/monitoring/PerlModules/NP/OracleDB/perl-NOCpulse-OracleDB.spec
@@ -7,7 +7,7 @@ Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}
BuildArch: noarch
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
BuildRequires: perl(NOCpulse::Debug) perl(NOCpulse::Config) perl(NOCpulse::Utils::XML) perl(NOCpulse::Object)
-BuildRequires: perl(RHN::DB)
+BuildRequires: perl(RHN::DBI)
BuildRequires: perl(DBI) perl(ExtUtils::MakeMaker)
Group: Development/Libraries
License: GPLv2
diff --git a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
index fed39bc..32d384e 100644
--- a/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
+++ b/monitoring/nocpulse-common/perl-API/NOCpulse/NOCpulseini.pm
@@ -4,7 +4,7 @@ use strict;
use DBI;
use IO::AtomicFile;
use LWP::UserAgent;
-use RHN::DB;
+use RHN::DBI;
use Class::MethodMaker
get_set =>
@@ -39,7 +39,7 @@ sub connect {
my $self = shift;
# Make DB connection
- my $dbh = RHN::DB->connect;
+ my $dbh = RHN::DBI->connect;
# Set up for graceful exit
$SIG{'INT'} = $self->can('bailout');
unless (defined($dbh)) {
commit a3d0771c35d90cd44e755bd0cc5d6ee4a583cd4b
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 31 11:44:23 2012 +0100
Factor the connection parameters config read to RHN::DBI, start to use it in RHN::DB, also support just one database connection.
diff --git a/web/modules/rhn/RHN/DB.pm b/web/modules/rhn/RHN/DB.pm
index c1c0ed3..191d290 100644
--- a/web/modules/rhn/RHN/DB.pm
+++ b/web/modules/rhn/RHN/DB.pm
@@ -16,64 +16,12 @@
package RHN::DB;
use strict;
-use DBI;
+use RHN::DBI ();
use Carp;
use RHN::Exception;
-use PXT::Config;
our @ISA = qw/DBI/;
-my %aliases;
-my %handles = ();
-
-# Add an alias, maps dbi connection string to an array of username,
-# password, and params.
-sub add_alias {
- my $class = shift;
- my $dbi_connection_string = shift;
-
- $aliases{$dbi_connection_string} = [ @_ ];
-}
-
-sub lookup_alias {
- my $class = shift;
- my $alias = shift;
-
- return $aliases{$alias};
-}
-
-# Return a DBI connection string based on the given inputs. This is also
-# used as a key in our hash of established connections.
-sub get_dbi_connection_string {
- my $class = shift;
- my $backend = shift;
- my $host = shift;
- my $port = shift;
- my $dbname = shift; # sid for oracle backend
-
- if ($backend eq "oracle") {
- return "dbi:Oracle:$dbname";
- }
- elsif ($backend eq "postgresql") {
- my $q = "dbi:Pg:dbname=$dbname";
- if (defined $host and $host ne '') {
- $q .= ";host=$host";
- if (defined $port and $port ne '') {
- $q .= ";port=$port";
- }
- }
- return $q;
- }
-}
-
-$RHN::DB::default_connection = undef;
-
-sub set_default_connection {
- my $class = shift;
-
- $RHN::DB::default_connection = shift;
-}
-
# this forces connection immediately after form, before first request
# is served. can cause a bit of a rush to the db as a bunch of
# httpd's connect, but should be manageable. typically called in
@@ -81,27 +29,21 @@ sub set_default_connection {
sub apache_child_init_handler {
my $class = shift;
- my @aliases = @_ ? @_ : ($RHN::DB::default_handle);
-
- for my $alias (@aliases) {
- if ($class->lookup_alias($alias)) {
- $class->connect($alias);
- }
- }
+ $class->connect();
}
# called after every request. necessary to cleanup uncommitted
# transactions and such
+my $dbh;
sub connection_cleanup {
my $class = shift;
- for my $alias (keys %handles) {
- my $dbh = $handles{$alias};
+ if (defined $dbh) {
if ($dbh->{ActiveKids}) {
- warn "Database handle '$alias' has active children after request completion.";
+ warn "Database handle has active children after request completion.";
}
while($dbh->in_nested_transaction) {
@@ -119,86 +61,39 @@ sub connection_cleanup {
sub soft_connect {
my $class = shift;
- my $alias = shift;
- my $ret = eval { $class->connect($alias) };
+ my $ret = eval { $class->connect(@_) };
return $ret;
}
sub connect {
my $class = shift;
- my $alias = shift;
- my $username = shift;
- my $password = shift;
-
- # Store db handlers using an alias which is equal to their DBI
- # connection string. Note that this does not include username or
- # password information and thus we cannot have multiple connections
- # to one db as different users (currently). If this turns out to be
- # a problem, suggest we prepend/append the username in the alias hash
- # key.
-
- # TODO: Once upon a time these aliases were just Oracle dsn's, if the incoming
- # alias is in this format, convert it to an Oracle dbi string?
-
- $alias ||= ($RHN::DB::default_connection ||= $class->get_dbi_connection_string(
- PXT::Config->get("db_backend"),
- PXT::Config->get("db_host"),
- PXT::Config->get("db_port"),
- PXT::Config->get("db_name")));
-
- if ($handles{$alias} and $handles{$alias}->{Active}) {
- my $dbh = $handles{$alias};
-
- if (not $dbh->ping()) {
- Carp::cluck("Cannot ping database handle for $alias: $DBI::errstr ($@)");
- }
- else {
- return $handles{$alias};
- }
+ if (@_) {
+ Carp::confess "The RHN::DB::connect does not accept any parameters.\n";
}
- # for bug #159720, set the NLS_LANG environment variable from the
- # config option if it is set.
- my $nls_lang = PXT::Config->get('server', 'nls_lang');
- if ($nls_lang) {
- $ENV{NLS_LANG} = $nls_lang;
+ if (defined $dbh and $dbh->ping()) {
+ return $dbh;
}
- $class->add_alias($alias, PXT::Config->get("db_user"),
- PXT::Config->get("db_password"), { });
-
- my $alias_data = $class->lookup_alias($alias);
- Carp::croak "RHN::DB->connect($alias): No such alias '$alias'" unless $alias_data;
-
- my $params;
- ($username, $password, $params) = @{ $alias_data };
+ my ($dsn, $login, $password, $attr) = RHN::DBI::_get_dbi_connect_parameters();
+ $attr->{HandleError} = \&RHN::DB::handle_error;
+ $attr->{private_rhndb_transaction_level} = 0;
- my $dbh = $handles{$alias} = $class->direct_connect($alias, $username, $password,
- { %$params,
- HandleError => \&RHN::DB::handle_error,
- RaiseError => 1,
- PrintError => 0,
- Taint => 0,
- AutoCommit => 0,
- private_rhndb_transaction_level => 0,
- FetchHashKeyName => 'NAME_uc',
- pg_enable_utf8 => 1,
- });
+ $dbh = $class->direct_connect($dsn, $login, $password, $attr);
# this dbh is from a cache, which means disconnects fail
$dbh->{private_from_cache} = 1;
- Carp::croak "$class->connect($alias) failed: $DBI::errstr" unless $dbh;
+ Carp::croak "$class->connect() failed: $DBI::errstr" unless $dbh;
$dbh->init_db_handle();
$dbh->init_db_session();
if (not $dbh->ping()) {
$dbh->force_disconnect;
- delete $handles{$alias};
- Carp::croak("Cannot ping database handle for $alias: $DBI::errstr");
+ Carp::croak("Cannot ping database handle: $DBI::errstr");
}
return $dbh;
}
diff --git a/web/modules/rhn/RHN/DBI.pm b/web/modules/rhn/RHN/DBI.pm
new file mode 100644
index 0000000..ff3a720
--- /dev/null
+++ b/web/modules/rhn/RHN/DBI.pm
@@ -0,0 +1,76 @@
+#
+# Copyright (c) 2011 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.
+#
+
+package RHN::DBI;
+
+use strict;
+use warnings FATAL => 'all';
+use DBI ();
+use PXT::Config ();
+use Carp ();
+
+my %DEFAULT_ATTRIBUTES = (
+ RaiseError => 1,
+ PrintError => 0,
+ Taint => 0,
+ AutoCommit => 0,
+ FetchHashKeyName => 'NAME_uc',
+ pg_enable_utf8 => 1,
+);
+
+# Return a DBI connect parameters, based on data in
+# /etc/rhn/rhn.conf. It will get the configuration values once
+# and use them for subsequent calls.
+my ($DSN, $LOGIN, $PASSWORD);
+sub _get_dbi_connect_parameters {
+ if (not defined $DSN) {
+ my $backend = PXT::Config->get("db_backend");
+ my $dbname = PXT::Config->get("db_name");
+ if ($backend eq "oracle") {
+ $DSN = "dbi:Oracle:$dbname";
+
+ my $nls_lang = PXT::Config->get('server', 'nls_lang');
+ if (defined $nls_lang and $nls_lang ne '') {
+ $ENV{NLS_LANG} = $nls_lang;
+ }
+ } else {
+ $DSN = "dbi:Pg:dbname=$dbname";
+ my $host = PXT::Config->get("db_host");
+ if (defined $host and $host ne '') {
+ $DSN .= ";host=$host";
+ my $port = PXT::Config->get("db_port");
+ if (defined $port and $port ne '') {
+ $DSN .= ";port=$port";
+ }
+ }
+ }
+ $LOGIN = PXT::Config->get("db_user");
+ $PASSWORD = PXT::Config->get("db_password");
+ }
+
+ return ($DSN, $LOGIN, $PASSWORD, { %DEFAULT_ATTRIBUTES });
+}
+
+# Do a connect via DBI to database configured in /etc/rhn/rhn.conf.
+sub connect {
+ my $class = shift;
+ if (@_) {
+ Carp::confess "The RHN::DBI::connect does not accept any parameters.\n";
+ }
+ return DBI->connect(_get_dbi_connect_parameters());
+}
+
+1;
+
diff --git a/web/spacewalk-web.spec b/web/spacewalk-web.spec
index 95a0e09..2b26178 100644
--- a/web/spacewalk-web.spec
+++ b/web/spacewalk-web.spec
@@ -221,6 +221,7 @@ rm -rf $RPM_BUILD_ROOT
%{perl_vendorlib}/RHN/SessionSwap.pm
%{perl_vendorlib}/RHN/Exception.pm
%{perl_vendorlib}/RHN/DB.pm
+%{perl_vendorlib}/RHN/DBI.pm
%{perl_vendorlib}/PXT/Config.pm
%attr(640,root,apache) %{_prefix}/share/rhn/config-defaults/rhn_web.conf
%doc LICENSE
commit 0f660de3fb8f957e105ccc2030d9c87910a92ab8
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 31 11:35:59 2012 +0100
Removing code which is long commented out.
diff --git a/web/modules/pxt/PXT/ApacheHandler.pm b/web/modules/pxt/PXT/ApacheHandler.pm
index 27ad37a..245db3e 100644
--- a/web/modules/pxt/PXT/ApacheHandler.pm
+++ b/web/modules/pxt/PXT/ApacheHandler.pm
@@ -312,17 +312,6 @@ sub initialize_pxt {
PXT::Config->set(base_port => $base_port);
}
-# NOTE: Commenting out as part of PostgreSQL effort, likely unused code.
-# Personalities once used to prepend a token to the cookie to avoid
-# conflicts with RHN cookies. Suspected to now be unused.
-#
-#if ($r->pnotes('hostname_personality')) {
-# my $dsn = $r->pnotes('hostname_personality');
-# if (RHN::DB->lookup_alias($dsn)) {
-# RHN::DB->set_default_handle($dsn);
-# }
-# }
-
if (PXT::Config->get('profile_queries')) {
my $dbh = RHN::DB->connect;
$dbh->enable_profile;
commit f3ac6fb02294310d07ec3ea619427822f193ab7c
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 31 11:33:58 2012 +0100
Monitoring uses RHN::DB, so no need to have the extra connect parameters.
diff --git a/spacewalk/setup/bin/spacewalk-setup b/spacewalk/setup/bin/spacewalk-setup
index 133820b..274e148 100755
--- a/spacewalk/setup/bin/spacewalk-setup
+++ b/spacewalk/setup/bin/spacewalk-setup
@@ -1293,23 +1293,11 @@ sub setup_monitoring {
RHN_ADMIN_EMAIL => $answers->{'admin-email'},
MAIL_MX => $answers->{'mail-mx'} || 'localhost',
MDOM => $answers->{mdom} || $answers->{hostname},
- RHN_DB_NAME => $answers->{'db-name'},
- RHN_DB_USERNAME => $answers->{'db-user'},
- RHN_DB_PASSWD => $answers->{'db-password'},
- RHN_DB_TABLE_OWNER => $answers->{'db-user'},
RHN_SAT_HOSTNAME => $answers->{hostname},
XPROTO => 'https',
RHN_SAT_WEB_PORT => 443
);
- # DB connection params not yet written to rhn.conf, must specify them manually:
- my $connection_string =
- RHN::DB->get_dbi_connection_string($answers->{'db-backend'},
- $answers->{'db-host'}, $answers->{'db-port'}, $answers->{'db-name'});
- RHN::DB->add_alias($connection_string, $answers->{'db-user'},
- $answers->{'db-password'}, { } );
- RHN::DB->set_default_connection($connection_string);
-
update_monitoring_config($answers, \%mon_config);
# Bugzilla 466747: On s390x, stty: standard input: Bad file descriptor
commit 251e06c97f7039363afb79abec5a90bf30a195ed
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Jan 30 16:27:56 2012 +0100
Removing the web.debug_disable_database option -- it is not supported beyond RHN::DB anyway.
diff --git a/java/buildconf/builder/config/satellite/default/rhn_web.conf b/java/buildconf/builder/config/satellite/default/rhn_web.conf
index 876e9cd..4785989 100644
--- a/java/buildconf/builder/config/satellite/default/rhn_web.conf
+++ b/java/buildconf/builder/config/satellite/default/rhn_web.conf
@@ -239,9 +239,6 @@ web.trace_session = 0
# email address for feedback
web.rhn_feedback_address = rhn-feedback(a)redhat.com
-# for debugging: act like the db has disappeared
-web.debug_disable_database = 0
-
# max number of sets of isos the "Latest ISOs" page should use
web.max_latest_iso_categories = 3
diff --git a/spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf b/spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf
index 7ccbd1d..d08becf 100644
--- a/spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf
+++ b/spacewalk/config/var/lib/rhn/rhn-satellite-prep/etc/rhn/rhn.conf
@@ -1,4 +1,3 @@
-traceback_mail = @@traceback_mail@@
mount_point = @@mount_point@@
kickstart_mount_point = @@kickstart_mount_point@@
repomd_cache_mount_point = /var/cache
@@ -42,7 +41,6 @@ hibernate.connection.driver_proto=@@hibernate_driver_proto@@
web.satellite = 1
web.satellite_install = @@satellite_install@@
-web.debug_disable_database = 0
web.session_swap_secret_1 = @@session_swap_secret_1@@
web.session_swap_secret_2 = @@session_swap_secret_2@@
diff --git a/web/conf/rhn_web.conf b/web/conf/rhn_web.conf
index 31276da..874f0d7 100644
--- a/web/conf/rhn_web.conf
+++ b/web/conf/rhn_web.conf
@@ -208,9 +208,6 @@ web.db_password =
# trace all sessions? (never enable in prod!)
web.trace_session = 0
-# for debugging: act like the db has disappeared
-web.debug_disable_database = 0
-
# max number of sets of isos the "Latest ISOs" page should use
web.max_latest_iso_categories = 3
diff --git a/web/modules/rhn/RHN/DB.pm b/web/modules/rhn/RHN/DB.pm
index ddddf93..c1c0ed3 100644
--- a/web/modules/rhn/RHN/DB.pm
+++ b/web/modules/rhn/RHN/DB.pm
@@ -132,8 +132,6 @@ sub connect {
my $username = shift;
my $password = shift;
- return if PXT::Config->get('debug_disable_database');
-
# Store db handlers using an alias which is equal to their DBI
# connection string. Note that this does not include username or
# password information and thus we cannot have multiple connections
12 years, 2 months
Branch 'errata-date' - utils/cloneByDate.py utils/depsolver.py
by Justin Sherrill
utils/cloneByDate.py | 48 +++++++++++++++++++++++-------------------------
utils/depsolver.py | 23 +++++++++++++++++++++--
2 files changed, 44 insertions(+), 27 deletions(-)
New commits:
commit 32c971c5ef2987f1579b0ff6e1f00235bc37500b
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Jan 30 14:48:44 2012 -0500
errata date clone - adding additional progress bars and cleaning up some output
diff --git a/utils/cloneByDate.py b/utils/cloneByDate.py
index 1891cd7..90a0590 100644
--- a/utils/cloneByDate.py
+++ b/utils/cloneByDate.py
@@ -93,14 +93,14 @@ def main(options):
-##
-# Usage:
-# a = ChannelTreeCloner(channel_hash, xmlrpc, db, to_date)
-# a.create_channels()
-# a.prepare()
-# a.clone()
-#
+
class ChannelTreeCloner:
+ """Usage:
+ a = ChannelTreeCloner(channel_hash, xmlrpc, db, to_date)
+ a.create_channels()
+ a.prepare()
+ a.clone()
+ """
def __init__(self, channels, remote_api, db_api, to_date, blacklist):
self.remote_api = remote_api
self.db_api = db_api
@@ -218,20 +218,16 @@ class ChannelTreeCloner:
labels = self.channel_map.keys()
repos = [{"id":label, "relative_path":self.repodata(label)} for label in labels]
- print "Solving deps"
-
solver = DepSolver(repos, nvrea_list)
dep_results = solver.processResults(solver.getDependencylist())
-
- print "Processing"
+
self.process_deps(dep_results)
-
def process_deps(self, deps):
needed_list = dict((label, []) for label in self.channel_map.values())
unsolved_deps = []
- pb = ProgressBar(prompt="Proccessing Depedencies: ", endTag=' - complete\n',
+ pb = ProgressBar(prompt="Processing Dependencies: ", endTag=' - complete',
finalSize=len(deps), finalBarLength=40, stream=sys.stdout)
pb.printAll(1);
@@ -251,20 +247,19 @@ class ChannelTreeCloner:
found = True
if not found:
unsolved_deps.append((pkg))
- pb.complete()
+ pb.printComplete()
- print "Unsolved deps: %i" % len(unsolved_deps)
- print "Needed deps: "
- for label in needed_list.keys():
- print "%s: %i" % (label, len(needed_list[label]))
+# print "Unsolved deps: %i" % len(unsolved_deps)
+# print "Needed deps: "
+# for label in needed_list.keys():
+# print "%s: %i" % (label, len(needed_list[label]))
for cloner in self.cloners:
needed = needed_list[cloner.dest_label()]
if len(needed) > 0:
cloner.process_deps(needed)
- def remove_blacklisted(self):
- print self.blacklist
+ def remove_blacklisted(self):
for cloner in self.cloners:
cloner.remove_blacklisted(self.blacklist)
@@ -323,12 +318,12 @@ class ChannelCloner:
return len(self.errata_to_clone)
def pre_summary(self):
- print "%s -> %s (%i/%i Errata)" %(self.from_label, self.to_label, len(self.errata_to_clone), len(self.available_errata))
+ print " %s -> %s (%i/%i Errata)" %(self.from_label, self.to_label, len(self.errata_to_clone), len(self.available_errata))
def process(self):
self.clone();
self.reset_new_pkgs()
- print "New packages added: %i" % (len(self.new_pkg_hash) - len(self.old_pkg_hash))
+ #print "New packages added: %i" % (len(self.new_pkg_hash) - len(self.old_pkg_hash))
def process_deps(self, needed_pkgs):
needed_ids = []
@@ -340,8 +335,7 @@ class ChannelCloner:
else:
unsolved_deps.append(pkg)
- if len(needed_ids) > 0:
- print "Adding dependencies: %i" % len(needed_ids)
+ if len(needed_ids) > 0:
self.remote_api.add_packages(self.to_label, needed_ids)
@@ -386,6 +380,9 @@ class ChannelCloner:
def clone(self):
bunch_size = 10
errata_ids = self.collect(self.errata_to_clone, "advisory_name")
+ if len(errata_ids) == 0:
+ return
+
msg = 'Cloning Errata into %s (%i): ' % (self.to_label, len(errata_ids))
pb = ProgressBar(prompt=msg, endTag=' - complete',
finalSize=len(errata_ids), finalBarLength=40, stream=sys.stdout)
@@ -419,7 +416,8 @@ class ChannelCloner:
if err['issue_date'] <= self.to_date:
to_clone.append(err)
- return (to_clone, available_errata)
+ return (to_clone, available_errata)
+
def remove_blacklisted(self, pkg_names):
found_ids = []
diff --git a/utils/depsolver.py b/utils/depsolver.py
index b1ee2e2..7de4bed 100644
--- a/utils/depsolver.py
+++ b/utils/depsolver.py
@@ -27,6 +27,15 @@ from yum.packageSack import ListPackageSack
from yum.packages import parsePackages
from yum.repos import RepoStorage
+try:
+ from spacewalk.satellite_tools.progress_bar import ProgressBar
+except:
+ _LIBPATH = "/usr/share/rhn"
+ if _LIBPATH not in sys.path:
+ sys.path.append(_LIBPATH)
+ from satellite_tools.progress_bar import ProgressBar
+
+
log = logging.getLogger(__name__)
CACHE_DIR="/tmp/cache/yum"
@@ -71,7 +80,8 @@ class DepSolver:
The package name format could be any of the following:
name, name.arch, name-ver-rel.arch, name-ver, name-ver-rel,
epoch:name-ver-rel.arch, name-epoch:ver-rel.arch
- """
+ """
+
ematch, match, unmatch = parsePackages(self._repostore.pkgSack, self.pkgs)
pkgs = []
for po in ematch + match:
@@ -91,7 +101,8 @@ class DepSolver:
"""
solved = []
to_solve = self.pkgs
- all_results = {}
+ all_results = {}
+
while to_solve:
log.debug("Solving %s \n\n" % to_solve)
results = self.getDependencylist()
@@ -112,7 +123,14 @@ class DepSolver:
def __locateDeps(self, pkgs):
results = {}
regex_filename_match = re.compile('[/*?]|\[[^]]*/[^]]*\]').match
+
+ pb = ProgressBar(prompt="Solving Dependencies (%i): " % len(pkgs), endTag=' - complete',
+ finalSize=len(pkgs), finalBarLength=40, stream=sys.stdout)
+ pb.printAll(1);
+
for pkg in pkgs:
+ pb.addTo(1)
+ pb.printIncrement()
results[pkg] = {}
reqs = pkg.requires
reqs.sort()
@@ -129,6 +147,7 @@ class DepSolver:
po.checkPrco('provides', (r, f, v)):
satisfiers.append(po)
pkgresults[req] = satisfiers
+ pb.printComplete()
return results
def __whatProvides(self, name, flags, version):
12 years, 2 months
Branch 'errata-date' - utils/depsolver.py
by Pradeep Kilambi
utils/depsolver.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 72978488be770327bfc992164612443b21b26681
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Jan 30 13:22:06 2012 -0500
fix to improve dep solver performance
diff --git a/utils/depsolver.py b/utils/depsolver.py
index 04c6bac..b1ee2e2 100644
--- a/utils/depsolver.py
+++ b/utils/depsolver.py
@@ -24,6 +24,7 @@ import sys
import yum
from yum.misc import prco_tuple_to_string
from yum.packageSack import ListPackageSack
+from yum.packages import parsePackages
from yum.repos import RepoStorage
log = logging.getLogger(__name__)
@@ -71,7 +72,7 @@ class DepSolver:
name, name.arch, name-ver-rel.arch, name-ver, name-ver-rel,
epoch:name-ver-rel.arch, name-epoch:ver-rel.arch
"""
- ematch, match, unmatch = self._repostore.pkgSack.matchPackageNames(self.pkgs)
+ ematch, match, unmatch = parsePackages(self._repostore.pkgSack, self.pkgs)
pkgs = []
for po in ematch + match:
pkgs.append(po)
12 years, 2 months
Branch 'errata-date' - utils/cloneByDate.py utils/spacewalk-clone-by-date
by Justin Sherrill
utils/cloneByDate.py | 59 ++++++++++++++++++++++++++++++------------
utils/spacewalk-clone-by-date | 9 ++++--
2 files changed, 49 insertions(+), 19 deletions(-)
New commits:
commit ebbe962c3d98f0ad04e97394cc8c3f6d9a9ccaf2
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Jan 30 11:27:27 2012 -0500
errata date clone - adding package blacklist removal
diff --git a/utils/cloneByDate.py b/utils/cloneByDate.py
index 106be52..1891cd7 100644
--- a/utils/cloneByDate.py
+++ b/utils/cloneByDate.py
@@ -62,7 +62,7 @@ def main(options):
cloners = []
needed_channels = []
for channel_list in options.channels:
- tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db, options.to_date)
+ tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db, options.to_date, options.blacklist)
cloners.append(tree_cloner)
needed_channels += tree_cloner.needing_create().values()
@@ -81,7 +81,7 @@ def main(options):
for cloner in cloners:
cloner.pre_summary()
total += cloner.pending()
-
+
if total == 0:
print ("\nNothing to do.")
sys.exit(0)
@@ -89,6 +89,7 @@ def main(options):
confirm("\nContinue with clone (y/n)?", options)
for cloner in cloners:
cloner.clone()
+ cloner.remove_blacklisted()
@@ -100,14 +101,16 @@ def main(options):
# a.clone()
#
class ChannelTreeCloner:
- def __init__(self, channels, remote_api, db_api, to_date):
+ def __init__(self, channels, remote_api, db_api, to_date, blacklist):
self.remote_api = remote_api
self.db_api = db_api
self.channel_map = channels
self.to_date = to_date
self.cloners = []
- self.validate_source_channels()
+ self.blacklist = blacklist
+ self.validate_source_channels()
+
for from_label in self.ordered_labels():
to_label = self.channel_map[from_label]
cloner = ChannelCloner(from_label, to_label, self.to_date, self.remote_api, self.db_api)
@@ -227,9 +230,16 @@ class ChannelTreeCloner:
def process_deps(self, deps):
needed_list = dict((label, []) for label in self.channel_map.values())
unsolved_deps = []
+
+ pb = ProgressBar(prompt="Proccessing Depedencies: ", endTag=' - complete\n',
+ finalSize=len(deps), finalBarLength=40, stream=sys.stdout)
+ pb.printAll(1);
+
#loop through all the deps and find any that don't exist in the
# destination channels
- for pkg in deps:
+ for pkg in deps:
+ pb.addTo(1)
+ pb.printIncrement()
for dep, solved_list in pkg.items():
found = False
for cloner in self.cloners:
@@ -241,19 +251,23 @@ class ChannelTreeCloner:
found = True
if not found:
unsolved_deps.append((pkg))
+ pb.complete()
print "Unsolved deps: %i" % len(unsolved_deps)
print "Needed deps: "
for label in needed_list.keys():
print "%s: %i" % (label, len(needed_list[label]))
-
- #import pdb; pdb.set_trace()
+
for cloner in self.cloners:
needed = needed_list[cloner.dest_label()]
if len(needed) > 0:
cloner.process_deps(needed)
-
+ def remove_blacklisted(self):
+ print self.blacklist
+ for cloner in self.cloners:
+ cloner.remove_blacklisted(self.blacklist)
+
def repodata(self, label):
repo_dir = "/var/cache/rhn/repodata/%s" % label
tmp_dir = tempfile.mkdtemp(suffix="clone-by-date")
@@ -272,9 +286,7 @@ class ChannelCloner:
self.db_api = db_api
self.from_label = from_label
self.to_label = to_label
- self.to_date = to_date
-
-
+ self.to_date = to_date
self.from_pkg_hash = None
self.new_pkg_hash = {}
@@ -331,11 +343,8 @@ class ChannelCloner:
if len(needed_ids) > 0:
print "Adding dependencies: %i" % len(needed_ids)
self.remote_api.add_packages(self.to_label, needed_ids)
- if len(unsolved_deps) > 0:
- print "Unresolved dependencies: %i" % len(unsolved_deps)
-
-
+
def list_to_hash(self, pkg_list, key):
pkg_hash = {}
for pkg in pkg_list:
@@ -411,6 +420,18 @@ class ChannelCloner:
to_clone.append(err)
return (to_clone, available_errata)
+
+ def remove_blacklisted(self, pkg_names):
+ found_ids = []
+ for pkg in self.reset_new_pkgs().values():
+ if pkg['name'] in pkg_names:
+ found_ids.append(pkg['id'])
+ if len(found_ids) > 0:
+ print "Removing %i packages from %s" % (len(found_ids), self.to_label)
+ self.remote_api.remove_packages(self.to_label, found_ids)
+
+
+
class RemoteApi:
""" Class for connecting to the XMLRPC spacewalk interface"""
@@ -466,7 +487,13 @@ class RemoteApi:
set = package_ids[:20]
del package_ids[:20]
self.client.channel.software.addPackages(self.auth_token, label, set)
-
+
+ def remove_packages(self, label, package_ids):
+ while(len(package_ids) > 0):
+ set = package_ids[:20]
+ del package_ids[:20]
+ self.client.channel.software.removePackages(self.auth_token, label, set)
+
def clone_channel(self, original_label, new_label, parent):
details = {'name': new_label, 'label':new_label, 'summary': new_label}
if parent and parent != '':
diff --git a/utils/spacewalk-clone-by-date b/utils/spacewalk-clone-by-date
index 3fad22a..b40d94b 100755
--- a/utils/spacewalk-clone-by-date
+++ b/utils/spacewalk-clone-by-date
@@ -87,8 +87,8 @@ def parse_args():
parser.add_option("-u", "--username", dest="username", help="Username")
parser.add_option("-p", "--password", dest="password", help="Password")
parser.add_option("-s", "--server", dest="server", help="Server URL to use for api connections (defaults to https://localhost/rpc/api)", default="https://localhost/rpc/api")
- parser.add_option("-l", "--channels", dest="channels", nargs=2, action="append", help="Origianl channel and clone channel labels space seperated (e.g. --channels=rhel-i386-server-5 myclone)")
- parser.add_option("-b", "--blacklist", dest="blacklist", nargs="*", help="Space seperated list of package names")
+ parser.add_option("-l", "--channels", dest="channels", nargs=2, action="append", help="Original channel and clone channel labels space seperated (e.g. --channels=rhel-i386-server-5 myclone)")
+ parser.add_option("-b", "--blacklist", dest="blacklist", help="Comman separated list of package names")
parser.add_option("-d", "--to_date", dest="to_date", help="Clone errata to the specified date (YYYY-MM-DD)")
parser.add_option("-y", "--assumeyes", dest='assumeyes', action='store_true', help="Assume yes for any prompts (unattended).")
parser.add_option("-m", "--sample-config", dest='sample', action='store_true', help="Print a sample full configuration file and exit.")
@@ -101,7 +101,10 @@ def parse_args():
if options.config and options.channels:
raise UserError("Cannot specify both --channels and --config.")
-
+
+ if options.blacklist:
+ options.blacklist = options.blacklist.split(",")
+
options = merge_config(options)
options.to_date = parse_time(options.to_date)
12 years, 2 months
Branch 'errata-date' - 2 commits - utils/cloneByDate.py utils/spacewalk-clone-by-date
by Justin Sherrill
utils/cloneByDate.py | 57 +++++++++++++++++++++++++++---------------
utils/spacewalk-clone-by-date | 36 ++++++++++++++++++++++----
2 files changed, 68 insertions(+), 25 deletions(-)
New commits:
commit ed4d17a4427a44f0e52619fc2c4ca666dc28fbf7
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Jan 30 10:06:17 2012 -0500
moving dep solving to channel tree instead of individual channels
diff --git a/utils/cloneByDate.py b/utils/cloneByDate.py
index d39438d..106be52 100644
--- a/utils/cloneByDate.py
+++ b/utils/cloneByDate.py
@@ -64,7 +64,7 @@ def main(options):
for channel_list in options.channels:
tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db, options.to_date)
cloners.append(tree_cloner)
- needed_channels += tree_cloner.needing_create()
+ needed_channels += tree_cloner.needing_create().values()
if len(needed_channels) > 0:
print "\nBy continuing the following channels will be created: "
@@ -113,13 +113,14 @@ class ChannelTreeCloner:
cloner = ChannelCloner(from_label, to_label, self.to_date, self.remote_api, self.db_api)
self.cloners.append(cloner)
+ #returns a trimmed down version of channel_map where the value needs creating
def needing_create(self):
- to_ret = []
+ to_create = {}
existing = self.remote_api.list_channel_labels()
- for label in self.channel_map.values():
- if existing.count(label) == 0:
- to_ret.append(label)
- return to_ret
+ for src, dest in self.channel_map.items():
+ if dest not in existing:
+ to_create[src] = dest
+ return to_create
def pending(self):
total = 0
@@ -127,23 +128,33 @@ class ChannelTreeCloner:
total += cloner.pending()
return total
+ def find_cloner(self, src_label):
+ for cloner in self.cloners:
+ if cloner.src_label() == src_label:
+ return cloner
+
def create_channels(self):
to_create = self.needing_create()
+
if len(to_create) == 0:
return
dest_parent = self.channel_map[self.src_parent]
nvreas = []
- if to_create.count(dest_parent) > 0:
+
+ #clone the destination parent if it doesn't exist
+ if dest_parent in to_create.values():
self.remote_api.clone_channel(self.src_parent, dest_parent, None)
- to_create.remove(dest_parent)
- cloner = self.cloners[0]
+ del to_create[self.src_parent]
+ cloner = self.find_cloner(self.src_parent)
nvreas += [ pkg['nvrea'] for pkg in cloner.reset_new_pkgs().values()]
-
+ #clone the children
for cloner in self.cloners:
- if cloner.dest_label() in to_create:
+ if cloner.dest_label() in to_create.values():
self.remote_api.clone_channel(cloner.src_label(), cloner.dest_label(), dest_parent)
nvreas += [ pkg['nvrea'] for pkg in cloner.reset_new_pkgs().values() ]
- self.dep_solve(nvreas, labels=to_create)
+
+ #dep solve all added packages with the parent channel
+ self.dep_solve(nvreas, labels=(to_create.keys() + [self.src_parent]))
def validate_source_channels(self):
@@ -195,17 +206,17 @@ class ChannelTreeCloner:
for cloner in self.cloners:
cloner.process()
added_pkgs += cloner.pkg_diff()
- self.dep_solve(added_pkgs)
+ self.dep_solve([pkg['nvrea'] for pkg in added_pkgs])
- def dep_solve(self, nvrea_list, labels=None):
+ def dep_solve(self, nvrea_list, labels=None):
if not labels:
labels = self.channel_map.keys()
repos = [{"id":label, "relative_path":self.repodata(label)} for label in labels]
print "Solving deps"
-
+
solver = DepSolver(repos, nvrea_list)
dep_results = solver.processResults(solver.getDependencylist())
@@ -222,13 +233,16 @@ class ChannelTreeCloner:
for dep, solved_list in pkg.items():
found = False
for cloner in self.cloners:
- if cloner.src_pkg_exist(solved_list) and not cloner.dest_pkg_exist(solved_list):
+ exists_from = cloner.src_pkg_exist(solved_list)
+ exists_to = cloner.dest_pkg_exist(solved_list)
+ if exists_from and not exists_to:
needed_list[cloner.dest_label()].append(solved_list[0]) #grab oldest package
- found = True
+ elif exists_from:
+ found = True
if not found:
unsolved_deps.append((pkg))
- print "Unsolved deps: %i" % len(unsolved_deps)
+ print "Unsolved deps: %i" % len(unsolved_deps)
print "Needed deps: "
for label in needed_list.keys():
print "%s: %i" % (label, len(needed_list[label]))
@@ -243,7 +257,10 @@ class ChannelTreeCloner:
def repodata(self, label):
repo_dir = "/var/cache/rhn/repodata/%s" % label
tmp_dir = tempfile.mkdtemp(suffix="clone-by-date")
- shutil.copytree(repo_dir, tmp_dir + "/repodata/")
+ try:
+ shutil.copytree(repo_dir, tmp_dir + "/repodata/")
+ except:
+ raise UserError("Could not find repodata for %s in %s" % (label, repo_dir))
return tmp_dir
@@ -299,7 +316,7 @@ class ChannelCloner:
def process(self):
self.clone();
self.reset_new_pkgs()
- print "New packages added: %i" % len(len(self.new_pkg_hash) - len(self.old_pkg_hash))
+ print "New packages added: %i" % (len(self.new_pkg_hash) - len(self.old_pkg_hash))
def process_deps(self, needed_pkgs):
needed_ids = []
commit a0448d0fa7500f79b47c647539ba31068c6a1f7b
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Jan 30 10:04:58 2012 -0500
errata date clone - adding sample configuration option
diff --git a/utils/spacewalk-clone-by-date b/utils/spacewalk-clone-by-date
index e44728a..3fad22a 100755
--- a/utils/spacewalk-clone-by-date
+++ b/utils/spacewalk-clone-by-date
@@ -21,6 +21,7 @@
import sys
import datetime
from optparse import OptionParser
+import simplejson as json
#try:
import cloneByDate
@@ -29,6 +30,24 @@ from cloneByDate import UserError
# from utils import cloneByDate
+SAMPLE_CONFIG = """
+{
+ "username":"admin",
+ "password":"redhat",
+ "assumeyes":true,
+ "to_date": "2011-10-01",
+ "channels":[
+ {
+ "rhel-x86_64-server-5":"my-rhel5-x86_64-clone",
+ "rhn-tools-rhel-x86_64-server-5": "my-tools-5-x86_64-clone"
+ },
+ {
+ "rhel-i386-server-5": "my-rhel5-i386-clone"
+ }
+ ]
+}
+"""
+
def merge_config(options):
if not options.config:
@@ -38,7 +57,7 @@ def merge_config(options):
#if soemthing is in the config and not passed in as an argument
# add it to options
- overwrite = ["username", "password", "blacklist", "channels", "server", "assumeyes"]
+ overwrite = ["username", "password", "blacklist", "channels", "server", "assumeyes", "to_date"]
for key in overwrite:
if config.has_key(key) and not getattr(options, key):
setattr(options, key, config[key])
@@ -72,12 +91,20 @@ def parse_args():
parser.add_option("-b", "--blacklist", dest="blacklist", nargs="*", help="Space seperated list of package names")
parser.add_option("-d", "--to_date", dest="to_date", help="Clone errata to the specified date (YYYY-MM-DD)")
parser.add_option("-y", "--assumeyes", dest='assumeyes', action='store_true', help="Assume yes for any prompts (unattended).")
+ parser.add_option("-m", "--sample-config", dest='sample', action='store_true', help="Print a sample full configuration file and exit.")
(options, args) = parser.parse_args()
- options.to_date = parse_time(options.to_date)
+ if options.sample:
+ print SAMPLE_CONFIG
+ sys.exit(0)
+
if options.config and options.channels:
raise UserError("Cannot specify both --channels and --config.")
+
+ options = merge_config(options)
+ options.to_date = parse_time(options.to_date)
+
if options.channels == None or len(options.channels) == 0:
raise UserError("No channels specified.")
return options
@@ -104,9 +131,8 @@ def systemExit(code, msgs=None):
def main():
try:
- args = parse_args();
- options = merge_config(args)
- return cloneByDate.main(options)
+ args = parse_args();
+ return cloneByDate.main(args)
except KeyboardInterrupt:
systemExit(0, "\nUser interrupted process.")
except UserError, error:
12 years, 2 months