backend/Makefile.backend | 2 backend/satellite_tools/Makefile | 6 backend/satellite_tools/repo_plugins/Makefile | 27 + backend/satellite_tools/repo_plugins/__init__.py | 15 backend/satellite_tools/repo_plugins/yum_src.py | 64 ++ backend/satellite_tools/reposync.py | 244 ++++++++++ backend/satellite_tools/spacewalk-debug.8 | 20 backend/satellite_tools/spacewalk-repo-sync | 79 +++ backend/server/Makefile | 4 backend/server/basePackageUpload.py | 100 ++++ backend/server/rhnPackage.py | 16 backend/server/rhnPackageUpload.py | 71 -- backend/spacewalk-backend.spec | 7 backend/upload_server/handlers/package_push/package_push.py | 10 backend/upload_server/handlers/package_upload/package_upload.py | 8 java/buildconf/builder/config/satellite/rhn.conf | 2 java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java | 3 java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml | 8 java/code/src/com/redhat/rhn/domain/channel/Channel.java | 51 ++ java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java | 40 + java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml | 41 + java/code/src/com/redhat/rhn/domain/channel/ContentSource.java | 131 +++++ java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.hbm.xml | 26 + java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.java | 59 ++ java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java | 14 java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml | 8 java/code/src/com/redhat/rhn/domain/task/TaskFactory.java | 29 + java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java | 30 + java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml | 3 java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 21 java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java | 46 + java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java | 8 java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java | 114 ++++ java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp | 39 + java/code/webapp/WEB-INF/struts-config.xml | 3 schema/spacewalk/common/tables/rhnChannelContentSource.sql | 61 ++ schema/spacewalk/common/tables/rhnContentSourceType.sql | 48 + schema/spacewalk/common/tables/rhnContentSourceType_data.sql | 21 schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql | 46 + schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql | 57 ++ 40 files changed, 1477 insertions(+), 105 deletions(-)
New commits: commit b397990514e0aed7cfcb77d5ea83a60664ea51b9 Merge: c273e9e... 074cca0... Author: Justin Sherrill jsherril@redhat.com Date: Mon Aug 3 14:06:12 2009 -0400
Merge branch 'master' into repo-sync
commit c273e9e74814bc85658472c21c9bfb9b69385d10 Author: Justin Sherrill jsherril@redhat.com Date: Mon Aug 3 13:13:55 2009 -0400
moving three new tables for postgres merge
diff --git a/schema/spacewalk/common/tables/rhnChannelContentSource.sql b/schema/spacewalk/common/tables/rhnChannelContentSource.sql new file mode 100644 index 0000000..f0b30a5 --- /dev/null +++ b/schema/spacewalk/common/tables/rhnChannelContentSource.sql @@ -0,0 +1,61 @@ +-- +-- 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. +-- +-- +-- +-- + +create table +rhnChannelContentSource +( + id number + constraint rhn_ccs_id_nn not null + constraint rhn_ccs_id_pk primary key, + channel_id number + constraint rhn_ccs_c_nn not null + constraint rhn_ccs_c_fk + references rhnChannel(id) on delete cascade, + type_id number + constraint rhn_ccs_type_nn not null + constraint rhn_ccs_type_fk + references rhnContentSourceType(id), + source_url varchar2(512) + constraint rhn_ccs_url_nn not null, + label varchar2(64) + constraint rhn_ccs_l_nn not null, + last_synced date, + created date default(sysdate) + constraint rhn_ccs_cre_nn not null, + modified date default(sysdate) + constraint rhn_ccs_mod_nn not null +) + enable row movement + ; + + +create sequence rhn_chan_content_src_id_seq start with 500; + + +create unique index rhn_ccs_uq + on rhnChannelContentSource(channel_id, type_id, source_url) + tablespace [[64k_tbs]] + ; + +/ +show errors + +-- +-- Revision 1.0 2009/06/26 21:54 jlsherrill +-- Initial file. +-- diff --git a/schema/spacewalk/common/tables/rhnContentSourceType.sql b/schema/spacewalk/common/tables/rhnContentSourceType.sql new file mode 100644 index 0000000..6e0ce24 --- /dev/null +++ b/schema/spacewalk/common/tables/rhnContentSourceType.sql @@ -0,0 +1,48 @@ +-- +-- 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. +-- +-- +-- +-- + +create table +rhnContentSourceType +( + id number + constraint rhn_cst_id_nn not null + constraint rhn_cst_id_pk primary key, + label varchar2(32) + constraint rhn_cst_label_nn not null + constraint rhn_cst_label_uq unique, + created date default(sysdate) + constraint rhn_cst_created_nn not null, + modified date default(sysdate) + constraint rhn_cst_modified_nn not null +) + enable row movement + ; + +create sequence rhn_content_source_type_id_seq start with 500; + +create index rhn_ccst_id_l_idx + on rhnContentSourceType(id,label) + tablespace [[64k_tbs]] + ; + +show errors + +-- +-- Revision 1.0 2002/11/13 21:50:21 jlsherrill +-- initial table add +-- diff --git a/schema/spacewalk/common/tables/rhnContentSourceType_data.sql b/schema/spacewalk/common/tables/rhnContentSourceType_data.sql new file mode 100644 index 0000000..db3424c --- /dev/null +++ b/schema/spacewalk/common/tables/rhnContentSourceType_data.sql @@ -0,0 +1,21 @@ +-- +-- 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. +-- +-- +-- +-- + +insert into rhnContentSourceType (id, label) values +(rhn_content_source_type_id_seq.nextval, 'yum'); + diff --git a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql deleted file mode 100644 index f0b30a5..0000000 --- a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql +++ /dev/null @@ -1,61 +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. --- --- --- --- - -create table -rhnChannelContentSource -( - id number - constraint rhn_ccs_id_nn not null - constraint rhn_ccs_id_pk primary key, - channel_id number - constraint rhn_ccs_c_nn not null - constraint rhn_ccs_c_fk - references rhnChannel(id) on delete cascade, - type_id number - constraint rhn_ccs_type_nn not null - constraint rhn_ccs_type_fk - references rhnContentSourceType(id), - source_url varchar2(512) - constraint rhn_ccs_url_nn not null, - label varchar2(64) - constraint rhn_ccs_l_nn not null, - last_synced date, - created date default(sysdate) - constraint rhn_ccs_cre_nn not null, - modified date default(sysdate) - constraint rhn_ccs_mod_nn not null -) - enable row movement - ; - - -create sequence rhn_chan_content_src_id_seq start with 500; - - -create unique index rhn_ccs_uq - on rhnChannelContentSource(channel_id, type_id, source_url) - tablespace [[64k_tbs]] - ; - -/ -show errors - --- --- Revision 1.0 2009/06/26 21:54 jlsherrill --- Initial file. --- diff --git a/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql b/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql deleted file mode 100644 index 6e0ce24..0000000 --- a/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql +++ /dev/null @@ -1,48 +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. --- --- --- --- - -create table -rhnContentSourceType -( - id number - constraint rhn_cst_id_nn not null - constraint rhn_cst_id_pk primary key, - label varchar2(32) - constraint rhn_cst_label_nn not null - constraint rhn_cst_label_uq unique, - created date default(sysdate) - constraint rhn_cst_created_nn not null, - modified date default(sysdate) - constraint rhn_cst_modified_nn not null -) - enable row movement - ; - -create sequence rhn_content_source_type_id_seq start with 500; - -create index rhn_ccst_id_l_idx - on rhnContentSourceType(id,label) - tablespace [[64k_tbs]] - ; - -show errors - --- --- Revision 1.0 2002/11/13 21:50:21 jlsherrill --- initial table add --- diff --git a/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql b/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql deleted file mode 100644 index db3424c..0000000 --- a/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql +++ /dev/null @@ -1,21 +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. --- --- --- --- - -insert into rhnContentSourceType (id, label) values -(rhn_content_source_type_id_seq.nextval, 'yum'); -
commit 29c7e5ec1f630b621000151ea497ef2e0f40b519 Merge: 50bd935... a98d583... Author: Justin Sherrill jsherril@redhat.com Date: Mon Aug 3 13:12:17 2009 -0400
merge conflict
diff --cc backend/satellite_tools/Makefile index d05d130,c2c08c0..e14fdaa --- a/backend/satellite_tools/Makefile +++ b/backend/satellite_tools/Makefile @@@ -16,7 -16,14 +16,14 @@@ FILES = __init__ connection diskImportL
SCRIPTS = satellite-sync spacewalk-debug\ rhn-schema-version rhn-satellite-activate rhn-charsets \ - rhn-ssl-dbstore update-packages rhn-db-stats spacewalk-repo-sync + rhn-ssl-dbstore update-packages rhn-db-stats \ - spacewalk-report ++ spacewalk-repo-sync spacewalk-report + + SPACEWALK_SUBDIRS = reports reports/data + + SPACEWALK_FILES = reports + + SPACEWALK_REPORT_FILES = reports/data
# check if we can build man pages DOCBOOK = $(wildcard /usr/bin/docbook2man) diff --cc backend/spacewalk-backend.spec index d9d77c6,77196db..4bd53ae --- a/backend/spacewalk-backend.spec +++ b/backend/spacewalk-backend.spec @@@ -506,9 -505,9 +506,10 @@@ rm -f %{rhnconf}/rhnSecret.py %attr(755,root,root) %{_bindir}/rhn-ssl-dbstore %attr(755,root,root) %{_bindir}/satellite-sync %attr(755,root,root) %{_bindir}/spacewalk-debug + %attr(755,root,root) %{_bindir}/spacewalk-report %attr(755,root,root) %{_bindir}/rhn-satellite-exporter %attr(755,root,root) %{_bindir}/update-packages +%attr(755,root,root) %{_bindir}/spacewalk-repo-sync %attr(755,root,root) %{_bindir}/rhn-db-stats %attr(750,root,root) %{_bindir}/satpasswd %attr(750,root,root) %{_bindir}/satwho @@@ -537,10 -535,8 +538,12 @@@ %{rhnroot}/satellite_tools/disk_dumper/iss_actions.py* %{rhnroot}/satellite_tools/disk_dumper/dumper.py* %{rhnroot}/satellite_tools/disk_dumper/string_buffer.py* +%dir %{rhnroot}/satellite_tools/repo_plugins +%attr(770,root,apache) %dir %{_var}/log/rhn/reposync +%{rhnroot}/satellite_tools/repo_plugins/__init__.py* +%{rhnroot}/satellite_tools/repo_plugins/yum_src.py* + %{_prefix}/share/spacewalk/reports.py* + %{_prefix}/share/spacewalk/reports/data/* %config %attr(644,root,apache) %{rhnconf}/default/rhn_server_iss.conf %{_mandir}/man8/rhn-satellite-exporter.8* %{_mandir}/man8/rhn-charsets.8* diff --cc java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java index 275dd45,a078105..172d7e7 --- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java @@@ -17,8 -17,8 +17,9 @@@ package com.redhat.rhn.manager.channel import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelArch; import com.redhat.rhn.domain.channel.ChannelFactory; + import com.redhat.rhn.domain.common.ChecksumType; import com.redhat.rhn.domain.role.RoleFactory; +import com.redhat.rhn.domain.task.TaskFactory; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException; diff --cc java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java index 80b8e80,6447deb..9300ae9 --- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java @@@ -17,7 -17,7 +17,8 @@@ package com.redhat.rhn.manager.channel
import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.task.TaskFactory; + import com.redhat.rhn.domain.common.ChecksumType; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException; import com.redhat.rhn.frontend.xmlrpc.InvalidParentChannelException;
commit 50bd93570a4840063d2d42ef92097d4685fb4827 Author: Justin Sherrill jsherril@redhat.com Date: Mon Aug 3 13:02:33 2009 -0400
adding newline to error message output
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 37d01bb..80f830e 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -210,7 +210,7 @@ class RepoSync:
def error_msg(self, message): rhnLog.log_clean(0, message) - sys.stderr.write(message) + sys.stderr.write(str(message) + "\n")
def log_msg(self, message): rhnLog.log_clean(0, message)
commit c4f32e97c88e5d175f365ed65d24b76391d669a2 Author: Justin Sherrill jsherril@redhat.com Date: Mon Aug 3 12:54:57 2009 -0400
fixing small method call in reposync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 97ec97e..37d01bb 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -56,7 +56,7 @@ class RepoSync: self.error_msg("--url must be specified") if not options.type: quit = True - self.error_message("--type must be specified") + self.error_msg("--type must be specified") if not options.channel_label: quit = True self.error_msg("--channel must be specified")
commit 10c32328e6ac2f63b93f5e815179a57a10439be4 Author: Justin Sherrill jsherril@redhat.com Date: Mon Aug 3 12:49:11 2009 -0400
fixing specfile to create directory for reposync
diff --git a/backend/Makefile.backend b/backend/Makefile.backend index 73ca5c7..378723e 100644 --- a/backend/Makefile.backend +++ b/backend/Makefile.backend @@ -7,7 +7,7 @@ CONF_DIRS = apache-conf httpd-conf rhn-conf logrotate
# We look for config files in "well known" locations (rhn-conf, # httpd-conf, logrotate) -EXTRA_DIRS = /var/log/rhn /var/cache/rhn +EXTRA_DIRS = /var/log/rhn /var/log/rhn/reposync /var/cache/rhn
all :: all-code all-conf
commit b2066fa2460ae2ec32a8a24958e155ce8420d4e0 Author: Justin Sherrill jsherril@redhat.com Date: Mon Aug 3 12:43:11 2009 -0400
fixing small whitespace error with reposync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 6d03b60..97ec97e 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -76,8 +76,7 @@ class RepoSync: self.repo_label = options.label self.channel = self.load_channel()
- if not self.channel or not \ - rhnChannel.isCustomChannel(self.channel['id']): + if not self.channel or not rhnChannel.isCustomChannel(self.channel['id']): print "Channel does not exist or is not custom" sys.exit(1)
commit c03775d9bcb4e6387e6f04e1398c05f0128252c9 Author: Justin Sherrill jsherril@redhat.com Date: Mon Aug 3 12:41:00 2009 -0400
adding better logging for spacewalk-repo-sync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 9418a78..6d03b60 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -13,7 +13,7 @@ # granted to use or replicate Red Hat trademarks that are incorporated # in this software or its documentation. # -import sys, os +import sys, os, time from optparse import OptionParser from common import rhnLib from server import rhnPackage, rhnSQL, rhnChannel, rhnPackageUpload @@ -23,6 +23,9 @@ from server.importlib.importLib import IncompletePackage from server.importlib.backendOracle import OracleBackend from server.importlib.packageImport import ChannelPackageSubscription
+ +default_log_location = '/var/log/rhn/reposync/' + class RepoSync: parser = None type = None @@ -39,30 +42,32 @@ class RepoSync: rhnSQL.initDB(db_string) (options, args) = self.process_args()
+ log_filename = 'reposync.log' + if options.channel_label and options.label: + date = time.localtime() + datestr = '%s.%s.%s-%s:%s:%s' % (date.tm_year, date.tm_mon, date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec) + log_filename = options.channel_label + '-' + options.label + '-' + datestr + '.log' + + rhnLog.initLOG(default_log_location + log_filename)
quit = False if not options.url: quit = True - print("--url must be specified") + self.error_msg("--url must be specified") if not options.type: quit = True - print("--type must be specified") + self.error_message("--type must be specified") if not options.channel_label: quit = True - print("--channel must be specified") + self.error_msg("--channel must be specified") if not options.label: quit = True - print("--label must be specified") - - self.log_file = options.logfile - if self.log_file: - rhnLog.initLOG(self.log_file) - - self.error_msg(str(sys.argv)) + self.error_msg("--label must be specified")
if quit: sys.exit(1)
+ self.log_msg(str(sys.argv))
self.type = options.type self.url = options.url @@ -70,9 +75,8 @@ class RepoSync: self.fail = options.fail self.repo_label = options.label self.channel = self.load_channel() - self.log_file = options.logfile
- if not self.channel or not \ + if not self.channel or not \ rhnChannel.isCustomChannel(self.channel['id']): print "Channel does not exist or is not custom" sys.exit(1) @@ -89,7 +93,6 @@ class RepoSync: self.parser.add_option('-t', '--type', action='store', dest='type', help='The type of repo, currently only "yum" is supported') self.parser.add_option('-l', '--label', action='store', dest='label', help='A friendly label to refer to the repo') self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation") - self.parser.add_option('-g', '--logfile', action='store', dest='logfile', help="The log file to log to. Default is to stderr and stdout.") return self.parser.parse_args()
def load_plugin(self): @@ -101,7 +104,7 @@ class RepoSync: def import_packages(self, packages): to_link = [] to_download = [] - self.print_msg("Repo " + self.url + " has " + str(len(packages)) + ".") + self.print_msg("Repo " + self.url + " has " + str(len(packages)) + " packages.") for pack in packages: pid = None if pack.checksums.has_key('md5sum'): @@ -202,16 +205,17 @@ class RepoSync:
def print_msg(self, message): - if self.log_file: - rhnLog.log_clean(0, message) + rhnLog.log_clean(0, message) print message
def error_msg(self, message): - if self.log_file: - rhnLog.log_clean(0, message) + rhnLog.log_clean(0, message) sys.stderr.write(message)
+ def log_msg(self, message): + rhnLog.log_clean(0, message) + class ContentPackage:
#map of checksums. Valid keys are 'md5sum' & 'sha256' diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec index 1fe9866..d9d77c6 100644 --- a/backend/spacewalk-backend.spec +++ b/backend/spacewalk-backend.spec @@ -538,6 +538,7 @@ rm -f %{rhnconf}/rhnSecret.py* %{rhnroot}/satellite_tools/disk_dumper/dumper.py* %{rhnroot}/satellite_tools/disk_dumper/string_buffer.py* %dir %{rhnroot}/satellite_tools/repo_plugins +%attr(770,root,apache) %dir %{_var}/log/rhn/reposync %{rhnroot}/satellite_tools/repo_plugins/__init__.py* %{rhnroot}/satellite_tools/repo_plugins/yum_src.py* %config %attr(644,root,apache) %{rhnconf}/default/rhn_server_iss.conf
commit d9321c436afdf239f19d8df66d447217806496ba Author: Justin Sherrill jsherril@redhat.com Date: Fri Jul 31 14:57:42 2009 -0400
check style fixes
diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.java b/java/code/src/com/redhat/rhn/domain/channel/Channel.java index e61da3f..65b411d 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@ -818,6 +818,7 @@ public class Channel extends BaseDomainHelper implements Comparable { * Set the yum content source, if one is already set, it will be replaced * if null or '' is passed in, all content sources will be removed. * @param url the url of the yum repo + * @param labelIn the label of the content source */ public void setYumContentSource(String url, String labelIn) { if (StringUtils.isEmpty(url)) { diff --git a/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java b/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java index aa75626..af74c20 100644 --- a/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java +++ b/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java @@ -68,9 +68,9 @@ public class TaskFactory extends HibernateFactory { }
/** - * - * @param name - * @return + * list All tasks with the given name + * @param name the name of the task + * @return List of tasks */ public static List<Task> listTasks(String name) { Session session = null; @@ -86,8 +86,8 @@ public class TaskFactory extends HibernateFactory { }
/** - * - * @param task + * Remove a task from teh database + * @param task the task to remove */ public static void removeTask(Task task) { TaskFactory.getSession().delete(task); diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index 40a4c2c..f26278b 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -27,7 +27,6 @@ import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException;
import java.io.IOException; -import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -66,8 +65,8 @@ public class RepoSyncTask implements Job { for (Task task : TaskFactory.listTasks(DISPLAY_NAME)) { ContentSource src = ChannelFactory.lookupContentSource(task.getData()); if (log.isInfoEnabled()) { - log.info("Syncing repo " + src.getSourceUrl() + " to channel " - + src.getChannel().getLabel()); + log.info("Syncing repo " + src.getSourceUrl() + " to channel " + + src.getChannel().getLabel()); } if (src == null) { log.error("Content Source could not be found: " + task.getData());
commit cb96846c44dd4a9edb6bebf809043f4b38206d6f Author: Justin Sherrill jsherril@redhat.com Date: Thu Jul 30 18:11:31 2009 -0400
some repo sync task fixes
diff --git a/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java b/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java index 4160ba1..1002d2f 100644 --- a/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java +++ b/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java @@ -145,7 +145,8 @@ public class ConfigDefaults { public static final String VIRT_DISK = "kickstart.virt_disk_size_gb"; public static final String KICKSTART_NETWORK_INTERFACE = "kickstart.default_interface";
- public static final String SPACEWALK_REPO_SYNC_PATH = "spacewalk_repo_sync_path"; + public static final String SPACEWALK_REPOSYNC_PATH = "spacewalk_reposync_path"; + public static final String SPACEWALK_REPOSYNC_LOG_FILE = "spacewalk_reposync_logfile";
private ConfigDefaults() { } diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java index 6f913d1..ba3ae7d 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java @@ -335,7 +335,9 @@ public class EditChannelAction extends RhnAction implements Listable { ucc.setAccess((String)form.get("org_sharing")); ucc.setYumUrl((String) form.getString("yum_repo")); ucc.setRepoLabel((String) form.getString("repo_label")); - ucc.setSyncRepo((Boolean)form.get("sync_repo")); + if (form.get("sync_repo") != null) { + ucc.setSyncRepo((Boolean)form.get("sync_repo")); + }
String parent = (String)form.get("parent"); if (parent == null || parent.equals("")) { @@ -408,7 +410,9 @@ public class EditChannelAction extends RhnAction implements Listable { ccc.setAccess((String)form.get("org_sharing")); ccc.setYumUrl((String) form.getString("yum_repo")); ccc.setRepoLabel((String) form.getString("repo_label")); - ccc.setSyncRepo((Boolean)form.get("sync_repo")); + if (form.get("sync_repo") != null) { + ccc.setSyncRepo((Boolean)form.get("sync_repo")); + }
String parent = (String)form.get("parent"); if (parent == null || parent.equals("")) { diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index 98c3272..40a4c2c 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -95,18 +95,19 @@ public class RepoSyncTask implements Job {
private static List<String> getSyncCommand(ContentSource src) { List<String> cmd = new ArrayList<String>(); - cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPO_SYNC_PATH, + cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPOSYNC_PATH, "/usr/bin/spacewalk-repo-sync")); - cmd.add("-c"); + cmd.add("--channel"); cmd.add(src.getChannel().getLabel()); - cmd.add("-u"); + cmd.add("--url"); cmd.add(src.getSourceUrl()); - cmd.add("-t"); + cmd.add("--type"); cmd.add(src.getType().getLabel()); - cmd.add("-l"); + cmd.add("--label"); cmd.add(src.getLabel()); - cmd.add("-g"); - cmd.add("/var/log/rhn/rhn_reposync.log"); + cmd.add("--logfile"); + cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPOSYNC_LOG_FILE, + "/var/log/rhn/rhn_reposync.log")); return cmd; }
commit 0c0b1227c5e534232f49d435ff7e8f7f0b0c1938 Author: Justin Sherrill jsherril@redhat.com Date: Thu Jul 30 17:39:06 2009 -0400
updating task to include log file and more logging
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index fdbe9e4..98c3272 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -27,6 +27,7 @@ import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException;
import java.io.IOException; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -63,23 +64,28 @@ public class RepoSyncTask implements Job { throws JobExecutionException {
for (Task task : TaskFactory.listTasks(DISPLAY_NAME)) { - ContentSource src = ChannelFactory.lookupContentSource(task.getData()); + if (log.isInfoEnabled()) { + log.info("Syncing repo " + src.getSourceUrl() + " to channel " + + src.getChannel().getLabel()); + } if (src == null) { log.error("Content Source could not be found: " + task.getData()); continue; }
try { - Process p = Runtime.getRuntime().exec( - (String[]) getSyncCommand(src).toArray()); + getSyncCommand(src).toArray(new String[0])); p.waitFor(); + } catch (IOException e) { + log.fatal(e.getMessage()); e.printStackTrace(); } catch (InterruptedException e) { + log.fatal(e.getMessage()); e.printStackTrace(); } src.setLastSynced(new Date()); @@ -90,7 +96,7 @@ public class RepoSyncTask implements Job { private static List<String> getSyncCommand(ContentSource src) { List<String> cmd = new ArrayList<String>(); cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPO_SYNC_PATH, - "/usr/sbin/spacewalk-repo-sync")); + "/usr/bin/spacewalk-repo-sync")); cmd.add("-c"); cmd.add(src.getChannel().getLabel()); cmd.add("-u"); @@ -99,6 +105,8 @@ public class RepoSyncTask implements Job { cmd.add(src.getType().getLabel()); cmd.add("-l"); cmd.add(src.getLabel()); + cmd.add("-g"); + cmd.add("/var/log/rhn/rhn_reposync.log"); return cmd; }
commit 57112cb536f9142d35aa1030b41cb27b34863627 Author: Justin Sherrill jsherril@redhat.com Date: Thu Jul 30 17:38:38 2009 -0400
making the logging a bit cleaner
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 053a8c4..9418a78 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -203,13 +203,13 @@ class RepoSync:
def print_msg(self, message): if self.log_file: - rhnLog.log_debug(0, message) + rhnLog.log_clean(0, message) print message
def error_msg(self, message): if self.log_file: - rhnLog.log_debug(0, message) + rhnLog.log_clean(0, message) sys.stderr.write(message)
class ContentPackage:
commit 2280dc149ddc31deca55e97c8bd1b7393e0ccf20 Author: Justin Sherrill jsherril@redhat.com Date: Thu Jul 30 16:09:15 2009 -0400
fixing some import things to actually work on an installed system
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py b/backend/satellite_tools/repo_plugins/yum_src.py index 77c6f57..a9c0ad6 100644 --- a/backend/satellite_tools/repo_plugins/yum_src.py +++ b/backend/satellite_tools/repo_plugins/yum_src.py @@ -16,7 +16,7 @@ import yum import shutil from yum import config -from reposync import ContentPackage +from satellite_tools.reposync import ContentPackage
class ContentSource: url = None diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index e5074b0..053a8c4 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -39,6 +39,7 @@ class RepoSync: rhnSQL.initDB(db_string) (options, args) = self.process_args()
+ quit = False if not options.url: quit = True @@ -53,6 +54,12 @@ class RepoSync: quit = True print("--label must be specified")
+ self.log_file = options.logfile + if self.log_file: + rhnLog.initLOG(self.log_file) + + self.error_msg(str(sys.argv)) + if quit: sys.exit(1)
@@ -71,8 +78,6 @@ class RepoSync: sys.exit(1)
- if self.log_file: - rhnLog.initLOG(self.log_file)
self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label) self.import_packages(self.plugin.list_packages()) @@ -88,10 +93,10 @@ class RepoSync: return self.parser.parse_args()
def load_plugin(self): - sys.path.append("repo_plugins") name = self.type + "_src" - mod = __import__(name) - return getattr(mod, "ContentSource") + mod = __import__('satellite_tools.repo_plugins', globals(), locals(), [name]) + submod = getattr(mod, name) + return getattr(submod, "ContentSource")
def import_packages(self, packages): to_link = []
commit f842a5b42266b3ad09929a9b5d524cbd65470bb7 Author: Justin Sherrill jsherril@redhat.com Date: Thu Jul 30 13:23:47 2009 -0400
adding sync repo option to channel details, and taskomatic task
diff --git a/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java b/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java index d1e5065..4160ba1 100644 --- a/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java +++ b/java/code/src/com/redhat/rhn/common/conf/ConfigDefaults.java @@ -145,6 +145,8 @@ public class ConfigDefaults { public static final String VIRT_DISK = "kickstart.virt_disk_size_gb"; public static final String KICKSTART_NETWORK_INTERFACE = "kickstart.default_interface";
+ public static final String SPACEWALK_REPO_SYNC_PATH = "spacewalk_repo_sync_path"; + private ConfigDefaults() { }
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java index baa0737..6f913d1 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java @@ -335,6 +335,7 @@ public class EditChannelAction extends RhnAction implements Listable { ucc.setAccess((String)form.get("org_sharing")); ucc.setYumUrl((String) form.getString("yum_repo")); ucc.setRepoLabel((String) form.getString("repo_label")); + ucc.setSyncRepo((Boolean)form.get("sync_repo"));
String parent = (String)form.get("parent"); if (parent == null || parent.equals("")) { @@ -407,6 +408,7 @@ public class EditChannelAction extends RhnAction implements Listable { ccc.setAccess((String)form.get("org_sharing")); ccc.setYumUrl((String) form.getString("yum_repo")); ccc.setRepoLabel((String) form.getString("repo_label")); + ccc.setSyncRepo((Boolean)form.get("sync_repo"));
String parent = (String)form.get("parent"); if (parent == null || parent.equals("")) { diff --git a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java index 0ea6469..275dd45 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java @@ -18,12 +18,14 @@ import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelArch; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.role.RoleFactory; +import com.redhat.rhn.domain.task.TaskFactory; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException; import com.redhat.rhn.frontend.xmlrpc.InvalidGPGKeyException; import com.redhat.rhn.frontend.xmlrpc.InvalidGPGUrlException; import com.redhat.rhn.frontend.xmlrpc.InvalidParentChannelException; +import com.redhat.rhn.taskomatic.task.RepoSyncTask;
import org.apache.commons.lang.StringUtils;
@@ -69,6 +71,7 @@ public class CreateChannelCommand { protected String access = Channel.PRIVATE; protected String yumUrl; protected String repoLabel; + protected boolean syncRepo = false;
@@ -261,6 +264,7 @@ public class CreateChannelCommand { c.setMaintainerEmail(maintainerEmail); c.setMaintainerPhone(maintainerPhone); c.setSupportPolicy(supportPolicy); + c.setYumContentSource(yumUrl, repoLabel);
// handles either parent id or label setParentChannel(c, user, parentLabel, parentId); @@ -271,9 +275,11 @@ public class CreateChannelCommand { ChannelFactory.save(c);
ChannelFactory.refreshNewestPackageCache(c, WEB_CHANNEL_CREATED); - - c.setYumContentSource(yumUrl, repoLabel);
+ if (syncRepo && !c.getContentSources().isEmpty()) { + TaskFactory.createTask(user.getOrg(), RepoSyncTask.DISPLAY_NAME, + c.getContentSources().iterator().next().getId()); + }
return c; } @@ -449,5 +455,13 @@ public class CreateChannelCommand { public void setRepoLabel(String repoLabelIn) { this.repoLabel = repoLabelIn; } + + + /** + * @param syncRepoIn The syncRepo to set. + */ + public void setSyncRepo(boolean syncRepoIn) { + this.syncRepo = syncRepoIn; + }
} diff --git a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java index 79764aa..80b8e80 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java @@ -17,9 +17,11 @@ package com.redhat.rhn.manager.channel;
import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.task.TaskFactory; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException; import com.redhat.rhn.frontend.xmlrpc.InvalidParentChannelException; +import com.redhat.rhn.taskomatic.task.RepoSyncTask;
/** * UpdateChannelCommand - command to create a new channel. @@ -77,10 +79,12 @@ public class UpdateChannelCommand extends CreateChannelCommand { c.setMaintainerEmail(maintainerEmail); c.setMaintainerPhone(maintainerPhone); c.setSupportPolicy(supportPolicy); - - c.setYumContentSource(yumUrl, repoLabel);
+ if (syncRepo && !c.getContentSources().isEmpty()) { + TaskFactory.createTask(user.getOrg(), RepoSyncTask.DISPLAY_NAME, + c.getContentSources().iterator().next().getId()); + }
// need to save before calling stored proc below ChannelFactory.save(c); diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index ae382a5..fdbe9e4 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -14,6 +14,8 @@ */ package com.redhat.rhn.taskomatic.task;
+import com.redhat.rhn.common.conf.Config; +import com.redhat.rhn.common.conf.ConfigDefaults; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.task.Task; @@ -29,6 +31,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List;
+ /** * Repo Sync * Used for syncing repos (like yum repos) to a channel @@ -59,7 +62,7 @@ public class RepoSyncTask implements Job { public void execute(JobExecutionContext context) throws JobExecutionException {
- for (Task task : TaskFactory.listTasks("repo_sync")) { + for (Task task : TaskFactory.listTasks(DISPLAY_NAME)) {
ContentSource src = ChannelFactory.lookupContentSource(task.getData()); if (src == null) { @@ -68,10 +71,16 @@ public class RepoSyncTask implements Job { }
try { - Process p = Runtime.getRuntime().exec(""); + + Process p = Runtime.getRuntime().exec( + (String[]) getSyncCommand(src).toArray()); + p.waitFor(); } catch (IOException e) { - + e.printStackTrace(); + } + catch (InterruptedException e) { + e.printStackTrace(); } src.setLastSynced(new Date()); TaskFactory.removeTask(task); @@ -80,13 +89,16 @@ public class RepoSyncTask implements Job {
private static List<String> getSyncCommand(ContentSource src) { List<String> cmd = new ArrayList<String>(); - cmd.add("/usr/sbin/spacewalk-repo-sync"); + cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPO_SYNC_PATH, + "/usr/sbin/spacewalk-repo-sync")); cmd.add("-c"); cmd.add(src.getChannel().getLabel()); cmd.add("-u"); cmd.add(src.getSourceUrl()); cmd.add("-t"); cmd.add(src.getType().getLabel()); + cmd.add("-l"); + cmd.add(src.getLabel()); return cmd; }
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp index adda2fb..ee51f22 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp @@ -120,6 +120,14 @@ <html:text property="yum_repo" maxlength="512" size="64" /> </td> </tr> + <tr> + <th> + <bean:message key="channel.edit.jsp.repolabel"/>: + </th> + <td> + <html:text property="repo_label" maxlength="64" size="20" /> + </td> + </tr> <c:if test='${not empty param.cid}'> <tr> <th> @@ -132,14 +140,6 @@ </c:if> <tr> <th> - <bean:message key="channel.edit.jsp.repolabel"/>: - </th> - <td> - <html:text property="repo_label" maxlength="64" size="20" /> - </td> - </tr> - <tr> - <th> <bean:message key="channel.edit.jsp.sync"/>: </th> <td>
commit a75f22ad634db6631b56582018a81d723a61c257 Author: Justin Sherrill jsherril@redhat.com Date: Thu Jul 30 13:21:41 2009 -0400
adding logging, cache clearing, and a few fixes to reposync
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py b/backend/satellite_tools/repo_plugins/yum_src.py index fb3859f..77c6f57 100644 --- a/backend/satellite_tools/repo_plugins/yum_src.py +++ b/backend/satellite_tools/repo_plugins/yum_src.py @@ -14,6 +14,7 @@ # in this software or its documentation. # import yum +import shutil from yum import config from reposync import ContentPackage
@@ -21,10 +22,11 @@ class ContentSource: url = None name = None repo = None - + cache_dir = '/var/cache/rhn/reposync/' def __init__(self, url, name): self.url = url self.name = name + self._clean_cache(self.cache_dir + name)
def list_packages(self): """ list packages""" @@ -33,8 +35,8 @@ class ContentSource: repo.cache = 0 repo.metadata_expire = 0 repo.baseurl = [self.url] - repo.basecachedir = '/var/cache/rhn/reposync/' -# repo.cachedir = '/var/cache/rhn/reposync/' + repo.basecachedir = self.cache_dir + repo.baseurlSetup() repo.setup(False) sack = repo.getPackageSack() sack.populate(repo, 'metadata', None, 0) @@ -52,4 +54,11 @@ class ContentSource:
def get_package(self, package): """ get package """ - return self.repo.getPackage(package.unique_id) + check = (self.verify_pkg, (package.unique_id ,1), {}) + return self.repo.getPackage(package.unique_id, checkfunc=check) + + def verify_pkg(self, fo, pkg, fail): + return pkg.verifyLocalPkg() + + def _clean_cache(self, directory): + shutil.rmtree(directory, True) diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 0fd24d2..e5074b0 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -17,7 +17,8 @@ import sys, os from optparse import OptionParser from common import rhnLib from server import rhnPackage, rhnSQL, rhnChannel, rhnPackageUpload -from common import CFG, initCFG, rhn_rpm +from common import CFG, initCFG, rhn_rpm, rhnLog, fetchTraceback +from common.rhn_mpm import InvalidPackageError from server.importlib.importLib import IncompletePackage from server.importlib.backendOracle import OracleBackend from server.importlib.packageImport import ChannelPackageSubscription @@ -38,15 +39,22 @@ class RepoSync: rhnSQL.initDB(db_string) (options, args) = self.process_args()
- + quit = False if not options.url: + quit = True print("--url must be specified") if not options.type: + quit = True print("--type must be specified") if not options.channel_label: + quit = True print("--channel must be specified") if not options.label: - print("--label must be specified") + quit = True + print("--label must be specified") + + if quit: + sys.exit(1)
self.type = options.type @@ -55,12 +63,17 @@ class RepoSync: self.fail = options.fail self.repo_label = options.label self.channel = self.load_channel() - + self.log_file = options.logfile + if not self.channel or not \ rhnChannel.isCustomChannel(self.channel['id']): print "Channel does not exist or is not custom" sys.exit(1)
+ + if self.log_file: + rhnLog.initLOG(self.log_file) + self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label) self.import_packages(self.plugin.list_packages())
@@ -71,6 +84,7 @@ class RepoSync: self.parser.add_option('-t', '--type', action='store', dest='type', help='The type of repo, currently only "yum" is supported') self.parser.add_option('-l', '--label', action='store', dest='label', help='A friendly label to refer to the repo') self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation") + self.parser.add_option('-g', '--logfile', action='store', dest='logfile', help="The log file to log to. Default is to stderr and stdout.") return self.parser.parse_args()
def load_plugin(self): @@ -82,6 +96,7 @@ class RepoSync: def import_packages(self, packages): to_link = [] to_download = [] + self.print_msg("Repo " + self.url + " has " + str(len(packages)) + ".") for pack in packages: pid = None if pack.checksums.has_key('md5sum'): @@ -101,7 +116,7 @@ class RepoSync: for (index, pack) in enumerate(to_download): """download each package""" try: - print(str(index) + "/" + str(len(to_download)) + " : "+ \ + self.print_msg(str(index+1) + "/" + str(len(to_download)) + " : "+ \ pack.getNVREA()) path = self.plugin.get_package(pack) md5 = rhnLib.getFileMD5(filename=path) @@ -112,9 +127,13 @@ class RepoSync: self.associate_package(pack, md5) else: to_link.append(pack) + if self.url.find("file://") < 0: + os.remove(path) + except KeyboardInterrupt: raise except: + self.error_msg("ERROR" + fetchTraceback()) if self.fail: raise continue @@ -124,6 +143,7 @@ class RepoSync: except KeyboardInterrupt: raise except: + self.error_msg(fetchTraceback()) if self.fail: raise continue @@ -142,9 +162,6 @@ class RepoSync: relative_path=rel_package_path, org_id=self.channel['org_id']) temp_file.close() - if self.url.find("file://") < 0: - os.remove(path) -
def associate_package(self, pack, md5sum): caller = "server.app.yumreposync" @@ -154,32 +171,42 @@ class RepoSync: package['name'] = pack.name package['version'] = pack.version package['release'] = pack.release - if pack.epoch == 0: - package['epoch'] = "" - else: - package['epoch'] = pack.epoch + package['epoch'] = pack.epoch package['arch'] = pack.arch package['md5sum'] = md5sum package['channels'] = [{'label':self.channel_label, 'id':self.channel['id']}] package['org_id'] = self.channel['org_id'] - try: - importer = ChannelPackageSubscription( - [IncompletePackage().populate(package)], - backend, caller=caller) - importer.run() + self._importer_run(package, caller, backend) except: - package['epoch'] = '0' + package['epoch'] = '' + self._importer_run(package, caller, backend) + + backend.commit() + + def _importer_run(self, package, caller, backend): importer = ChannelPackageSubscription( - [IncompletePackage().populate(package)], + [IncompletePackage().populate(package)], backend, caller=caller) importer.run() - backend.commit() +
def load_channel(self): return rhnChannel.channel_info(self.channel_label)
+ + def print_msg(self, message): + if self.log_file: + rhnLog.log_debug(0, message) + print message + + + def error_msg(self, message): + if self.log_file: + rhnLog.log_debug(0, message) + sys.stderr.write(message) + class ContentPackage:
#map of checksums. Valid keys are 'md5sum' & 'sha256' @@ -199,9 +226,11 @@ class ContentPackage: self.version = version self.release = release self.arch = arch + self.epoch = epoch
def getNVREA(self): if self.epoch: return self.name + '-' + self.version + '-' + self.release + '-' + self.epoch + '.' + self.arch else: return self.name + '-' + self.version + '-' + self.release + '.' + self.arch +
commit 27676a0db884611b0326b797b6fd6b97e7f33300 Author: Pradeep Kilambi pkilambi@redhat.com Date: Wed Jul 29 16:50:13 2009 -0400
adding makefile to repo_plugins
diff --git a/backend/satellite_tools/repo_plugins/Makefile b/backend/satellite_tools/repo_plugins/Makefile new file mode 100644 index 0000000..556fb17 --- /dev/null +++ b/backend/satellite_tools/repo_plugins/Makefile @@ -0,0 +1,27 @@ +# Makefile for repo sync plugins +# +# $Id: Makefile $ +# +# Copyright (c) 2009 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. +# +# + +TOP = ../.. + +# Specific stuff +SUBDIR = satellite_tools/repo_plugins +FILES = __init__ yum_src + +include $(TOP)/Makefile.defs + diff --git a/backend/satellite_tools/spacewalk-debug.8 b/backend/satellite_tools/spacewalk-debug.8 index 0db3791..2a63608 100644 --- a/backend/satellite_tools/spacewalk-debug.8 +++ b/backend/satellite_tools/spacewalk-debug.8 @@ -1,19 +1,14 @@ -." This manpage has been automatically generated by docbook2man -." from a DocBook document. This tool can be found at: -." http://shell.ipoline.com/~elmert/comp/docbook2X/ -." Please send any bug reports, improvements, comments, patches, -." etc. to Steve Cheng steve@ggi-project.org. -.TH "SPACEWALK-DEBUG" "8" "11 June 2008" "Version 3.6" "" - +.\" auto-generated by docbook2man-spec $Revision: 1.1 $ +.TH "SPACEWALK-DEBUG" "8" "29 July 2009" "Version 3.6" "" .SH NAME -spacewalk-debug - Debug utility that packages log files and relevant debug information needed for full diagnosis of Spacewalk issues. +spacewalk-debug - Debug utility that packages log files and relevant debug information needed for full diagnosis of Spacewalk Server issues. .SH SYNOPSIS - +.sp .nf - - + +.sp \fBspacewalk-debug\fR - +.sp .fi .SH "DESCRIPTION" .PP @@ -45,4 +40,5 @@ satellite-sync(8) .SH "AUTHORS"
Todd Warner taw@redhat.com + Pradeep Kilambi pkilambi@redhat.com
commit 018fcfd031374ef91fbc54d27031e695511a09e4 Author: Pradeep Kilambi pkilambi@redhat.com Date: Mon Jul 27 12:51:29 2009 -0400
updating spacewalk backend spec file with reposync stuff
diff --git a/backend/server/Makefile b/backend/server/Makefile index fbbad78..776fb63 100644 --- a/backend/server/Makefile +++ b/backend/server/Makefile @@ -18,8 +18,8 @@ FILES = __init__ \ rhnHandler rhnImport rhnMapping rhnLib rhnPackage \ rhnItem \ rhnKickstart \ - rhnPackageUpload rhnRepository rhnSession rhnUser \ - rhnVirtualization taskomatic + rhnPackageUpload basePackageUpload rhnRepository \ + rhnSession rhnUser rhnVirtualization taskomatic SUBDIRS = rhnSQL rhnServer action \ handlers importlib action_extra_data \ config_common repomd diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec index 4037804..1fe9866 100644 --- a/backend/spacewalk-backend.spec +++ b/backend/spacewalk-backend.spec @@ -325,6 +325,7 @@ rm -f %{rhnconf}/rhnSecret.py* %{rhnroot}/server/rhnItem.py* %{rhnroot}/server/rhnPackage.py* %{rhnroot}/server/rhnPackageUpload.py* +%{rhnroot}/server/basePackageUpload.py* %{rhnroot}/server/rhnHandler.py* %{rhnroot}/server/rhnImport.py* %{rhnroot}/server/rhnLib.py* @@ -507,6 +508,7 @@ rm -f %{rhnconf}/rhnSecret.py* %attr(755,root,root) %{_bindir}/spacewalk-debug %attr(755,root,root) %{_bindir}/rhn-satellite-exporter %attr(755,root,root) %{_bindir}/update-packages +%attr(755,root,root) %{_bindir}/spacewalk-repo-sync %attr(755,root,root) %{_bindir}/rhn-db-stats %attr(750,root,root) %{_bindir}/satpasswd %attr(750,root,root) %{_bindir}/satwho @@ -525,6 +527,7 @@ rm -f %{rhnconf}/rhnSecret.py* %{rhnroot}/satellite_tools/rhn_ssl_dbstore.py* %{rhnroot}/satellite_tools/xmlWireSource.py* %{rhnroot}/satellite_tools/updatePackages.py* +%{rhnroot}/satellite_tools/reposync.py* %dir %{rhnroot}/satellite_tools/disk_dumper %{rhnroot}/satellite_tools/disk_dumper/__init__.py* %{rhnroot}/satellite_tools/disk_dumper/iss.py* @@ -534,6 +537,9 @@ rm -f %{rhnconf}/rhnSecret.py* %{rhnroot}/satellite_tools/disk_dumper/iss_actions.py* %{rhnroot}/satellite_tools/disk_dumper/dumper.py* %{rhnroot}/satellite_tools/disk_dumper/string_buffer.py* +%dir %{rhnroot}/satellite_tools/repo_plugins +%{rhnroot}/satellite_tools/repo_plugins/__init__.py* +%{rhnroot}/satellite_tools/repo_plugins/yum_src.py* %config %attr(644,root,apache) %{rhnconf}/default/rhn_server_iss.conf %{_mandir}/man8/rhn-satellite-exporter.8* %{_mandir}/man8/rhn-charsets.8*
commit 629d5ca6cf235df83d60ca0fbaf17055624308b9 Author: Pradeep Kilambi pkilambi@redhat.com Date: Mon Jul 27 12:44:23 2009 -0400
updating Makefile with reposync files
diff --git a/backend/satellite_tools/Makefile b/backend/satellite_tools/Makefile index 9c02dce..d05d130 100644 --- a/backend/satellite_tools/Makefile +++ b/backend/satellite_tools/Makefile @@ -6,17 +6,17 @@ TOP = ..
# Specific stuff SUBDIR = satellite_tools -SUBDIRS = exporter disk_dumper accounts +SUBDIRS = exporter disk_dumper accounts repo_plugins FILES = __init__ connection diskImportLib messages \ progress_bar req_channels satCerts satrm satsync syncCache \ sync_handlers rhn-entitlement-report\ syncLib SequenceServer xmlDiskDumper xmlDiskSource \ xmlSource xmlWireSource rhn_satellite_activate rhn_ssl_dbstore \ - satComputePkgHeaders updatePackages + satComputePkgHeaders updatePackages reposync
SCRIPTS = satellite-sync spacewalk-debug\ rhn-schema-version rhn-satellite-activate rhn-charsets \ - rhn-ssl-dbstore update-packages rhn-db-stats + rhn-ssl-dbstore update-packages rhn-db-stats spacewalk-repo-sync
# check if we can build man pages DOCBOOK = $(wildcard /usr/bin/docbook2man) diff --git a/backend/satellite_tools/repo_plugins/__init__.py b/backend/satellite_tools/repo_plugins/__init__.py new file mode 100644 index 0000000..fb3600e --- /dev/null +++ b/backend/satellite_tools/repo_plugins/__init__.py @@ -0,0 +1,15 @@ +# +# 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. +# +
commit 353e94dfc2ce49c6cd0ba61e4bb67ec901767884 Author: Pradeep Kilambi pkilambi@redhat.com Date: Mon Jul 27 12:39:16 2009 -0400
some clean up on repo sync stuff
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py b/backend/satellite_tools/repo_plugins/yum_src.py index fd39518..fb3859f 100644 --- a/backend/satellite_tools/repo_plugins/yum_src.py +++ b/backend/satellite_tools/repo_plugins/yum_src.py @@ -16,8 +16,8 @@ import yum from yum import config from reposync import ContentPackage -class ContentSource:
+class ContentSource: url = None name = None repo = None @@ -31,7 +31,7 @@ class ContentSource: repo = yum.yumRepo.YumRepository(self.name) self.repo = repo repo.cache = 0 - repo.metadata_expire = 5 + repo.metadata_expire = 0 repo.baseurl = [self.url] repo.basecachedir = '/var/cache/rhn/reposync/' # repo.cachedir = '/var/cache/rhn/reposync/' @@ -42,7 +42,8 @@ class ContentSource: to_return = [] for pack in list: new_pack = ContentPackage() - new_pack.setNVREA(pack.name, pack.version, pack.release, pack.epoch, pack.arch) + new_pack.setNVREA(pack.name, pack.version, pack.release, + pack.epoch, pack.arch) new_pack.unique_id = pack for cs in pack.checksums: new_pack.checksums[cs[0]] = cs[1] @@ -52,5 +53,3 @@ class ContentSource: def get_package(self, package): """ get package """ return self.repo.getPackage(package.unique_id) - - diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 5abcc1c..0fd24d2 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -23,8 +23,6 @@ from server.importlib.backendOracle import OracleBackend from server.importlib.packageImport import ChannelPackageSubscription
class RepoSync: - - parser = None type = None url = None @@ -34,7 +32,6 @@ class RepoSync: fail = False repo_label = None
- def main(self): initCFG('server') db_string = CFG.DEFAULT_DB #"rhnsat/rhnsat@rhnsat" @@ -59,15 +56,14 @@ class RepoSync: self.repo_label = options.label self.channel = self.load_channel()
- if not self.channel or not rhnChannel.isCustomChannel(self.channel['id']): + if not self.channel or not \ + rhnChannel.isCustomChannel(self.channel['id']): print "Channel does not exist or is not custom" sys.exit(1)
self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label) self.import_packages(self.plugin.list_packages())
- - def process_args(self): self.parser = OptionParser() self.parser.add_option('-u', '--url', action='store', dest='url', help='The url to sync') @@ -76,7 +72,6 @@ class RepoSync: self.parser.add_option('-l', '--label', action='store', dest='label', help='A friendly label to refer to the repo') self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation") return self.parser.parse_args() -
def load_plugin(self): sys.path.append("repo_plugins") @@ -94,18 +89,24 @@ class RepoSync: elif pack.checksums.has_key('sha256'): """lookup by sha256""" if pid == None: - if self.channel_label not in rhnPackage.get_channels_for_package([pack.name, pack.version, pack.release, pack.epoch, pack.arch]) and \ - self.channel_label not in rhnPackage.get_channels_for_package([pack.name, pack.version, pack.release, '', pack.arch]): + if self.channel_label not in \ + rhnPackage.get_channels_for_package([pack.name, \ + pack.version, pack.release, pack.epoch, pack.arch]) and \ + self.channel_label not in \ + rhnPackage.get_channels_for_package([pack.name, \ + pack.version, pack.release, '', pack.arch]): to_download.append(pack)
for (index, pack) in enumerate(to_download): """download each package""" try: - print(str(index) + "/" + str(len(to_download)) + " : "+ pack.getNVREA()) + print(str(index) + "/" + str(len(to_download)) + " : "+ \ + pack.getNVREA()) path = self.plugin.get_package(pack) md5 = rhnLib.getFileMD5(filename=path) - pid = rhnPackage.get_package_for_md5sum(self.channel['org_id'], md5) + pid = rhnPackage.get_package_for_md5sum( + self.channel['org_id'], md5) if pid is None: self.upload_package(pack, path, md5) self.associate_package(pack, md5) @@ -138,7 +139,8 @@ class RepoSync: package_dict, diff_level = rhnPackageUpload.push_package(header, payload_stream, md5sum, force=False, header_start=header_start, header_end=header_end, - relative_path=rel_package_path, org_id=self.channel['org_id']) + relative_path=rel_package_path, + org_id=self.channel['org_id']) temp_file.close() if self.url.find("file://") < 0: os.remove(path) @@ -158,21 +160,26 @@ class RepoSync: package['epoch'] = pack.epoch package['arch'] = pack.arch package['md5sum'] = md5sum - package['channels'] = [{'label':self.channel_label, 'id':self.channel['id']}] + package['channels'] = [{'label':self.channel_label, + 'id':self.channel['id']}] package['org_id'] = self.channel['org_id']
try: - importer = ChannelPackageSubscription([IncompletePackage().populate(package)], backend, caller=caller) + importer = ChannelPackageSubscription( + [IncompletePackage().populate(package)], + backend, caller=caller) importer.run() except: package['epoch'] = '0' - importer = ChannelPackageSubscription([IncompletePackage().populate(package)], backend, caller=caller) + importer = ChannelPackageSubscription( + [IncompletePackage().populate(package)], + backend, caller=caller) importer.run() backend.commit() + def load_channel(self): return rhnChannel.channel_info(self.channel_label)
- class ContentPackage:
#map of checksums. Valid keys are 'md5sum' & 'sha256' @@ -198,4 +205,3 @@ class ContentPackage: return self.name + '-' + self.version + '-' + self.release + '-' + self.epoch + '.' + self.arch else: return self.name + '-' + self.version + '-' + self.release + '.' + self.arch - diff --git a/backend/satellite_tools/spacewalk-repo-sync b/backend/satellite_tools/spacewalk-repo-sync index 244c260..a14ad76 100755 --- a/backend/satellite_tools/spacewalk-repo-sync +++ b/backend/satellite_tools/spacewalk-repo-sync @@ -22,7 +22,6 @@ if __name__ != '__main__': import sys def systemExit(code, msgs=None): "Exit with a code and optional message(s). Saved a few lines of code." - if msgs: if type(msgs) not in [type([]), type(())]: msgs = (msgs, ) @@ -30,7 +29,6 @@ def systemExit(code, msgs=None): sys.stderr.write(str(msg)+'\n') sys.exit(code)
- try: import os import socket @@ -45,16 +43,12 @@ except ImportError: sys.stderr.write("Unable to find RHN code tree.\n" "Path not correct? '%s'\n" % _LIBPATH)
- - - def releaseLOCK(): global LOCK if LOCK: LOCK.release() LOCK = None
- def main():
# quick check to see if you are a super-user. @@ -62,19 +56,16 @@ def main(): sys.stderr.write('ERROR: must be root to execute\n') sys.exit(8)
- LOCK = None try: - LOCK = rhnLockfile.Lockfile('/var/run/spacewalk-sync.pid') + LOCK = rhnLockfile.Lockfile('/var/run/spacewalk-repo-sync.pid') except rhnLockfile.LockfileLockedException: - systemExit(1, "SYNC ERROR: attempting to run more than one instance of satellite-sync. Exiting.") - + systemExit(1, "ERROR: attempting to run more than one instance of spacewalk-repo-sync Exiting.") sync = reposync.RepoSync() sync.main() releaseLOCK() return 0
- if __name__ == '__main__': try: sys.exit(abs(main() or 0)) @@ -86,4 +77,3 @@ if __name__ == '__main__': except Exception, e: releaseLOCK() raise -
commit 6ed3ca255562fef25eb51bcb2523a2929af504a7 Author: Justin Sherrill jsherril@redhat.com Date: Wed Jul 22 18:24:16 2009 -0400
adding repo sync task and other UI bits for spacewalk repo sync
diff --git a/backend/satellite_tools/repo_plugins/yum_src.py b/backend/satellite_tools/repo_plugins/yum_src.py new file mode 100644 index 0000000..fd39518 --- /dev/null +++ b/backend/satellite_tools/repo_plugins/yum_src.py @@ -0,0 +1,56 @@ +#!/usr/bin/python -u +# +# 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. +# +import yum +from yum import config +from reposync import ContentPackage +class ContentSource: + + url = None + name = None + repo = None + + def __init__(self, url, name): + self.url = url + self.name = name + + def list_packages(self): + """ list packages""" + repo = yum.yumRepo.YumRepository(self.name) + self.repo = repo + repo.cache = 0 + repo.metadata_expire = 5 + repo.baseurl = [self.url] + repo.basecachedir = '/var/cache/rhn/reposync/' +# repo.cachedir = '/var/cache/rhn/reposync/' + repo.setup(False) + sack = repo.getPackageSack() + sack.populate(repo, 'metadata', None, 0) + list = sack.returnPackages() + to_return = [] + for pack in list: + new_pack = ContentPackage() + new_pack.setNVREA(pack.name, pack.version, pack.release, pack.epoch, pack.arch) + new_pack.unique_id = pack + for cs in pack.checksums: + new_pack.checksums[cs[0]] = cs[1] + to_return.append(new_pack) + return to_return + + def get_package(self, package): + """ get package """ + return self.repo.getPackage(package.unique_id) + + diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.java b/java/code/src/com/redhat/rhn/domain/channel/Channel.java index 303fa7d..e61da3f 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@ -819,7 +819,7 @@ public class Channel extends BaseDomainHelper implements Comparable { * if null or '' is passed in, all content sources will be removed. * @param url the url of the yum repo */ - public void setYumContentSource(String url) { + public void setYumContentSource(String url, String labelIn) { if (StringUtils.isEmpty(url)) { if (!this.getContentSources().isEmpty()) { this.getContentSources().clear(); @@ -830,11 +830,14 @@ public class Channel extends BaseDomainHelper implements Comparable { ContentSource cs = new ContentSource(); cs.setChannel(this); cs.setSourceUrl(url); + cs.setLabel(labelIn); cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); this.getContentSources().add(cs); } else { - this.getContentSources().iterator().next().setSourceUrl(url); + ContentSource cs = this.getContentSources().iterator().next(); + cs.setSourceUrl(url); + cs.setLabel(labelIn); } } ChannelFactory.save(this); diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java index 7f3aa2a..71a73b1 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -120,6 +120,19 @@ public class ChannelFactory extends HibernateFactory { }
/** + * Lookup a content source by id + * @param id the id to lookup + * @return the ContentSource + */ + public static ContentSource lookupContentSource(Long id) { + Map params = new HashMap(); + params.put("id", id); + return (ContentSource) singleton.lookupObjectByNamedQuery( + "ContentSource.findById", params); + } + + + /** * Retrieve a list of channel ids associated with the labels provided * @param labelsIn the labels to search for * @return list of channel ids diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml index 2756941..fd8edd2 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml @@ -17,6 +17,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" <property name="lastSynced" type="timestamp" column="last_synced"/> <property name="created" type="timestamp" column="created" insert="false" update="false" /> <property name="modified" type="timestamp" column="modified" insert="false" update="false" /> + <property name="label" type="string" column="label"/>
<many-to-one @@ -31,4 +32,10 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
</class> + + + <query name="ContentSource.findById"> + <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id = :id]]> + </query> + </hibernate-mapping> diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java index 70a54e8..74599a1 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java @@ -29,8 +29,25 @@ public class ContentSource extends BaseDomainHelper { private ContentSourceType type; private String sourceUrl; private Date lastSynced; + private String label;
+ + /** + * @return Returns the label. + */ + public String getLabel() { + return label; + } + + + /** + * @param labelIn The label to set. + */ + public void setLabel(String labelIn) { + this.label = labelIn; + } + /** * @return Returns the id. */ diff --git a/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml b/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml index 276b5e8..70b8f1a 100644 --- a/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml @@ -32,6 +32,14 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" where org_id = :org_id and task_name = :name and task_data = :data and earliest = :earliest]]> </query> + + <query name="Task.listTasksByName"> + <![CDATA[from com.redhat.rhn.domain.task.Task as t + where t.name = :name]]> + </query> + + +
<sql-query name="Task.lookupByNameLike"> <![CDATA[SELECT {t.*} diff --git a/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java b/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java index 50149eb..aa75626 100644 --- a/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java +++ b/java/code/src/com/redhat/rhn/domain/task/TaskFactory.java @@ -19,10 +19,12 @@ import com.redhat.rhn.domain.org.Org;
import org.apache.log4j.Logger; import org.hibernate.Criteria; +import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.criterion.CriteriaSpecification; import org.hibernate.criterion.Order;
+import java.util.Collections; import java.util.Date; import java.util.List;
@@ -66,6 +68,33 @@ public class TaskFactory extends HibernateFactory { }
/** + * + * @param name + * @return + */ + public static List<Task> listTasks(String name) { + Session session = null; + try { + session = HibernateFactory.getSession(); + return session.getNamedQuery("Task.listTasksByName") + .setString("name", name).list(); + } + catch (HibernateException he) { + log.error("Hibernate exception: " + he.toString()); + } + return Collections.EMPTY_LIST; + } + + /** + * + * @param task + */ + public static void removeTask(Task task) { + TaskFactory.getSession().delete(task); + } + + + /** * Saves the object to the db * @param taskIn The task to save */ diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java index c7c8f66..baa0737 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java @@ -334,6 +334,7 @@ public class EditChannelAction extends RhnAction implements Listable { ucc.setSupportPolicy((String)form.get("support_policy")); ucc.setAccess((String)form.get("org_sharing")); ucc.setYumUrl((String) form.getString("yum_repo")); + ucc.setRepoLabel((String) form.getString("repo_label"));
String parent = (String)form.get("parent"); if (parent == null || parent.equals("")) { @@ -405,6 +406,7 @@ public class EditChannelAction extends RhnAction implements Listable { ccc.setSupportPolicy((String)form.get("support_policy")); ccc.setAccess((String)form.get("org_sharing")); ccc.setYumUrl((String) form.getString("yum_repo")); + ccc.setRepoLabel((String) form.getString("repo_label"));
String parent = (String)form.get("parent"); if (parent == null || parent.equals("")) { @@ -570,11 +572,13 @@ public class EditChannelAction extends RhnAction implements Listable {
if (c.getContentSources().isEmpty()) { form.set("yum_repo", ""); + form.set("repo_label", ""); request.setAttribute("last_sync", ""); } else { ContentSource cs = c.getContentSources().iterator().next(); form.set("yum_repo", cs.getSourceUrl()); + form.set("repo_label", cs.getLabel()); String lastSync = LocalizationService.getInstance().getMessage( "channel.edit.repo.neversynced"); if (cs.getLastSynced() != null) { diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index 8c76681..82aabc0 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -21431,6 +21431,12 @@ given channel.</source> <trans-unit id="channel.edit.jsp.repourl"> <source>Repository URL</source> </trans-unit> + <trans-unit id="channel.edit.jsp.repolabel"> + <source>Label</source> + </trans-unit> + <trans-unit id="edit.channel.invalidrepolabel.missing"> + <source>A repo label is required if providing a yum repository url.</source> + </trans-unit> <trans-unit id="channel.edit.jsp.lastsynced"> <source>Last Sync Time</source> </trans-unit> diff --git a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java index d75225c..0ea6469 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java @@ -68,9 +68,12 @@ public class CreateChannelCommand { protected String supportPolicy; protected String access = Channel.PRIVATE; protected String yumUrl; + protected String repoLabel;
+
+ /** * default constructor. */ @@ -269,7 +272,8 @@ public class CreateChannelCommand {
ChannelFactory.refreshNewestPackageCache(c, WEB_CHANNEL_CREATED);
- c.setYumContentSource(yumUrl); + c.setYumContentSource(yumUrl, repoLabel); +
return c; } @@ -324,6 +328,12 @@ public class CreateChannelCommand { throw new IllegalArgumentException( "Required parameters not set: user, or summary"); } + + if (!StringUtils.isEmpty(yumUrl) && StringUtils.isEmpty(repoLabel)) { + throw new IllegalArgumentException( + "edit.channel.invalidrepolabel.missing"); + } + }
protected void verifyChannelName(String cname) throws InvalidChannelNameException { @@ -432,5 +442,12 @@ public class CreateChannelCommand { public void setYumUrl(String yumUrlIn) { this.yumUrl = yumUrlIn; } + + /** + * @param repoLabelIn The repoLabel to set. + */ + public void setRepoLabel(String repoLabelIn) { + this.repoLabel = repoLabelIn; + }
} diff --git a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java index 66d8673..79764aa 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java @@ -79,7 +79,7 @@ public class UpdateChannelCommand extends CreateChannelCommand { c.setSupportPolicy(supportPolicy);
- c.setYumContentSource(yumUrl); + c.setYumContentSource(yumUrl, repoLabel);
// need to save before calling stored proc below diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java new file mode 100644 index 0000000..ae382a5 --- /dev/null +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2009 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 com.redhat.rhn.taskomatic.task; + +import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.task.Task; +import com.redhat.rhn.domain.task.TaskFactory; + +import org.apache.log4j.Logger; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * Repo Sync + * Used for syncing repos (like yum repos) to a channel + * This really just calls a python script + * + * @version $Rev$ + */ +public class RepoSyncTask implements Job { + + /** + * Used to log stats in the RHNDAEMONSTATE table + */ + public static final String DISPLAY_NAME = "repo_sync"; + + private static Logger log = Logger.getLogger(RepoSyncTask.class); + + /** + * Default constructor + */ + public RepoSyncTask() { + } + + + /** + * + * {@inheritDoc} + */ + public void execute(JobExecutionContext context) + throws JobExecutionException { + + for (Task task : TaskFactory.listTasks("repo_sync")) { + + ContentSource src = ChannelFactory.lookupContentSource(task.getData()); + if (src == null) { + log.error("Content Source could not be found: " + task.getData()); + continue; + } + + try { + Process p = Runtime.getRuntime().exec(""); + } + catch (IOException e) { + + } + src.setLastSynced(new Date()); + TaskFactory.removeTask(task); + } + } + + private static List<String> getSyncCommand(ContentSource src) { + List<String> cmd = new ArrayList<String>(); + cmd.add("/usr/sbin/spacewalk-repo-sync"); + cmd.add("-c"); + cmd.add(src.getChannel().getLabel()); + cmd.add("-u"); + cmd.add(src.getSourceUrl()); + cmd.add("-t"); + cmd.add(src.getType().getLabel()); + return cmd; + } + + +} diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp index eb7649a..adda2fb 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp @@ -117,7 +117,7 @@ <bean:message key="channel.edit.jsp.repourl"/>: </th> <td> - <html:text property="yum_repo" maxlength="512" size="60" /> + <html:text property="yum_repo" maxlength="512" size="64" /> </td> </tr> <c:if test='${not empty param.cid}'> @@ -132,6 +132,14 @@ </c:if> <tr> <th> + <bean:message key="channel.edit.jsp.repolabel"/>: + </th> + <td> + <html:text property="repo_label" maxlength="64" size="20" /> + </td> + </tr> + <tr> + <th> <bean:message key="channel.edit.jsp.sync"/>: </th> <td> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index d09d20d..8086357 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -838,6 +838,7 @@ <form-property name="maintainer_phone" type="java.lang.String" /> <form-property name="support_policy" type="java.lang.String" /> <form-property name="yum_repo" type="java.lang.String" /> + <form-property name="repo_label" type="java.lang.String" /> <form-property name="sync_repo" type="java.lang.Boolean" /> <form-property name="per_user_subscriptions" type="java.lang.String" /> <form-property name="org_sharing" type="java.lang.String" />
commit 7363b853cd74456f03b24bfceb0478a89031ceb6 Author: Justin Sherrill jsherril@redhat.com Date: Wed Jul 22 18:23:56 2009 -0400
adding label to ContentSource schema
diff --git a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql index 26c3973..f0b30a5 100644 --- a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql +++ b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql @@ -32,6 +32,8 @@ rhnChannelContentSource references rhnContentSourceType(id), source_url varchar2(512) constraint rhn_ccs_url_nn not null, + label varchar2(64) + constraint rhn_ccs_l_nn not null, last_synced date, created date default(sysdate) constraint rhn_ccs_cre_nn not null, diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql index a1445e1..ccf5cb8 100644 --- a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql +++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql @@ -32,6 +32,8 @@ rhnChannelContentSource references rhnContentSourceType(id), source_url varchar2(512) constraint rhn_ccs_url_nn not null, + label varchar2(64) + constraint rhn_ccs_l_nn not null, last_synced date, created date default(sysdate) constraint rhn_ccs_cre_nn not null,
commit 7a0f31f3dabe9c0c0f226421321c58f2c8c3c29b Author: Justin Sherrill jsherril@redhat.com Date: Wed Jul 22 18:22:37 2009 -0400
backend/satellite_tools/repo_plugins/yum_src.py
initial commit of spacewalk repo sync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py new file mode 100644 index 0000000..5abcc1c --- /dev/null +++ b/backend/satellite_tools/reposync.py @@ -0,0 +1,201 @@ +#!/usr/bin/python -u +# +# 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. +# +import sys, os +from optparse import OptionParser +from common import rhnLib +from server import rhnPackage, rhnSQL, rhnChannel, rhnPackageUpload +from common import CFG, initCFG, rhn_rpm +from server.importlib.importLib import IncompletePackage +from server.importlib.backendOracle import OracleBackend +from server.importlib.packageImport import ChannelPackageSubscription + +class RepoSync: + + + parser = None + type = None + url = None + channel_label = None + plugin = None + channel = None + fail = False + repo_label = None + + + def main(self): + initCFG('server') + db_string = CFG.DEFAULT_DB #"rhnsat/rhnsat@rhnsat" + rhnSQL.initDB(db_string) + (options, args) = self.process_args() + + + if not options.url: + print("--url must be specified") + if not options.type: + print("--type must be specified") + if not options.channel_label: + print("--channel must be specified") + if not options.label: + print("--label must be specified") + + + self.type = options.type + self.url = options.url + self.channel_label = options.channel_label + self.fail = options.fail + self.repo_label = options.label + self.channel = self.load_channel() + + if not self.channel or not rhnChannel.isCustomChannel(self.channel['id']): + print "Channel does not exist or is not custom" + sys.exit(1) + + self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label) + self.import_packages(self.plugin.list_packages()) + + + + def process_args(self): + self.parser = OptionParser() + self.parser.add_option('-u', '--url', action='store', dest='url', help='The url to sync') + self.parser.add_option('-c', '--channel', action='store', dest='channel_label', help='The label of the channel to sync packages to') + self.parser.add_option('-t', '--type', action='store', dest='type', help='The type of repo, currently only "yum" is supported') + self.parser.add_option('-l', '--label', action='store', dest='label', help='A friendly label to refer to the repo') + self.parser.add_option('-f', '--fail', action='store_true', dest='fail', default=False , help="If a package import fails, fail the entire operation") + return self.parser.parse_args() + + + def load_plugin(self): + sys.path.append("repo_plugins") + name = self.type + "_src" + mod = __import__(name) + return getattr(mod, "ContentSource") + + def import_packages(self, packages): + to_link = [] + to_download = [] + for pack in packages: + pid = None + if pack.checksums.has_key('md5sum'): + """lookup by md5sum""" + elif pack.checksums.has_key('sha256'): + """lookup by sha256""" + if pid == None: + if self.channel_label not in rhnPackage.get_channels_for_package([pack.name, pack.version, pack.release, pack.epoch, pack.arch]) and \ + self.channel_label not in rhnPackage.get_channels_for_package([pack.name, pack.version, pack.release, '', pack.arch]): + to_download.append(pack) + + + for (index, pack) in enumerate(to_download): + """download each package""" + try: + print(str(index) + "/" + str(len(to_download)) + " : "+ pack.getNVREA()) + path = self.plugin.get_package(pack) + md5 = rhnLib.getFileMD5(filename=path) + pid = rhnPackage.get_package_for_md5sum(self.channel['org_id'], md5) + if pid is None: + self.upload_package(pack, path, md5) + self.associate_package(pack, md5) + else: + to_link.append(pack) + except KeyboardInterrupt: + raise + except: + if self.fail: + raise + continue + for pack in to_link: + try: + self.associate_package(pack, md5) + except KeyboardInterrupt: + raise + except: + if self.fail: + raise + continue + + def upload_package(self, package, path, md5): + temp_file = open(path, 'rb') + header, payload_stream, md5sum, header_start, header_end = \ + rhnPackageUpload.load_package(temp_file) + rel_package_path = rhnPackageUpload.relative_path_from_header( + header, org_id=self.channel['org_id'], md5sum=md5sum) + package_path = os.path.join(CFG.MOUNT_POINT, + rel_package_path) + package_dict, diff_level = rhnPackageUpload.push_package(header, + payload_stream, md5sum, force=False, + header_start=header_start, header_end=header_end, + relative_path=rel_package_path, org_id=self.channel['org_id']) + temp_file.close() + if self.url.find("file://") < 0: + os.remove(path) + + + def associate_package(self, pack, md5sum): + caller = "server.app.yumreposync" + backend = OracleBackend() + backend.init() + package = {} + package['name'] = pack.name + package['version'] = pack.version + package['release'] = pack.release + if pack.epoch == 0: + package['epoch'] = "" + else: + package['epoch'] = pack.epoch + package['arch'] = pack.arch + package['md5sum'] = md5sum + package['channels'] = [{'label':self.channel_label, 'id':self.channel['id']}] + package['org_id'] = self.channel['org_id'] + + try: + importer = ChannelPackageSubscription([IncompletePackage().populate(package)], backend, caller=caller) + importer.run() + except: + package['epoch'] = '0' + importer = ChannelPackageSubscription([IncompletePackage().populate(package)], backend, caller=caller) + importer.run() + backend.commit() + def load_channel(self): + return rhnChannel.channel_info(self.channel_label) + + +class ContentPackage: + + #map of checksums. Valid keys are 'md5sum' & 'sha256' + checksums = {} + + #unique ID that can be used by plugin + unique_id = None + + name = None + version = None + release = None + epoch = None + arch = None + + def setNVREA(self, name, version, release, epoch, arch): + self.name = name + self.version = version + self.release = release + self.arch = arch + + def getNVREA(self): + if self.epoch: + return self.name + '-' + self.version + '-' + self.release + '-' + self.epoch + '.' + self.arch + else: + return self.name + '-' + self.version + '-' + self.release + '.' + self.arch + diff --git a/backend/satellite_tools/spacewalk-repo-sync b/backend/satellite_tools/spacewalk-repo-sync new file mode 100755 index 0000000..244c260 --- /dev/null +++ b/backend/satellite_tools/spacewalk-repo-sync @@ -0,0 +1,89 @@ +#!/usr/bin/python -u +# +# 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. +# + +LOCK = None + +if __name__ != '__main__': + raise ImportError, "module cannot be imported" + +import sys +def systemExit(code, msgs=None): + "Exit with a code and optional message(s). Saved a few lines of code." + + if msgs: + if type(msgs) not in [type([]), type(())]: + msgs = (msgs, ) + for msg in msgs: + sys.stderr.write(str(msg)+'\n') + sys.exit(code) + + +try: + import os + import socket + _LIBPATH = "/usr/share/rhn" + if _LIBPATH not in sys.path: + sys.path.append(_LIBPATH) + from common import rhnLockfile, CFG, fetchTraceback + from satellite_tools import reposync +except KeyboardInterrupt: + systemExit(0, "\nUser interrupted process.") +except ImportError: + sys.stderr.write("Unable to find RHN code tree.\n" + "Path not correct? '%s'\n" % _LIBPATH) + + + + +def releaseLOCK(): + global LOCK + if LOCK: + LOCK.release() + LOCK = None + + +def main(): + + # quick check to see if you are a super-user. + if os.getuid() != 0: + sys.stderr.write('ERROR: must be root to execute\n') + sys.exit(8) + + + LOCK = None + try: + LOCK = rhnLockfile.Lockfile('/var/run/spacewalk-sync.pid') + except rhnLockfile.LockfileLockedException: + systemExit(1, "SYNC ERROR: attempting to run more than one instance of satellite-sync. Exiting.") + + sync = reposync.RepoSync() + sync.main() + releaseLOCK() + return 0 + + +if __name__ == '__main__': + try: + sys.exit(abs(main() or 0)) + except KeyboardInterrupt: + systemExit(0, "\nUser interrupted process.") + except SystemExit, e: + releaseLOCK() + sys.exit(e.code) + except Exception, e: + releaseLOCK() + raise + diff --git a/backend/server/basePackageUpload.py b/backend/server/basePackageUpload.py new file mode 100644 index 0000000..ad05f93 --- /dev/null +++ b/backend/server/basePackageUpload.py @@ -0,0 +1,100 @@ +#!/usr/bin/python +# +# 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. +# +# $Id$ + +import os +import tempfile +from mod_python import apache + +from common import CFG, log_debug, rhnFault, rhn_mpm, rhnLib, UserDictCase +from common.rhn_rpm import get_header_byte_range + +from server import rhnSQL +from server.importlib import importLib, userAuth, mpmSource, backendOracle, \ + packageImport, errataCache +from server.rhnLib import get_package_path, \ + get_package_path_without_package_name +from server.rhnServer import server_packages + +class BasePackageUpload: + def __init__(self, req): + self.header_prefix = "X-RHN-Upload" + self.error_header_prefix = 'X-RHN-Upload-Error' + self.prefix = 'rhn/repository' + self.is_source = 0 + self.rel_package_path = None + self.package_path = None + self.required_fields = [ + "Package-Name", + "Package-Version", + "Package-Release", + "Package-Arch", + "File-MD5sum", + ] + self.field_data = UserDictCase() + self.org_id = None + + def headerParserHandler(self, req): + """ This whole function is ugly as hell. The Auth field in the header used to be required, but now + it must have either the Auth field or the Auth-Session field. + """ + # Initialize the logging + log_debug(3, "Method", req.method) + + #Header string. This is what the Auth-Session field will look like in the header. + session_header = "%s-%s" % (self.header_prefix, "Auth-Session") + + for f in self.required_fields: + hf = "%s-%s" % (self.header_prefix, f) + if not req.headers_in.has_key(hf): + #If the current field is Auth and Auth-Session field isn't present, something is wrong. + if f == "Auth" and not req.headers_in.has_key(session_header): + log_debug(4, "Required field %s missing" % f) + raise rhnFault(500, f) + + #The current field is Auth and the Auth-Session field is present, so everything is good. + elif f == "Auth" and req.headers_in.has_key(session_header): + self.field_data["Auth-Session"] = req.headers_in[session_header] + continue + + #The current field being looked for isn't the Auth field and it's missing, so something is wrong. + else: + log_debug(4, "Required field %s missing" % f) + raise rhnFault(500, f) + + if not (f == "Auth" and not req.headers_in.has_key(hf)): + self.field_data[f] = req.headers_in[hf] + else: + if req.headers_in.has_key(session_header): + self.field_data[f] = req.headers_in[hf] + + self.package_name = self.field_data["Package-Name"] + self.package_version = self.field_data["Package-Version"] + self.package_release = self.field_data["Package-Release"] + self.package_arch = self.field_data["Package-Arch"] + self.file_md5sum = self.field_data["File-MD5sum"] + #4/18/05 wregglej. if 1051 is in the header's keys, then it's a nosrc package. + self.is_source = (self.package_arch == 'src' or self.package_arch == 'nosrc') + return apache.OK + + def handler(self, req): + log_debug(3, "Method", req.method) + return apache.OK + def cleanupHandler(self, req): + return apache.OK + + def logHandler(self, req): + return apache.OK diff --git a/backend/server/rhnPackage.py b/backend/server/rhnPackage.py index c5f97b0..0b7ac08 100644 --- a/backend/server/rhnPackage.py +++ b/backend/server/rhnPackage.py @@ -432,6 +432,22 @@ def get_channels_for_package(pkg): return [] return map(lambda c: c['label'], ret)
+def get_package_for_md5sum(org_id, md5sum): + statement = """ + select + p.id + from + rhnPackage p + where p.org_id = :org_id + and p.md5sum = :md5sum + """ + h = rhnSQL.prepare(statement) + h.execute(org_id=org_id, md5sum=md5sum) + ret = h.fetchone_dict() + if not ret: + return None + return ret['id'] +
def _none2emptyString(foo): if foo is None: diff --git a/backend/server/rhnPackageUpload.py b/backend/server/rhnPackageUpload.py index 5cdcd95..46b57a7 100644 --- a/backend/server/rhnPackageUpload.py +++ b/backend/server/rhnPackageUpload.py @@ -17,7 +17,6 @@
import os import tempfile -from mod_python import apache
from common import CFG, log_debug, rhnFault, rhn_mpm, rhnLib, UserDictCase from common.rhn_rpm import get_header_byte_range @@ -29,76 +28,6 @@ from server.rhnLib import get_package_path, \ get_package_path_without_package_name from server.rhnServer import server_packages
-class BasePackageUpload: - def __init__(self, req): - self.header_prefix = "X-RHN-Upload" - self.error_header_prefix = 'X-RHN-Upload-Error' - self.prefix = 'rhn/repository' - self.is_source = 0 - self.rel_package_path = None - self.package_path = None - self.required_fields = [ - "Package-Name", - "Package-Version", - "Package-Release", - "Package-Arch", - "File-MD5sum", - ] - self.field_data = UserDictCase() - self.org_id = None - - def headerParserHandler(self, req): - """ This whole function is ugly as hell. The Auth field in the header used to be required, but now - it must have either the Auth field or the Auth-Session field. - """ - # Initialize the logging - log_debug(3, "Method", req.method) - - #Header string. This is what the Auth-Session field will look like in the header. - session_header = "%s-%s" % (self.header_prefix, "Auth-Session") - - for f in self.required_fields: - hf = "%s-%s" % (self.header_prefix, f) - if not req.headers_in.has_key(hf): - #If the current field is Auth and Auth-Session field isn't present, something is wrong. - if f == "Auth" and not req.headers_in.has_key(session_header): - log_debug(4, "Required field %s missing" % f) - raise rhnFault(500, f) - - #The current field is Auth and the Auth-Session field is present, so everything is good. - elif f == "Auth" and req.headers_in.has_key(session_header): - self.field_data["Auth-Session"] = req.headers_in[session_header] - continue - - #The current field being looked for isn't the Auth field and it's missing, so something is wrong. - else: - log_debug(4, "Required field %s missing" % f) - raise rhnFault(500, f) - - if not (f == "Auth" and not req.headers_in.has_key(hf)): - self.field_data[f] = req.headers_in[hf] - else: - if req.headers_in.has_key(session_header): - self.field_data[f] = req.headers_in[hf] - - self.package_name = self.field_data["Package-Name"] - self.package_version = self.field_data["Package-Version"] - self.package_release = self.field_data["Package-Release"] - self.package_arch = self.field_data["Package-Arch"] - self.file_md5sum = self.field_data["File-MD5sum"] - #4/18/05 wregglej. if 1051 is in the header's keys, then it's a nosrc package. - self.is_source = (self.package_arch == 'src' or self.package_arch == 'nosrc') - return apache.OK - - def handler(self, req): - log_debug(3, "Method", req.method) - return apache.OK - def cleanupHandler(self, req): - return apache.OK - - def logHandler(self, req): - return apache.OK -
def source_match(v1, v2): """ returns true if both parameters are true, false otherwise """ diff --git a/backend/upload_server/handlers/package_push/package_push.py b/backend/upload_server/handlers/package_push/package_push.py index fd19a3e..2115ada 100644 --- a/backend/upload_server/handlers/package_push/package_push.py +++ b/backend/upload_server/handlers/package_push/package_push.py @@ -26,11 +26,11 @@ from mod_python import apache from rhn import rpclib
from common import CFG, log_debug, log_error, rhnFault, rhnFlags -from server import rhnPackageUpload, rhnSQL +from server import rhnPackageUpload, rhnSQL, basePackageUpload
-class PackagePush(rhnPackageUpload.BasePackageUpload): +class PackagePush(basePackageUpload.BasePackageUpload): def __init__(self, req): - rhnPackageUpload.BasePackageUpload.__init__(self, req) + basePackageUpload.BasePackageUpload.__init__(self, req) self.required_fields.extend([ 'Auth', 'Force', @@ -43,7 +43,7 @@ class PackagePush(rhnPackageUpload.BasePackageUpload): self.force = None
def headerParserHandler(self, req): - ret = rhnPackageUpload.BasePackageUpload.headerParserHandler(self, req) + ret = basePackageUpload.BasePackageUpload.headerParserHandler(self, req) # Optional headers maps = [['Null-Org', 'null_org'], ['Packaging', 'packaging']] for hn, sn in maps: @@ -108,7 +108,7 @@ class PackagePush(rhnPackageUpload.BasePackageUpload):
def handler(self, req): - ret = rhnPackageUpload.BasePackageUpload.handler(self, req) + ret = basePackageUpload.BasePackageUpload.handler(self, req) if ret != apache.OK: return ret
diff --git a/backend/upload_server/handlers/package_upload/package_upload.py b/backend/upload_server/handlers/package_upload/package_upload.py index c3689cb..b087ca9 100644 --- a/backend/upload_server/handlers/package_upload/package_upload.py +++ b/backend/upload_server/handlers/package_upload/package_upload.py @@ -23,12 +23,12 @@ import os from mod_python import apache
from common import CFG, log_debug, log_error, rhnFault, rhnFlags -from server import rhnPackageUpload +from server import rhnPackageUpload, basePackageUpload from server.rhnLib import get_package_path
-class PackageUpload(rhnPackageUpload.BasePackageUpload): +class PackageUpload(basePackageUpload.BasePackageUpload): def headerParserHandler(self, req): - ret = rhnPackageUpload.BasePackageUpload.headerParserHandler(self, req) + ret = basePackageUpload.BasePackageUpload.headerParserHandler(self, req) if ret != apache.OK: return ret
@@ -60,7 +60,7 @@ class PackageUpload(rhnPackageUpload.BasePackageUpload): return apache.OK
def handler(self, req): - ret = rhnPackageUpload.BasePackageUpload.handler(self, req) + ret = basePackageUpload.BasePackageUpload.handler(self, req) if ret != apache.OK: return ret
commit ac8941eed03bef6babc9caff3c47ae1a02a357ff Merge: a54eb73... 953f234... Author: Justin Sherrill jsherril@redhat.com Date: Wed Jul 22 14:14:38 2009 -0400
merge conflict
diff --cc java/code/src/com/redhat/rhn/domain/channel/Channel.java index b7f8d4d,ca5071e..303fa7d --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@@ -794,46 -795,30 +798,72 @@@ public class Channel extends BaseDomain public boolean containsDistributions() { return ChannelFactory.containsDistributions(this); } + + /** + * @return Returns the contentSources. + */ + public Set<ContentSource> getContentSources() { + return contentSources; + } + + + /** + * @param contentSourcesIn The contentSources to set. + */ + public void setContentSources(Set<ContentSource> contentSourcesIn) { + this.contentSources = contentSourcesIn; + } + + /** + * Set the yum content source, if one is already set, it will be replaced + * if null or '' is passed in, all content sources will be removed. + * @param url the url of the yum repo + */ + public void setYumContentSource(String url) { + if (StringUtils.isEmpty(url)) { + if (!this.getContentSources().isEmpty()) { + this.getContentSources().clear(); + } + } + else { + if (this.getContentSources().isEmpty()) { + ContentSource cs = new ContentSource(); + cs.setChannel(this); + cs.setSourceUrl(url); + cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); + this.getContentSources().add(cs); + } + else { + this.getContentSources().iterator().next().setSourceUrl(url); + } + } + ChannelFactory.save(this); + } + + + /** + * get the compatible checksum type to be used for repomd.xml + * based on channel release. If its RHEL-5 we use sha1 + * anything newer will be sha256. + * @return checksumType + */ + public String getChecksumType() { + Channel toConsider = this; + while (toConsider.getParentChannel() != null) { + toConsider = toConsider.getParentChannel(); + } + DistChannelMap channelDist = ChannelFactory.lookupDistChannelMap(toConsider); + if (channelDist != null) { + String release = channelDist.getRelease(); + // If channel or parent is RHEL-5 use sha1, else use sha256 + if (toConsider.isCustom() || sha1compatiblechannels.contains(release)) { + return CHECKSUM_SHA_1; + } + else { + return CHECKSUM_SHA_256; + } + } + // default to sha256 + return CHECKSUM_SHA_256; + } } diff --cc java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml index 2499e27,a8952f6..a01a024 --- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml @@@ -8243,9 -8272,18 +8272,21 @@@ Follow this url to see the full list o <trans-unit id="snapshots.configchannel"> <source>Configuration Channels Updated</source> </trans-unit> + <trans-unit id="channel.edit.repo.neversynced"> + <source>This repo has never been synced.</source> + </trans-unit> + <trans-unit id="ssm.provision.scheduled"> + <source>Successfully scheduled {0} system(s) for provisioning.</source> + </trans-unit> + <trans-unit id="ssm.package.install.operationname"> + <source>Schedule Package Installations</source> + </trans-unit> + <trans-unit id="ssm.package.upgrade.operationname"> + <source>Schedule Package Upgrades</source> + </trans-unit> + <trans-unit id="ssm.package.verify.operationname"> + <source>Schedule Package Verifications</source> + </trans-unit> <trans-unit id="kickstart.cobbler.distro.syncfail"> <source> The following is a list of errors gathered while Spacewalk attempts to
commit a54eb7309017956196ba92d58a6ba615bc288a9b Author: Justin Sherrill jsherril@redhat.com Date: Mon Jul 13 13:45:19 2009 -0400
adding sync repo option to UI for yum repos
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index 2580fb5..ac7d30f 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -21337,7 +21337,10 @@ given channel.</source> </trans-unit> <trans-unit id="channel.edit.jsp.lastsynced"> <source>Last Sync Time</source> - </trans-unit> + </trans-unit> + <trans-unit id="channel.edit.jsp.sync"> + <source>Sync Repo</source> + </trans-unit> </body> </file> </xliff> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp index 7ee2632..eb7649a 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp @@ -120,14 +120,24 @@ <html:text property="yum_repo" maxlength="512" size="60" /> </td> </tr> + <c:if test='${not empty param.cid}'> + <tr> + <th> + <bean:message key="channel.edit.jsp.lastsynced"/>: + </th> + <td> + <c:out value='${last_sync}'/> + </td> + </tr> + </c:if> <tr> - <th> - <bean:message key="channel.edit.jsp.lastsynced"/>: + <th> + <bean:message key="channel.edit.jsp.sync"/>: </th> <td> - <c:out value='${last_sync}'/> + <html:checkbox property="sync_repo" /> </td> - </tr> + </tr> </table>
<h2><bean:message key="channel.edit.jsp.contactsupportinfo"/></h2> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 884ac91..37787a1 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -841,6 +841,7 @@ <form-property name="maintainer_phone" type="java.lang.String" /> <form-property name="support_policy" type="java.lang.String" /> <form-property name="yum_repo" type="java.lang.String" /> + <form-property name="sync_repo" type="java.lang.Boolean" /> <form-property name="per_user_subscriptions" type="java.lang.String" /> <form-property name="org_sharing" type="java.lang.String" /> <form-property name="gpg_key_url" type="java.lang.String" />
commit d19948c081d40f1682ba6a6f4aeb6885eb8eb440 Author: Justin Sherrill jsherril@redhat.com Date: Fri Jul 10 16:25:37 2009 -0400
initial yum repo sync schema and UI work
diff --git a/java/buildconf/builder/config/satellite/rhn.conf b/java/buildconf/builder/config/satellite/rhn.conf index 06eb7a6..6d65bbe 100644 --- a/java/buildconf/builder/config/satellite/rhn.conf +++ b/java/buildconf/builder/config/satellite/rhn.conf @@ -38,7 +38,7 @@ web.default_db=rhnsat/rhnsat@rhnsat web.legacy_user_enabled = 1 web.legacy_save_enabled = 1
-hibernate.connection.url=jdbc:log:oracle.jdbc.driver.OracleDriver:oracle:thin:@joust.rhndev.redhat.com:1521:rhnsat +hibernate.connection.url=jdbc:log:oracle.jdbc.driver.OracleDriver:oracle:thin:@rlx-2-10.rhndev.redhat.com:1521:rhnsat hibernate.connection.driver_class=net.rkbloom.logdriver.LogDriver
web.product_name = Spacewalk diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml index f4ecff3..51f850d 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml @@ -63,6 +63,14 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" column="channel_family_id"/> </set>
+ <set name="contentSources" lazy="true" table="rhnChannelContentSource" + cascade="all-delete-orphan" inverse="true"> + <key column="channel_id"/> + <one-to-many + class="com.redhat.rhn.domain.channel.ContentSource" /> + </set> + + <set name="trustedOrgs" lazy="true" table="rhnChannelTrust" cascade="save-update"> <key column="channel_id"/> diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.java b/java/code/src/com/redhat/rhn/domain/channel/Channel.java index b45d739..b7f8d4d 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@ -24,6 +24,7 @@ import com.redhat.rhn.manager.channel.ChannelManager; import com.redhat.rhn.manager.system.IncompatibleArchException; import com.redhat.rhn.manager.system.SystemManager;
+import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; @@ -84,7 +85,9 @@ public class Channel extends BaseDomainHelper implements Comparable { private String maintainerEmail; private String maintainerPhone; private String supportPolicy; - + private Set<ContentSource> contentSources = new HashSet(); + + /** * @param orgIn what org you want to know if it is globally subscribable in * @return Returns whether or not this channel is globally subscribable. @@ -791,4 +794,46 @@ public class Channel extends BaseDomainHelper implements Comparable { public boolean containsDistributions() { return ChannelFactory.containsDistributions(this); } + + /** + * @return Returns the contentSources. + */ + public Set<ContentSource> getContentSources() { + return contentSources; + } + + + /** + * @param contentSourcesIn The contentSources to set. + */ + public void setContentSources(Set<ContentSource> contentSourcesIn) { + this.contentSources = contentSourcesIn; + } + + /** + * Set the yum content source, if one is already set, it will be replaced + * if null or '' is passed in, all content sources will be removed. + * @param url the url of the yum repo + */ + public void setYumContentSource(String url) { + if (StringUtils.isEmpty(url)) { + if (!this.getContentSources().isEmpty()) { + this.getContentSources().clear(); + } + } + else { + if (this.getContentSources().isEmpty()) { + ContentSource cs = new ContentSource(); + cs.setChannel(this); + cs.setSourceUrl(url); + cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); + this.getContentSources().add(cs); + } + else { + this.getContentSources().iterator().next().setSourceUrl(url); + } + } + ChannelFactory.save(this); + } + } diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java index 4837cf1..b2c2abd 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -14,22 +14,6 @@ */ package com.redhat.rhn.domain.channel;
-import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.criterion.CriteriaSpecification; -import org.hibernate.criterion.Projections; -import org.hibernate.criterion.Restrictions; - import com.redhat.rhn.common.db.datasource.CallableMode; import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.common.db.datasource.ModeFactory; @@ -43,6 +27,22 @@ import com.redhat.rhn.domain.rhnpackage.Package; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.manager.channel.ChannelManager;
+import org.apache.log4j.Logger; +import org.hibernate.Criteria; +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.criterion.CriteriaSpecification; +import org.hibernate.criterion.Projections; +import org.hibernate.criterion.Restrictions; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * ChannelFactory * @version $Rev$ @@ -52,6 +52,9 @@ public class ChannelFactory extends HibernateFactory { private static ChannelFactory singleton = new ChannelFactory(); private static Logger log = Logger.getLogger(ChannelFactory.class);
+ public static final ContentSourceType CONTENT_SOURCE_TYPE_YUM = + ChannelFactory.lookupContentSourceType("yum"); + private ChannelFactory() { super(); } @@ -110,6 +113,19 @@ public class ChannelFactory extends HibernateFactory { "Channel.findByLabelAndUserId", params); }
+ + /** + * Lookup a content source type by label + * @param label the label to lookup + * @return the ContentSourceType + */ + public static ContentSourceType lookupContentSourceType(String label) { + Map params = new HashMap(); + params.put("label", label); + return (ContentSourceType) singleton.lookupObjectByNamedQuery( + "ContentSourceType.findByLabel", params); + } + /** * Retrieve a list of channel ids associated with the labels provided * @param labelsIn the labels to search for @@ -129,7 +145,16 @@ public class ChannelFactory extends HibernateFactory { public static void save(Channel c) { singleton.saveObject(c); } - + + /** + * Insert or Update a content source. + * @param c content source to be stored in database. + */ + public static void save(ContentSource c) { + singleton.saveObject(c); + } + + /** * Remove a Channel from the DB * @param c Action to be removed from database. diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml new file mode 100644 index 0000000..2756941 --- /dev/null +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping +PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" +"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping> + <class name="com.redhat.rhn.domain.channel.ContentSource" + table="rhnChannelContentSource" > + + <id name="id" type="long" column="id"> + <meta attribute="scope-set">protected</meta> + <generator class="sequence"> + <param name="sequence">rhn_chan_content_src_id_seq</param> + </generator> + </id> + + <property name="sourceUrl" type="string" column="source_url"/> + <property name="lastSynced" type="timestamp" column="last_synced"/> + <property name="created" type="timestamp" column="created" insert="false" update="false" /> + <property name="modified" type="timestamp" column="modified" insert="false" update="false" /> + + + <many-to-one + name="type" + class="com.redhat.rhn.domain.channel.ContentSourceType" + column="type_id"/> + + <many-to-one + name="channel" + class="com.redhat.rhn.domain.channel.Channel" + column="channel_id" /> + + + </class> +</hibernate-mapping> diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java new file mode 100644 index 0000000..70a54e8 --- /dev/null +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java @@ -0,0 +1,114 @@ +/** + * Copyright (c) 2009 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 com.redhat.rhn.domain.channel; + +import com.redhat.rhn.domain.BaseDomainHelper; + +import java.util.Date; + +/** + * ContentSourceType + * @version $Rev$ + */ +public class ContentSource extends BaseDomainHelper { + + private Long id; + private Channel channel; + private ContentSourceType type; + private String sourceUrl; + private Date lastSynced; + + + /** + * @return Returns the id. + */ + public Long getId() { + return id; + } + + /** + * @param idIn The id to set. + */ + public void setId(Long idIn) { + this.id = idIn; + } + + + + /** + * @return Returns the chan. + */ + public Channel getChannel() { + return channel; + } + + + /** + * @param chanIn The chan to set. + */ + public void setChannel(Channel chanIn) { + this.channel = chanIn; + } + + + /** + * @return Returns the type. + */ + public ContentSourceType getType() { + return type; + } + + + /** + * @param typeIn The type to set. + */ + public void setType(ContentSourceType typeIn) { + this.type = typeIn; + } + + + /** + * @return Returns the sourceUrl. + */ + public String getSourceUrl() { + return sourceUrl; + } + + + /** + * @param sourceUrlIn The sourceUrl to set. + */ + public void setSourceUrl(String sourceUrlIn) { + this.sourceUrl = sourceUrlIn; + } + + /** + * @return Returns the lastSynced. + */ + public Date getLastSynced() { + return lastSynced; + } + + + /** + * @param lastSyncedIn The lastSynced to set. + */ + public void setLastSynced(Date lastSyncedIn) { + this.lastSynced = lastSyncedIn; + } + + + +} diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.hbm.xml new file mode 100644 index 0000000..f44342d --- /dev/null +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.hbm.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping +PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" +"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping> + <class name="com.redhat.rhn.domain.channel.ContentSourceType" + table="rhnContentSourceType" mutable="false"> + <cache usage="read-only"/> + <id name="id" type="long" column="id"> + <meta attribute="scope-set">protected</meta> + <generator class="sequence"> + <param name="sequence">rhn_content_source_type_id_seq</param> + </generator> + </id> + + <property name="label" type="string" column="label"/> + <property name="created" type="date" column="created"/> + <property name="modified" type="date" column="modified"/> + + </class> + + + <query name="ContentSourceType.findByLabel"> + <![CDATA[from com.redhat.rhn.domain.channel.ContentSourceType as c where c.label = :label]]> + </query> +</hibernate-mapping> diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.java new file mode 100644 index 0000000..9757457 --- /dev/null +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSourceType.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2009 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 com.redhat.rhn.domain.channel; + +import com.redhat.rhn.domain.BaseDomainHelper; + +/** + * ContentSourceType + * @version $Rev$ + */ +public class ContentSourceType extends BaseDomainHelper { + + private Long id; + private String label; + + + /** + * @return Returns the id. + */ + public Long getId() { + return id; + } + + /** + * @param i The id to set. + */ + public void setId(Long i) { + this.id = i; + } + + /** + * @return Returns the label. + */ + public String getLabel() { + return label; + } + + /** + * @param l The label to set. + */ + public void setLabel(String l) { + this.label = l; + } + + + +} diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java index a27c402..b5e2900 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java +++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java @@ -18,6 +18,7 @@ import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ChannelFamily; import com.redhat.rhn.domain.channel.ChannelFamilyFactory; +import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.errata.Errata; import com.redhat.rhn.domain.errata.test.ErrataFactoryTest; import com.redhat.rhn.domain.rhnpackage.Package; @@ -175,4 +176,17 @@ public class ChannelTest extends BaseTestCaseWithUser { }
} + + public void testContentSource() throws Exception { + Channel c = ChannelFactoryTest.createTestChannel(user); + ContentSource cs = new ContentSource(); + cs.setSourceUrl("fake url"); + cs.setChannel(c); + cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); + c.getContentSources().add(cs); + c = (Channel) TestUtils.saveAndReload(c); + assertNotEmpty(c.getContentSources()); + } + + } diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java index 0845b9f..d58ac62 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java @@ -14,30 +14,13 @@ */ package com.redhat.rhn.frontend.action.channel.manage;
-import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; -import org.apache.struts.action.DynaActionForm; - import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.common.localization.LocalizationService; import com.redhat.rhn.common.security.PermissionException; import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelArch; import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.role.RoleFactory; import com.redhat.rhn.domain.server.Server; @@ -59,6 +42,24 @@ import com.redhat.rhn.manager.channel.UpdateChannelCommand; import com.redhat.rhn.manager.system.SystemManager; import com.redhat.rhn.manager.user.UserManager;
+import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.action.DynaActionForm; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +
/** * EditChannelAction @@ -332,6 +333,7 @@ public class EditChannelAction extends RhnAction implements Listable { ucc.setMaintainerPhone((String)form.get("maintainer_phone")); ucc.setSupportPolicy((String)form.get("support_policy")); ucc.setAccess((String)form.get("org_sharing")); + ucc.setYumUrl((String) form.getString("yum_repo"));
String parent = (String)form.get("parent"); if (parent == null || parent.equals("")) { @@ -402,6 +404,7 @@ public class EditChannelAction extends RhnAction implements Listable { ccc.setMaintainerPhone((String)form.get("maintainer_phone")); ccc.setSupportPolicy((String)form.get("support_policy")); ccc.setAccess((String)form.get("org_sharing")); + ccc.setYumUrl((String) form.getString("yum_repo"));
String parent = (String)form.get("parent"); if (parent == null || parent.equals("")) { @@ -559,6 +562,23 @@ public class EditChannelAction extends RhnAction implements Listable { .getMessage("generic.jsp.none")); }
+ if (c.getContentSources().isEmpty()) { + form.set("yum_repo", ""); + request.setAttribute("last_sync", ""); + } + else { + ContentSource cs = c.getContentSources().iterator().next(); + form.set("yum_repo", cs.getSourceUrl()); + String lastSync = LocalizationService.getInstance().getMessage( + "channel.edit.repo.neversynced"); + if (cs.getLastSynced() != null) { + lastSync = LocalizationService.getInstance().formatDate( + cs.getLastSynced()); + } + request.setAttribute("last_sync", lastSync); + + } + request.setAttribute("channel_label", c.getLabel()); request.setAttribute("channel_name", c.getName()); request.setAttribute("channel_arch", c.getChannelArch().getName()); diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml index 12d363a..2499e27 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml @@ -8243,6 +8243,9 @@ Follow this url to see the full list of inactive systems: <trans-unit id="snapshots.configchannel"> <source>Configuration Channels Updated</source> </trans-unit> + <trans-unit id="channel.edit.repo.neversynced"> + <source>This repo has never been synced.</source> + </trans-unit> <trans-unit id="kickstart.cobbler.distro.syncfail"> <source> The following is a list of errors gathered while Spacewalk attempts to diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index 521532d..2580fb5 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -21329,9 +21329,15 @@ given channel.</source> <trans-unit id="channel.jsp.repolastbuild"> <source>Last Repo Build</source> </trans-unit> - - - + <trans-unit id="channel.edit.jsp.yumrepo"> + <source>Associated Yum Repository</source> + </trans-unit> + <trans-unit id="channel.edit.jsp.repourl"> + <source>Repository URL</source> + </trans-unit> + <trans-unit id="channel.edit.jsp.lastsynced"> + <source>Last Sync Time</source> + </trans-unit> </body> </file> </xliff> diff --git a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java index 8ee65e9..b219588 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java @@ -66,7 +66,10 @@ public class CreateChannelCommand { protected String maintainerPhone; protected String supportPolicy; protected String access = Channel.PRIVATE; + protected String yumUrl;
+ + /** * default constructor. */ @@ -265,6 +268,8 @@ public class CreateChannelCommand {
ChannelFactory.refreshNewestPackageCache(c, WEB_CHANNEL_CREATED);
+ c.setYumContentSource(yumUrl); + return c; }
@@ -411,4 +416,12 @@ public class CreateChannelCommand { throw new InvalidGPGUrlException(); } } + + /** + * @param yumUrlIn The yumUrl to set. + */ + public void setYumUrl(String yumUrlIn) { + this.yumUrl = yumUrlIn; + } + } diff --git a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java index 576fcc9..66d8673 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java @@ -77,6 +77,10 @@ public class UpdateChannelCommand extends CreateChannelCommand { c.setMaintainerEmail(maintainerEmail); c.setMaintainerPhone(maintainerPhone); c.setSupportPolicy(supportPolicy); + + + c.setYumContentSource(yumUrl); +
// need to save before calling stored proc below ChannelFactory.save(c); diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp index d7c45e4..7ee2632 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp @@ -108,6 +108,27 @@ </td> </tr> </table> + + + <h2><bean:message key="channel.edit.jsp.yumrepo"/></h2> + <table class="details"> + <tr> + <th> + <bean:message key="channel.edit.jsp.repourl"/>: + </th> + <td> + <html:text property="yum_repo" maxlength="512" size="60" /> + </td> + </tr> + <tr> + <th> + <bean:message key="channel.edit.jsp.lastsynced"/>: + </th> + <td> + <c:out value='${last_sync}'/> + </td> + </tr> + </table>
<h2><bean:message key="channel.edit.jsp.contactsupportinfo"/></h2> <table class="details"> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 5bd6f16..884ac91 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -840,6 +840,7 @@ <form-property name="maintainer_email" type="java.lang.String" /> <form-property name="maintainer_phone" type="java.lang.String" /> <form-property name="support_policy" type="java.lang.String" /> + <form-property name="yum_repo" type="java.lang.String" /> <form-property name="per_user_subscriptions" type="java.lang.String" /> <form-property name="org_sharing" type="java.lang.String" /> <form-property name="gpg_key_url" type="java.lang.String" /> diff --git a/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql new file mode 100644 index 0000000..26c3973 --- /dev/null +++ b/schema/spacewalk/rhnsat/tables/rhnChannelContentSource.sql @@ -0,0 +1,59 @@ +-- +-- 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. +-- +-- +-- +-- + +create table +rhnChannelContentSource +( + id number + constraint rhn_ccs_id_nn not null + constraint rhn_ccs_id_pk primary key, + channel_id number + constraint rhn_ccs_c_nn not null + constraint rhn_ccs_c_fk + references rhnChannel(id) on delete cascade, + type_id number + constraint rhn_ccs_type_nn not null + constraint rhn_ccs_type_fk + references rhnContentSourceType(id), + source_url varchar2(512) + constraint rhn_ccs_url_nn not null, + last_synced date, + created date default(sysdate) + constraint rhn_ccs_cre_nn not null, + modified date default(sysdate) + constraint rhn_ccs_mod_nn not null +) + enable row movement + ; + + +create sequence rhn_chan_content_src_id_seq start with 500; + + +create unique index rhn_ccs_uq + on rhnChannelContentSource(channel_id, type_id, source_url) + tablespace [[64k_tbs]] + ; + +/ +show errors + +-- +-- Revision 1.0 2009/06/26 21:54 jlsherrill +-- Initial file. +-- diff --git a/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql b/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql new file mode 100644 index 0000000..6e0ce24 --- /dev/null +++ b/schema/spacewalk/rhnsat/tables/rhnContentSourceType.sql @@ -0,0 +1,48 @@ +-- +-- 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. +-- +-- +-- +-- + +create table +rhnContentSourceType +( + id number + constraint rhn_cst_id_nn not null + constraint rhn_cst_id_pk primary key, + label varchar2(32) + constraint rhn_cst_label_nn not null + constraint rhn_cst_label_uq unique, + created date default(sysdate) + constraint rhn_cst_created_nn not null, + modified date default(sysdate) + constraint rhn_cst_modified_nn not null +) + enable row movement + ; + +create sequence rhn_content_source_type_id_seq start with 500; + +create index rhn_ccst_id_l_idx + on rhnContentSourceType(id,label) + tablespace [[64k_tbs]] + ; + +show errors + +-- +-- Revision 1.0 2002/11/13 21:50:21 jlsherrill +-- initial table add +-- diff --git a/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql b/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql new file mode 100644 index 0000000..db3424c --- /dev/null +++ b/schema/spacewalk/rhnsat/tables/rhnContentSourceType_data.sql @@ -0,0 +1,21 @@ +-- +-- 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. +-- +-- +-- +-- + +insert into rhnContentSourceType (id, label) values +(rhn_content_source_type_id_seq.nextval, 'yum'); + diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql new file mode 100644 index 0000000..546a3e1 --- /dev/null +++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnContentSoourceType.sql @@ -0,0 +1,46 @@ +-- +-- 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. +-- +-- +-- +-- + +create table +rhnContentSourceType +( + id number + constraint rhn_cst_id_nn not null + constraint rhn_cst_id_pk primary key, + label varchar2(32) + constraint rhn_cst_label_nn not null + constraint rhn_cst_label_uq unique, + created date default(sysdate) + constraint rhn_cst_created_nn not null, + modified date default(sysdate) + constraint rhn_cst_modified_nn not null +) + enable row movement + ; + +create sequence rhn_content_source_type_id_seq start with 500; + +create index rhn_ccst_id_l_idx + on rhnContentSourceType(id,label) + tablespace [[64k_tbs]] + ; + + +insert into rhnContentSourceType (id, label) values +(rhn_content_source_type_id_seq.nextval, 'yum'); + diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql new file mode 100644 index 0000000..a1445e1 --- /dev/null +++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/192-rhnChannelContentSoource.sql @@ -0,0 +1,55 @@ +-- +-- 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. +-- +-- +-- +-- + +create table +rhnChannelContentSource +( + id number + constraint rhn_ccs_id_nn not null + constraint rhn_ccs_id_pk primary key, + channel_id number + constraint rhn_ccs_c_nn not null + constraint rhn_ccs_c_fk + references rhnChannel(id) on delete cascade, + type_id number + constraint rhn_ccs_type_nn not null + constraint rhn_ccs_type_fk + references rhnContentSourceType(id), + source_url varchar2(512) + constraint rhn_ccs_url_nn not null, + last_synced date, + created date default(sysdate) + constraint rhn_ccs_cre_nn not null, + modified date default(sysdate) + constraint rhn_ccs_mod_nn not null +) + enable row movement + ; + + +create sequence rhn_chan_content_src_id_seq start with 500; + + +create unique index rhn_ccs_uq + on rhnChannelContentSource(channel_id, type_id, source_url) + tablespace [[64k_tbs]] + ; + +/ +show errors +
spacewalk-commits@lists.fedorahosted.org