Branch 'repo-sync' - java/code
by Justin Sherrill
java/code/src/com/redhat/rhn/domain/channel/Channel.java | 1 +
java/code/src/com/redhat/rhn/domain/task/TaskFactory.java | 10 +++++-----
java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java | 5 ++---
3 files changed, 8 insertions(+), 8 deletions(-)
New commits:
commit d9321c436afdf239f19d8df66d447217806496ba
Author: Justin Sherrill <jsherril(a)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());
14 years, 4 months
Changes to 'refs/tags/spacewalk-utils-0.6.6-1'
by Pradeep Kilambi
Tag 'spacewalk-utils-0.6.6-1' created by Pradeep Kilambi <pkilambi(a)redhat.com> at 2009-07-31 18:52 +0000
Tagging package [spacewalk-utils] version [0.6.6-1] in directory [utils/].
Changes since spacewalk-setup-0.6.16-1:
Jan Pazdziora (5):
513368 - call setpgrp to prevent kill 0 to propagate to jabberd and tomcat.
No --log option, print_progress does logging for us, sqlplus should print to STDOUT/STDERR.
/usr/sbin/oracle-nofcontext-selinux-enable needs semanage, let's add it to Requires everywhere.
The allow oracle_db_t oracle_sqlplus_log_t:file { write } is already specified above.
Use rw_files_pattern instead of direct allows, to get open on Fedora 12.
Justin Sherrill (2):
unit test fixes
514591 - fixing issue where empty string being passed in for some values on errata.create api would result in ISE 500
Pradeep Kilambi (5):
505559 - spacewalk-debug now captures database tablespace usage report
467281 - Instead of checksing for the start now we cechk if tools is in the channel label. This is not a perfect solution but atleast covers few more cases. An ideal solution would be to add some kind of a relation ship between parent and child signifying that this is a tools channel for a given parent.
514970 - removing the spacewalk common dependency on utils package so it can run on client. Added the locking supported moduled to utils package.
Merge branch 'master' of ssh://pkilambi@git.fedorahosted.org/git/spacewalk
Automatic commit of package [spacewalk-utils] release [0.6.6-1].
Shannon Hughes (1):
494409 - fix to unsubscribe child channels during trust removal
---
backend/satellite_tools/spacewalk-debug | 5
backend/server/rhnChannel.py | 2
java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java | 52 +++-
java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java | 2
java/code/src/com/redhat/rhn/manager/kickstart/test/KickstartManagerTest.java | 5
monitoring/ProgAGoGo/gogo.pl | 1
rel-eng/packages/spacewalk-utils | 2
selinux/oracle-selinux/oracle-selinux.spec | 8
selinux/oracle-xe-selinux/oracle-xe.te | 5
spacewalk/setup/lib/Spacewalk/Setup.pm | 1
utils/Makefile | 2
utils/migrate-system-profile | 2
utils/rhnLockfile.py | 112 ++++++++++
utils/rhn_fcntl.py | 44 +++
utils/spacewalk-utils.spec | 7
15 files changed, 220 insertions(+), 30 deletions(-)
---
14 years, 4 months
rel-eng/packages utils/spacewalk-utils.spec
by Pradeep Kilambi
rel-eng/packages/spacewalk-utils | 2 +-
utils/spacewalk-utils.spec | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
New commits:
commit a41821fba2bf4525c2bcf9339c582f999bb8bbc2
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Fri Jul 31 14:52:43 2009 -0400
Automatic commit of package [spacewalk-utils] release [0.6.6-1].
diff --git a/rel-eng/packages/spacewalk-utils b/rel-eng/packages/spacewalk-utils
index 215f738..6fd609e 100644
--- a/rel-eng/packages/spacewalk-utils
+++ b/rel-eng/packages/spacewalk-utils
@@ -1 +1 @@
-0.6.5-1 utils/
+0.6.6-1 utils/
diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec
index a34247a..7ccd37d 100644
--- a/utils/spacewalk-utils.spec
+++ b/utils/spacewalk-utils.spec
@@ -1,7 +1,7 @@
%define rhnroot %{_prefix}/share/rhn
Name: spacewalk-utils
-Version: 0.6.5
+Version: 0.6.6
Release: 1%{?dist}
Summary: Utilities that may be run against a Spacewalk server.
@@ -56,7 +56,7 @@ rm -rf $RPM_BUILD_ROOT
%changelog
-* Fri Jul 31 2009 Pradeep Kilambi <pkilambi(a)redhat.com>
+* Fri Jul 31 2009 Pradeep Kilambi <pkilambi(a)redhat.com> 0.6.6-1
- removing common module dep and adding locking to utils package.
* Wed Jul 15 2009 Miroslav Suchý <msuchy(a)redhat.com> 0.6.5-1
14 years, 4 months
Branch 'VADER' - utils/Makefile utils/migrate-system-profile utils/rhn_fcntl.py utils/rhnLockfile.py utils/spacewalk-utils.spec
by Pradeep Kilambi
utils/Makefile | 2
utils/migrate-system-profile | 2
utils/rhnLockfile.py | 112 +++++++++++++++++++++++++++++++++++++++++++
utils/rhn_fcntl.py | 44 ++++++++++++++++
utils/spacewalk-utils.spec | 5 +
5 files changed, 163 insertions(+), 2 deletions(-)
New commits:
commit 17f53a8856879bec8277454e8ef76474560f7316
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Fri Jul 31 14:49:47 2009 -0400
514970 - removing the spacewalk common dependency on utils package so it can run on client. Added the locking supported moduled to utils package.
diff --git a/utils/Makefile b/utils/Makefile
index b8cb8bf..7655ae3 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -6,7 +6,7 @@ NAME := spacewalk-utils
SUBDIR = utils
-FILES = __init__ systemSnapshot migrateSystemProfile
+FILES = __init__ systemSnapshot migrateSystemProfile rhnLockfile rhn_fcntl
SCRIPTS = sw-system-snapshot migrate-system-profile
DOCBOOK = $(wildcard /usr/bin/docbook2man)
diff --git a/utils/migrate-system-profile b/utils/migrate-system-profile
index 02da0fd..76daa6f 100755
--- a/utils/migrate-system-profile
+++ b/utils/migrate-system-profile
@@ -53,7 +53,7 @@ if os.getuid() != 0:
try:
- from common import rhnLockfile, CFG, fetchTraceback
+ from utils import rhnLockfile
except KeyboardInterrupt:
systemExit(0, "\nUser interrupted process.")
except ImportError:
diff --git a/utils/rhnLockfile.py b/utils/rhnLockfile.py
new file mode 100644
index 0000000..e6e6cfb
--- /dev/null
+++ b/utils/rhnLockfile.py
@@ -0,0 +1,112 @@
+#
+# 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 os
+import sys
+import fcntl
+from errno import EWOULDBLOCK, EEXIST
+import rhn_fcntl
+
+# NOTE: rhn_fcntl is deprecated in Python 2.2, just use fcntl
+
+class LockfileLockedException(Exception):
+ """thrown ONLY when pid file is locked."""
+ pass
+
+class Lockfile:
+
+ """class that provides simple access to a PID-style lockfile.
+
+ methods: __init__(lockfile), acquire(), and release()
+ NOTE: currently acquires upon init
+ The *.pid file will be acquired, or an LockfileLockedException is raised.
+ """
+
+ def __init__(self, lockfile, pid=None):
+ """create (if need be), and acquire lock on lockfile
+
+ lockfile example: '/var/run/up2date.pid'
+ """
+
+ # cleanup the path and assign it.
+ self.lockfile = os.path.abspath(
+ os.path.expanduser(
+ os.path.expandvars(lockfile)))
+
+ self.pid = pid
+ if not self.pid:
+ self.pid = os.getpid()
+
+ # create the directory structure
+ dirname = os.path.dirname(self.lockfile)
+ if not os.path.exists(dirname):
+ try:
+ os.makedirs(dirname)
+ except OSError, e:
+ if hasattr(e, 'errno') and e.errno == EEXIST:
+ # race condition... dirname exists now.
+ pass
+ else:
+ raise
+
+ # open the file -- non-destructive read-write, unless it needs
+ # to be created XXX: potential race condition upon create?
+ self.f = os.open(self.lockfile, os.O_RDWR|os.O_CREAT|os.O_SYNC)
+ self.acquire()
+
+ def acquire(self):
+ """acquire the lock; else raise LockfileLockedException."""
+
+ try:
+ fcntl.flock(self.f, fcntl.LOCK_EX|fcntl.LOCK_NB)
+ except IOError, e:
+ if e.errno == EWOULDBLOCK:
+ raise LockfileLockedException(
+ "cannot acquire lock on %s." % self.lockfile)
+ else:
+ raise
+ # unlock upon exit
+ fcntl.fcntl(self.f, rhn_fcntl.F_SETFD, 1)
+ # truncate and write the pid
+ os.ftruncate(self.f, 0)
+ os.write(self.f, str(self.pid) + '\n')
+
+ def release(self):
+ # Remove the lock file
+ os.unlink(self.lockfile)
+ fcntl.flock(self.f, fcntl.LOCK_UN)
+ os.close(self.f)
+
+
+def main():
+ """test code"""
+
+ try:
+ L = Lockfile('./test.pid')
+ except LockfileLockedException, e:
+ sys.stderr.write("%s\n" % e)
+ sys.exit(-1)
+ else:
+ print "lock acquired "
+ print "...sleeping for 10 seconds"
+ import time
+ time.sleep(10)
+ L.release()
+ print "lock released "
+
+if __name__ == '__main__':
+ # test code
+ sys.exit(main() or 0)
+
diff --git a/utils/rhn_fcntl.py b/utils/rhn_fcntl.py
new file mode 100644
index 0000000..c1ba42f
--- /dev/null
+++ b/utils/rhn_fcntl.py
@@ -0,0 +1,44 @@
+#!/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.
+#
+
+
+import fcntl
+
+
+symbols = [
+ 'F_RDLCK', 'F_WRLCK', 'F_UNLCK', 'F_SETLKW',
+ 'F_SETFD', 'F_GETFD',
+]
+
+
+if hasattr(fcntl, symbols[0]):
+ module = fcntl
+else:
+ import FCNTL
+ module = FCNTL
+ del FCNTL
+del fcntl
+
+
+dict = globals()
+for symbol in symbols:
+ dict[symbol] = getattr(module, symbol)
+
+
+del dict
+del symbol
+del symbols
+del module
diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec
index 16559c7..0963e46 100644
--- a/utils/spacewalk-utils.spec
+++ b/utils/spacewalk-utils.spec
@@ -50,11 +50,16 @@ rm -rf $RPM_BUILD_ROOT
%{rhnroot}/utils/__init__.py*
%{rhnroot}/utils/systemSnapshot.py*
%{rhnroot}/utils/migrateSystemProfile.py*
+%{rhnroot}/utils/rhnLockfile.py*
+%{rhnroot}/utils/rhn_fcntl.py*
%{_mandir}/man8/sw-system-snapshot.8*
%{_mandir}/man8/migrate-system-profile.8*
%changelog
+* Fri Jul 31 2009 Pradeep Kilambi <pkilambi(a)redhat.com>
+- removing common module dep and adding locking to utils package.
+
* Fri Apr 24 2009 jesus m. rodriguez <jesusr(a)redhat.com> 0.5.1-1
- new package
14 years, 4 months
Branch 'VADER' - java/buildconf
by Justin Sherrill
java/buildconf/apidoc/singlepage/api_index_ftr.txt | 5 +
java/buildconf/apidoc/singlepage/api_index_hdr.txt | 10 +++
java/buildconf/apidoc/singlepage/apiindex.txt | 7 ++
java/buildconf/apidoc/singlepage/faqs.txt | 20 +++++++
java/buildconf/apidoc/singlepage/scripts.txt | 60 +++++++++++++++++++++
5 files changed, 102 insertions(+)
New commits:
commit b646e6f7af384093fac786b5d04fa4a9e51c1ae1
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Fri Jul 31 14:46:35 2009 -0400
adding singlepage apidoc templates that were never merged to VADER
diff --git a/java/buildconf/apidoc/singlepage/api_index_ftr.txt b/java/buildconf/apidoc/singlepage/api_index_ftr.txt
new file mode 100644
index 0000000..0274132
--- /dev/null
+++ b/java/buildconf/apidoc/singlepage/api_index_ftr.txt
@@ -0,0 +1,5 @@
+ </ul>
+</body>
+
+Generated on: $current_date
+</html>
diff --git a/java/buildconf/apidoc/singlepage/api_index_hdr.txt b/java/buildconf/apidoc/singlepage/api_index_hdr.txt
new file mode 100644
index 0000000..4221b55
--- /dev/null
+++ b/java/buildconf/apidoc/singlepage/api_index_hdr.txt
@@ -0,0 +1,10 @@
+<html>
+<head>
+ <meta http-equiv="cache-control" content="no-cache" />
+
+</head>
+<body>
+<h3><img src="../img/rhn-icon-api.gif" /><a href="index.html">API Overview</a></h3>
+Welcome to the RHN Satellite API. By using the included API calls, you can more easily automate many of the tasks you perform everyday. All API calls are grouped by common functionality. <a href="faqs.html">Faqs</a> and <a href="scripts.html">example scripts</a> are available.
+<h2>Namespaces</h2>
+ <ul class="apidoc">
diff --git a/java/buildconf/apidoc/singlepage/apiindex.txt b/java/buildconf/apidoc/singlepage/apiindex.txt
new file mode 100644
index 0000000..cca8bbd
--- /dev/null
+++ b/java/buildconf/apidoc/singlepage/apiindex.txt
@@ -0,0 +1,7 @@
+<a name="#top">Red Hat Satellite API Documentation</a>
+<ul>
+#foreach( $handler in $handlers )
+ <li><a href="#${handler.name}">$handler.name</a></li>
+#end
+</ul>
+<hr>
diff --git a/java/buildconf/apidoc/singlepage/faqs.txt b/java/buildconf/apidoc/singlepage/faqs.txt
new file mode 100644
index 0000000..6d2661d
--- /dev/null
+++ b/java/buildconf/apidoc/singlepage/faqs.txt
@@ -0,0 +1,20 @@
+<html>
+<head>
+ <meta http-equiv="cache-control" content="no-cache" />
+
+</head>
+<body>
+<h1><img src="../img/rhn-icon-api.gif" alt="application program interface" /><a href="faqs.html">Frequently Asked Questions</a></h1>
+<p />
+<ul>
+ <dt>What programming languages are supported by the Satellite's api?</dt>
+ <dd>Any language that provides an XMLRPC client interface will work with the Satellite's API. While Perl and Python are two of the most commonly used, an XMLRPC client implementation is available in most every common language. </dd>
+ <br />
+ <dt>When trying to call a specific function, the error "Fault returned from XML RPC Server, fault code -1: Could not find method METHOD in class..." is given. What is wrong?</dt>
+ <dd>Typically this is seen when either a function name is being called that doesn't exist, the number of parameters for a particular function is incorrect, or the type of a passed parameter is incorrect (Such as an array is expected, but a String is passed). Check all of these things.</dd>
+ <br />
+ <dt>Should I call an API method using the naming scheme "methodName" or "method_name"?</dt>
+ <dd>Both of these are valid names for the same method, so use whichever you prefer.</dd>
+</ul>
+</body>
+</html>
diff --git a/java/buildconf/apidoc/singlepage/scripts.txt b/java/buildconf/apidoc/singlepage/scripts.txt
new file mode 100644
index 0000000..23c0126
--- /dev/null
+++ b/java/buildconf/apidoc/singlepage/scripts.txt
@@ -0,0 +1,60 @@
+<html>
+<head>
+ <meta http-equiv="cache-control" content="no-cache" />
+
+</head>
+<body>
+<h1><img src="./img/rhn-icon-api.gif" alt="application program interface" /><a href="../scripts.html">Sample Scripts</a></h1>
+<h2>Sample Scripts</h2>
+<h3>Perl example:</h3><BR>
+This Perl example shows the system.listUserSystems call being used to get a list of systems a user has access to. In the example below, the name of each system will be printed.
+The Frontier::Client Perl module can be found in the "perl-Frontier-RPC" rpm contained in the newest Satellite channel on http://rhn.redhat.com.
+<p />
+
+<code>
+#!/usr/bin/perl<br/>
+use Frontier::Client;<br />
+<br />
+my $HOST = 'satellite.example.com';<br />
+my $user = 'username';<br />
+my $pass = 'password';<br />
+<br />
+my $client = new Frontier::Client(url => "http://$HOST/rpc/api");<br />
+my $session = $client->call('auth.login',$user, $pass);<br />
+<br />
+my $systems = $client->call('system.listUserSystems', $session);<br />
+foreach my $system (@$systems) {<br />
+ print $system->{'name'}."\n";<br />
+}<br />
+$client->call('auth.logout', $session);</br>
+</code>
+<hr />
+<p />
+<h3>Python example:</h3><br />
+Below is an example of the user.listAdministeredSystemGroups call being used. Only the name of each group is printed.
+<p />
+
+<code>
+#!/usr/bin/python<br />
+import xmlrpclib<br />
+<br />
+SATELLITE_URL = "http://satellite.example.com/rpc/api"<br />
+SATELLITE_LOGIN = "username"<br />
+SATELLITE_PASSWORD = "password"<br />
+<br />
+client = xmlrpclib.Server(SATELLITE_URL, verbose=0)<br />
+<br />
+key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)<br />
+list = client.user.list_users(key, 'admin')<br />
+for user in list:<br />
+ print user.get('login')<br />
+<br />
+client.auth.logout(key)<br />
+</code>
+<hr />
+
+For more examples visit the <a href="https://fedorahosted.org/spacewalk/">Spacewalk community page</a>.
+
+<p />
+</body><p />
+</html><p />
14 years, 4 months
java/code
by Shannon Hughes
java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java | 52 +++++++---
1 file changed, 38 insertions(+), 14 deletions(-)
New commits:
commit b12b5d8f0dccce0721b10e2c9ce606c80e085fc6
Author: Shannon Hughes <shughes(a)redhat.com>
Date: Fri Jul 31 14:15:05 2009 -0400
494409 - fix to unsubscribe child channels during trust removal
diff --git a/java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java b/java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java
index 2d34264..81f37f5 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java
@@ -14,10 +14,27 @@
*/
package com.redhat.rhn.frontend.action.multiorg;
+import java.util.ArrayList;
+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.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
import com.redhat.rhn.common.db.datasource.DataResult;
+import com.redhat.rhn.domain.channel.Channel;
+import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import com.redhat.rhn.domain.rhnset.RhnSet;
+import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
import com.redhat.rhn.frontend.dto.OrgTrust;
@@ -30,18 +47,6 @@ import com.redhat.rhn.manager.rhnset.RhnSetDecl;
import com.redhat.rhn.manager.rhnset.RhnSetManager;
import com.redhat.rhn.manager.system.SystemManager;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
/**
* Abstract POST action class that provides for setup->confirm->commit
* lifecycle. This should probably be added as a <i>real</i> class and
@@ -251,15 +256,34 @@ public class TrustAction extends FormDispatcher {
User orgUser = UserFactory.findRandomOrgAdmin(theOrg);
for (Org removed : getRemoved(theOrg, set)) {
theOrg.removeTrust(removed);
+ User orgAdmin = UserFactory.findRandomOrgAdmin(removed);
DataResult<Map> dr =
SystemManager.subscribedInOrgTrust(theOrg.getId(), removed.getId());
for (Map item : dr) {
Long sid = (Long)item.get("id");
- Long cid = (Long)item.get("cid");
+ Server s = ServerFactory.lookupById(sid);
+ Long cid = (Long)item.get("cid");
+ Channel channel = ChannelFactory.lookupById(cid);
+ if (channel.getParentChannel() == null) {
+ // unsubscribe children first if subscribed
+ List<Channel> children = channel
+ .getAccessibleChildrenFor(orgUser);
+ Iterator<Channel> i = children.iterator();
+ while (i.hasNext()) {
+ Channel child = (Channel) i.next();
+ if (s.isSubscribed(child)) {
+ // unsubscribe server from child channel
+ child.getTrustedOrgs().remove(theOrg);
+ ChannelFactory.save(child);
+ s = SystemManager.
+ unsubscribeServerFromChannel(s, child);
+ }
+ }
+ }
+ ChannelFactory.save(channel);
SystemManager.unsubscribeServerFromChannel(orgUser, sid, cid);
}
-
}
OrgFactory.save(theOrg);
14 years, 4 months
Branch 'VADER' - java/code
by Shannon Hughes
java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java | 52 +++++++---
1 file changed, 38 insertions(+), 14 deletions(-)
New commits:
commit 9ad1a4df2263d0f353b02122f3f3584d9ce96cbe
Author: Shannon Hughes <shughes(a)redhat.com>
Date: Fri Jul 31 14:15:05 2009 -0400
494409 - fix to unsubscribe child channels during trust removal
diff --git a/java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java b/java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java
index 2d34264..81f37f5 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/multiorg/TrustAction.java
@@ -14,10 +14,27 @@
*/
package com.redhat.rhn.frontend.action.multiorg;
+import java.util.ArrayList;
+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.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
import com.redhat.rhn.common.db.datasource.DataResult;
+import com.redhat.rhn.domain.channel.Channel;
+import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import com.redhat.rhn.domain.rhnset.RhnSet;
+import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
import com.redhat.rhn.frontend.dto.OrgTrust;
@@ -30,18 +47,6 @@ import com.redhat.rhn.manager.rhnset.RhnSetDecl;
import com.redhat.rhn.manager.rhnset.RhnSetManager;
import com.redhat.rhn.manager.system.SystemManager;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
/**
* Abstract POST action class that provides for setup->confirm->commit
* lifecycle. This should probably be added as a <i>real</i> class and
@@ -251,15 +256,34 @@ public class TrustAction extends FormDispatcher {
User orgUser = UserFactory.findRandomOrgAdmin(theOrg);
for (Org removed : getRemoved(theOrg, set)) {
theOrg.removeTrust(removed);
+ User orgAdmin = UserFactory.findRandomOrgAdmin(removed);
DataResult<Map> dr =
SystemManager.subscribedInOrgTrust(theOrg.getId(), removed.getId());
for (Map item : dr) {
Long sid = (Long)item.get("id");
- Long cid = (Long)item.get("cid");
+ Server s = ServerFactory.lookupById(sid);
+ Long cid = (Long)item.get("cid");
+ Channel channel = ChannelFactory.lookupById(cid);
+ if (channel.getParentChannel() == null) {
+ // unsubscribe children first if subscribed
+ List<Channel> children = channel
+ .getAccessibleChildrenFor(orgUser);
+ Iterator<Channel> i = children.iterator();
+ while (i.hasNext()) {
+ Channel child = (Channel) i.next();
+ if (s.isSubscribed(child)) {
+ // unsubscribe server from child channel
+ child.getTrustedOrgs().remove(theOrg);
+ ChannelFactory.save(child);
+ s = SystemManager.
+ unsubscribeServerFromChannel(s, child);
+ }
+ }
+ }
+ ChannelFactory.save(channel);
SystemManager.unsubscribeServerFromChannel(orgUser, sid, cid);
}
-
}
OrgFactory.save(theOrg);
14 years, 4 months
2 commits - utils/Makefile utils/migrate-system-profile utils/rhn_fcntl.py utils/rhnLockfile.py utils/spacewalk-utils.spec
by Pradeep Kilambi
utils/Makefile | 2
utils/migrate-system-profile | 2
utils/rhnLockfile.py | 112 +++++++++++++++++++++++++++++++++++++++++++
utils/rhn_fcntl.py | 44 ++++++++++++++++
utils/spacewalk-utils.spec | 5 +
5 files changed, 163 insertions(+), 2 deletions(-)
New commits:
commit c6aaa1f5c5fe577bf66c83779202134094317ae1
Merge: 1b32acc... e294153...
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Fri Jul 31 14:24:05 2009 -0400
Merge branch 'master' of ssh://pkilambi@git.fedorahosted.org/git/spacewalk
commit 1b32acc1b98f6c72e42e9abbd595a8b93ea24cb5
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Fri Jul 31 14:23:46 2009 -0400
514970 - removing the spacewalk common dependency on utils package so it can run on client. Added the locking supported moduled to utils package.
diff --git a/utils/Makefile b/utils/Makefile
index fa6ceb0..834eee7 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -6,7 +6,7 @@ NAME := spacewalk-utils
SUBDIR = utils
-FILES = __init__ systemSnapshot migrateSystemProfile
+FILES = __init__ systemSnapshot migrateSystemProfile rhnLockfile rhn_fcntl
SCRIPTS = sw-system-snapshot migrate-system-profile spacewalk-api
DOCBOOK = $(wildcard /usr/bin/docbook2man)
diff --git a/utils/migrate-system-profile b/utils/migrate-system-profile
index 02da0fd..76daa6f 100755
--- a/utils/migrate-system-profile
+++ b/utils/migrate-system-profile
@@ -53,7 +53,7 @@ if os.getuid() != 0:
try:
- from common import rhnLockfile, CFG, fetchTraceback
+ from utils import rhnLockfile
except KeyboardInterrupt:
systemExit(0, "\nUser interrupted process.")
except ImportError:
diff --git a/utils/rhnLockfile.py b/utils/rhnLockfile.py
new file mode 100644
index 0000000..e6e6cfb
--- /dev/null
+++ b/utils/rhnLockfile.py
@@ -0,0 +1,112 @@
+#
+# 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 os
+import sys
+import fcntl
+from errno import EWOULDBLOCK, EEXIST
+import rhn_fcntl
+
+# NOTE: rhn_fcntl is deprecated in Python 2.2, just use fcntl
+
+class LockfileLockedException(Exception):
+ """thrown ONLY when pid file is locked."""
+ pass
+
+class Lockfile:
+
+ """class that provides simple access to a PID-style lockfile.
+
+ methods: __init__(lockfile), acquire(), and release()
+ NOTE: currently acquires upon init
+ The *.pid file will be acquired, or an LockfileLockedException is raised.
+ """
+
+ def __init__(self, lockfile, pid=None):
+ """create (if need be), and acquire lock on lockfile
+
+ lockfile example: '/var/run/up2date.pid'
+ """
+
+ # cleanup the path and assign it.
+ self.lockfile = os.path.abspath(
+ os.path.expanduser(
+ os.path.expandvars(lockfile)))
+
+ self.pid = pid
+ if not self.pid:
+ self.pid = os.getpid()
+
+ # create the directory structure
+ dirname = os.path.dirname(self.lockfile)
+ if not os.path.exists(dirname):
+ try:
+ os.makedirs(dirname)
+ except OSError, e:
+ if hasattr(e, 'errno') and e.errno == EEXIST:
+ # race condition... dirname exists now.
+ pass
+ else:
+ raise
+
+ # open the file -- non-destructive read-write, unless it needs
+ # to be created XXX: potential race condition upon create?
+ self.f = os.open(self.lockfile, os.O_RDWR|os.O_CREAT|os.O_SYNC)
+ self.acquire()
+
+ def acquire(self):
+ """acquire the lock; else raise LockfileLockedException."""
+
+ try:
+ fcntl.flock(self.f, fcntl.LOCK_EX|fcntl.LOCK_NB)
+ except IOError, e:
+ if e.errno == EWOULDBLOCK:
+ raise LockfileLockedException(
+ "cannot acquire lock on %s." % self.lockfile)
+ else:
+ raise
+ # unlock upon exit
+ fcntl.fcntl(self.f, rhn_fcntl.F_SETFD, 1)
+ # truncate and write the pid
+ os.ftruncate(self.f, 0)
+ os.write(self.f, str(self.pid) + '\n')
+
+ def release(self):
+ # Remove the lock file
+ os.unlink(self.lockfile)
+ fcntl.flock(self.f, fcntl.LOCK_UN)
+ os.close(self.f)
+
+
+def main():
+ """test code"""
+
+ try:
+ L = Lockfile('./test.pid')
+ except LockfileLockedException, e:
+ sys.stderr.write("%s\n" % e)
+ sys.exit(-1)
+ else:
+ print "lock acquired "
+ print "...sleeping for 10 seconds"
+ import time
+ time.sleep(10)
+ L.release()
+ print "lock released "
+
+if __name__ == '__main__':
+ # test code
+ sys.exit(main() or 0)
+
diff --git a/utils/rhn_fcntl.py b/utils/rhn_fcntl.py
new file mode 100644
index 0000000..c1ba42f
--- /dev/null
+++ b/utils/rhn_fcntl.py
@@ -0,0 +1,44 @@
+#!/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.
+#
+
+
+import fcntl
+
+
+symbols = [
+ 'F_RDLCK', 'F_WRLCK', 'F_UNLCK', 'F_SETLKW',
+ 'F_SETFD', 'F_GETFD',
+]
+
+
+if hasattr(fcntl, symbols[0]):
+ module = fcntl
+else:
+ import FCNTL
+ module = FCNTL
+ del FCNTL
+del fcntl
+
+
+dict = globals()
+for symbol in symbols:
+ dict[symbol] = getattr(module, symbol)
+
+
+del dict
+del symbol
+del symbols
+del module
diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec
index 6c946db..a34247a 100644
--- a/utils/spacewalk-utils.spec
+++ b/utils/spacewalk-utils.spec
@@ -50,10 +50,15 @@ rm -rf $RPM_BUILD_ROOT
%{rhnroot}/utils/__init__.py*
%{rhnroot}/utils/systemSnapshot.py*
%{rhnroot}/utils/migrateSystemProfile.py*
+%{rhnroot}/utils/rhnLockfile.py*
+%{rhnroot}/utils/rhn_fcntl.py*
%{_mandir}/man8/*
%changelog
+* Fri Jul 31 2009 Pradeep Kilambi <pkilambi(a)redhat.com>
+- removing common module dep and adding locking to utils package.
+
* Wed Jul 15 2009 Miroslav Suchý <msuchy(a)redhat.com> 0.6.5-1
- add spacewalk-api script, which can interact with API from command line
14 years, 4 months
java/code
by Justin Sherrill
java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit e2941539cc4ce907a358de8faf965789320147ea
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Fri Jul 31 14:16:06 2009 -0400
514591 - fixing issue where empty string being passed in for some values on errata.create api would result in ISE 500
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java
index ae4002b..d972fcd 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java
@@ -842,7 +842,7 @@ public class ErrataHandler extends BaseHandler {
private Object getRequiredAttribute(Map map, String attribute) {
Object value = map.get(attribute);
- if (value == null) {
+ if (value == null || StringUtils.isEmpty(value.toString())) {
throw new MissingErrataAttributeException(attribute);
}
else {
14 years, 4 months
backend/server
by Pradeep Kilambi
backend/server/rhnChannel.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 0bcf3672c1a4fd995b8bcec6fe12ea3b91eda1f8
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Fri Jul 31 13:05:49 2009 -0400
467281 - Instead of checksing for the start now we cechk if tools is in the channel label. This is not a perfect solution but atleast covers few more cases. An ideal solution would be to add some kind of a relation ship between parent and child signifying that this is a tools channel for a given parent.
diff --git a/backend/server/rhnChannel.py b/backend/server/rhnChannel.py
index e0a28f2..926402c 100644
--- a/backend/server/rhnChannel.py
+++ b/backend/server/rhnChannel.py
@@ -2402,7 +2402,7 @@ def subscribe_to_tools_channel(server_id):
tools_channel = None
for channel in child_channels:
if channel.has_key('label'):
- if channel['label'].find('rhn-tools') == 0:
+ if 'rhn-tools' in channel['label']:
tools_channel = channel
if tools_channel is None:
14 years, 4 months