[Spacewalk-devel] New serializer returning array of arrays instead of array of hashes

2012-08-27 Thread Aron Parsons
I added the ContentSourceFilterSerializer recently
(fb091b6a20074fc861840952091e36b10c06..78e04edac79095c52849f300f0a3f170da0a0db7)
for the channel.software.listRepoFilters API function but can't get it
to return exactly what I want.  Instead of returning an array of
hashes, it returns an array of arrays.

Returns:
[ [1, '+', 'cobbler'] ]

What I want:
[ {'sortOrder' : 1, 'flag' : '+', 'filter' : 'cobbler'} ]

Any help?  In looking at most of the other serializers, I really don't
see what's out of place.

/aron

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] [PATCH 00/03][spacecmd] Call (raw) api directly from spacecmd

2011-08-04 Thread Aron Parsons
Committed.

Out of curiosity, how are you using the JSON output?

/aron

- Original Message -
From: Satoru SATOH satoru.sa...@gmail.com
To: spacewalk-devel@redhat.com
Subject: [Spacewalk-devel] [PATCH 00/03][spacecmd] Call (raw) api
directlyfrom spacecmd
Message-ID: 20110729091334.GA6963@localhost.localdomain
Content-Type: text/plain; charset=us-ascii

Hi,

I wrote a series of patch adding new 'api' sub command to spacecmd, to
call raw api (ex. channel.software.listErrata) from spacecmd.

Could you please review these?

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] [Patch] List repos from spacecmd

2011-03-28 Thread Aron Parsons
Trent,
Thanks for the patch.  I created a new module for repos, so the repo functions
are now repo_list and repo_details; softwarechannel was getting a bit cluttered.
They should be there in versions = 1.4.5.

I don't use repos in Spacewalk, but I'd be more than happy to commit any patches
that implement this functionality.  

Aron Parsons, RHCA
Senior Consultant
Red Hat Consulting

- Original Message -
Date: Mon, 28 Mar 2011 08:30:52 -0500
From: Trent Johnson tljoh...@oreillyschool.com
To: spacewalk-devel@redhat.com
Subject: [Spacewalk-devel] [Patch] List repos from spacecmd
Message-ID: 4d908d8c.8060...@oreillyschool.com
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I needed to list repos from spacecmd.  See attached.

Also, it would be nice if repos could be associated etc. from spacecmd.

Thanks,
Trent


--- old//usr/lib/python2.6/site-packages/spacecmd/softwarechannel.py 
2011-03-28 07:45:40.062935272 -0500
+++ /usr/lib/python2.6/site-packages/spacecmd/softwarechannel.py 
2011-03-28 07:40:13.962940058 -0500
@@ -67,6 +67,21 @@
  print '\n'.join(sorted(channels))

  
+def help_softwarechannel_listrepos(self):
+print 'softwarechannel_listrepos: List all available user repos'
+print 'usage: softwarechannel_listrepos'
+
+def do_softwarechannel_listrepos(self, args, doreturn=False):
+repos = self.client.channel.software.listUserRepos(self.session)
+repos = [c.get('label') for c in repos]
+
+if doreturn:
+return repos
+else:
+if len(repos):
+print '\n'.join(sorted(repos))
+
+

  def help_softwarechannel_listbasechannels(self):
  print 'softwarechannel_listbasechannels: List all base software 
channels'
@@ -260,6 +275,38 @@

  

+def help_softwarechannel_repodetails(self):
+print 'softwarechannel_repodetails: Show the details of a user repo'
+print 'usage: softwarechannel_repodetails repo ...'
+
+def complete_softwarechannel_repodetails(self, text, line, beg, end):
+return tab_completer(self.do_softwarechannel_listrepos('', True), text)
+
+def do_softwarechannel_repodetails(self, args):
+(args, options) = parse_arguments(args)
+
+if not len(args):
+self.help_softwarechannel_repodetails()
+return
+
+# allow globbing of software channel names
+repos = filter_results(self.do_softwarechannel_listrepos('', True), 
args)
+
+add_separator = False
+
+for repo in repos:
+details = self.client.channel.software.getRepoDetails(\
+self.session, repo)
+
+if add_separator: print self.SEPARATOR
+add_separator = True
+
+print 'Repository Label:   %s' % details.get('label')
+print 'Repository Url: %s' % details.get('sourceUrl')
+print 'Repository Type:%s' % details.get('type')
+
+
+
  def help_softwarechannel_listerrata(self):
  print 'softwarechannel_listerrata: List the errata associated with a'
  print 'software channel'



--

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

End of Spacewalk-devel Digest, Vol 34, Issue 28
***

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] SystemManagerTest.testSystemSearch junit test

2010-12-16 Thread Aron Parsons
Tomas,
It should be fixed with commit 9d4a84d50842a03f61fd2496cb5b5af922c58c47.  Sorry 
for that,
I was rushing things along at the end of the day when I pushed those commits.

/aron

- Original Message -
From: Tomas Lestach tlest...@redhat.com
To: Aron Parsons apars...@redhat.com
Cc: spacewalk-devel@redhat.com
Sent: Wednesday, December 15, 2010 1:08:02 PM GMT -05:00 US/Canada Eastern
Subject: SystemManagerTest.testSystemSearch junit test

Hello Aron,

I saw, one of our junit tests failed:

com.redhat.rhn.manager.system.test.SystemManagerTest.testSystemSearch

...

systemsearch_uuid is empty with value: e280ccb0-1f31-11dc-9c52-00425200ea2f
Stacktrace

junit.framework.AssertionFailedError: systemsearch_uuid is empty with 
value: e280ccb0-1f31-11dc-9c52-00425200ea2f
at 
com.redhat.rhn.manager.system.test.SystemManagerTest.testSystemSearch(SystemManagerTest.java:793)


It looks it's caused by the commit
f4ec077413cf6d5b1510ff58d81560272ed453ff
especially:

+/* UUID setup */
+ServerUuid uuid = ServerUuidTest.createTestServerUuid();
+uuid.setServer(s);
+s.setServerUuid(uuid);
+

If you check the createTestServerUuid method, you'll find out that the 
method creates a new org, new user, new server and associated the server 
with an UUID. The server-uuid association gets stored into the DB. So, 
if you then update the server, the change won't get reflected into the 
DB as well. That causes later search to fail.
At the first look, I'd say, it's not appropriate to call this method to 
get an UUID.

Could you check the issue, please?

Regards,
Tomas
-- 
Tomas Lestach
RHN Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] Spacecmd Errors against Spacewalk 1.0 (and 1.1)

2010-08-23 Thread Aron Parsons
I am going to have to defer this to the rest of the team since the
problem doesn't seem to be with spacecmd itself, it's just exposing the
problem on the Spacewalk server itself.  However, just a few more
questions I would ask to help debug it:

- What's your database setup?
- What versions of the client tools are on the sytsems that expose the
behavior?
- Can you reproduce this on a 100% clean install?

-- 
/aron


On Mon, 2010-08-23 at 10:55 +0200, Christoph Sievers wrote:
 Am 23.08.10 10:24, schrieb Tomas Lestach:
 
  Regarding the rhn_web_api.log, there was an exception thrown, but there was 
  a problem in the exception handling and a new exception was thrown 
  (Stopwatch is not running), so we do not have any information about the 
  original exception. :(
  Not sure, why the StopWatch wasn't initialized. I suppose tomcat log would 
  say more.
 
 Hi,
 
 catalina.out get these entries when I run into the error. I have this
 error on every Spacewalk I installed (running 5).
 
 
 redstone.xmlrpc.XmlRpcDispatcher writeError
 WARNING: java.lang.NullPointerException: null
 
 
 shall I set any debug stuff for the tomcat5? If so.. how?
 
 rgds
 Christoph
 
 P.S. reformatted output of the server response. Looks like from
 retrieving installtime on it crashes?
 
 begin
 
 ?xml version=1.0 encoding=UTF-8?
  methodResponse
   params
param
 value
  array
   data
value
 struct
  member
   namearch/name
   value
stringx86_64/string
   /value
  /member
  member
   nameinstalltime/name
   value
?xml version=1.0 encoding=UTF-8?
 methodResponse
  fault
   value
struct
 member
  namefaultCode/name
  value
   int-1/int
  /value
 /member
 member
  namefaultString/name
  value
   stringjava.lang.NullPointerException: null/string
  /value
 /member
/struct
   /value
  /fault
 /methodResponse
 
 end

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] Spacecmd Errors against Spacewalk 1.0 (and 1.1)

2010-08-23 Thread Aron Parsons
AFAIK you'll need to the reactivation key/rhnreg_ks --force dance for
all of the systems.  However, it should be a really simple API script to
write up.  Just call system.obtainReactivationKey and then pass that
into system.scheduleScriptRun for each system; probably less than 20
lines total.

-- 
/aron


On Mon, 2010-08-23 at 18:23 +0200, Christoph Sievers wrote:
 Am 23.08.10 16:27, schrieb Aron Parsons:
  I am going to have to defer this to the rest of the team since the
  problem doesn't seem to be with spacecmd itself, it's just exposing the
  problem on the Spacewalk server itself.  However, just a few more
  questions I would ask to help debug it:
  
  - What's your database setup?
  - What versions of the client tools are on the sytsems that expose the
  behavior?
  - Can you reproduce this on a 100% clean install?
  
 
 After I did a reactivation of the system it started working and I now
 can get the installed packages list..
 
 Is it possible to do the reactivation bulkwise so that I do not have to
 do the generate key/issue rhnreg_ks/ steps for every single system?
 
 rgds
 Christoph

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


[Spacewalk-devel] [PATCH] fixed the system counts in the *_action_list queries

2010-07-27 Thread Aron Parsons
This fixes the SQL queries from commit
2afeaf8a02329f5f750bb1c1ebfaa0525a9d343c.  They were not returning the
correct count for each system state.

/aron
From e5379f6a6de6b31b01d2497ffe6d7d2314975ac1 Mon Sep 17 00:00:00 2001
From: Aron Parsons apars...@redhat.com
Date: Tue, 27 Jul 2010 12:04:44 -0400
Subject: [PATCH] fixed the system counts in the *_action_list queries

---
 .../common/db/datasource/xml/Action_queries.xml|   30 ++--
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Action_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Action_queries.xml
index 624ec91..d947cee 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Action_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Action_queries.xml
@@ -118,9 +118,9 @@ SELECT  DISTINCT UAO.id AS ID,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME,
 UAO.scheduler,
 WC.login AS SCHEDULER_NAME,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id IN (0,1)) AS IN_PROGRESS_SYSTEMS,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 2) AS COMPLETED_SYSTEMS,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 3) AS FAILED_SYSTEMS
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status IN (0,1)) AS IN_PROGRESS_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status = 2) AS COMPLETED_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status = 3) AS FAILED_SYSTEMS
   FROM  rhnUserActionOverview UAO, web_contact WC
  WHERE  UAO.org_id = :org_id
AND  UAO.user_id = :user_id
@@ -166,9 +166,9 @@ SELECT  DISTINCT UAO.id AS ID,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME,
 UAO.scheduler,
 WC.login AS SCHEDULER_NAME,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id IN (0,1)) AS IN_PROGRESS_SYSTEMS,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 2) AS COMPLETED_SYSTEMS,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 3) AS FAILED_SYSTEMS
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status IN (0,1)) AS IN_PROGRESS_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status = 2) AS COMPLETED_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status = 3) AS FAILED_SYSTEMS
   FROM  rhnUserActionOverview UAO, web_contact WC
  WHERE  UAO.org_id = :org_id
AND  UAO.user_id = :user_id
@@ -189,9 +189,9 @@ SELECT  DISTINCT UAO.id AS ID,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME,
 UAO.scheduler,
 WC.login AS SCHEDULER_NAME,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id IN (0,1)) AS IN_PROGRESS_SYSTEMS,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 2) AS COMPLETED_SYSTEMS,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 3) AS FAILED_SYSTEMS
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status IN (0,1)) AS IN_PROGRESS_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status = 2) AS COMPLETED_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status = 3) AS FAILED_SYSTEMS
   FROM  rhnUserActionOverview UAO, web_contact WC
  WHERE  UAO.org_id = :org_id
AND  UAO.user_id = :user_id
@@ -214,9 +214,9 @@ SELECT  DISTINCT UAO.id AS ID,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME,
 UAO.scheduler,
 WC.login AS SCHEDULER_NAME,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id IN (0,1)) AS IN_PROGRESS_SYSTEMS,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 2) AS COMPLETED_SYSTEMS,
-(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 3) AS FAILED_SYSTEMS
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status IN (0,1)) AS IN_PROGRESS_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction WHERE action_id = UAO.id AND status = 2) AS COMPLETED_SYSTEMS

[Spacewalk-devel] [PATCH] added new API functions system.listPackageProfiles and system.deletePackageProfile

2010-07-27 Thread Aron Parsons

From 6cabc45564380ffd059f8f010c46753f96bff426 Mon Sep 17 00:00:00 2001
From: Aron Parsons apars...@redhat.com
Date: Tue, 27 Jul 2010 18:37:50 -0400
Subject: [PATCH] added new API functions system.listPackageProfiles and system.deletePackageProfile

---
 .../serializer/ProfileOverviewDtoSerializer.java   |   60 
 .../xmlrpc/serializer/SerializerRegistry.java  |1 +
 .../rhn/frontend/xmlrpc/system/SystemHandler.java  |   43 ++
 3 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ProfileOverviewDtoSerializer.java

diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ProfileOverviewDtoSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ProfileOverviewDtoSerializer.java
new file mode 100644
index 000..cd6488a
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ProfileOverviewDtoSerializer.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2009--2010 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.frontend.xmlrpc.serializer;
+
+import com.redhat.rhn.frontend.dto.ProfileOverviewDto;
+import com.redhat.rhn.frontend.xmlrpc.serializer.util.SerializerHelper;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import redstone.xmlrpc.XmlRpcCustomSerializer;
+import redstone.xmlrpc.XmlRpcException;
+import redstone.xmlrpc.XmlRpcSerializer;
+
+
+/**
+ * ProfileOverviewDtoSerializer
+ * @version $Rev$
+ *
+ * @xmlrpc.doc
+ * #struct(package profile)
+ *   #prop(int, id)
+ *   #prop(string, name)
+ *   #prop(string, channel)
+ * #struct_end()
+ */
+public class ProfileOverviewDtoSerializer implements XmlRpcCustomSerializer {
+
+/**
+ * {...@inheritdoc}
+ */
+public Class getSupportedClass() {
+return ProfileOverviewDto.class;
+}
+
+/**
+ * {...@inheritdoc}
+ */
+public void serialize(Object value, Writer output, XmlRpcSerializer builtInSerializer)
+throws XmlRpcException, IOException {
+ProfileOverviewDto dto = (ProfileOverviewDto) value;
+SerializerHelper helper = new SerializerHelper(builtInSerializer);
+helper.add(id, dto.getId().longValue());
+helper.add(name, dto.getName());
+helper.add(channel, dto.getChannelName());
+helper.writeTo(output);
+}
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
index cf537eb..1c18f96 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
@@ -112,6 +112,7 @@ public class SerializerRegistry {
 SERIALIZER_CLASSES.add(PackageProviderSerializer.class);
 SERIALIZER_CLASSES.add(PackageDtoSerializer.class);
 SERIALIZER_CLASSES.add(PackageOverviewSerializer.class);
+SERIALIZER_CLASSES.add(ProfileOverviewDtoSerializer.class);
 SERIALIZER_CLASSES.add(SnippetSerializer.class);
 SERIALIZER_CLASSES.add(NetworkDtoSerializer.class);
 SERIALIZER_CLASSES.add(DistChannelMapSerializer.class);
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
index 8e09e98..5e72950 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
@@ -3637,6 +3637,49 @@ public class SystemHandler extends BaseHandler {
 return 1;
 }
 
+/**
+ * Lists the package profiles in this organization
+ *
+ * @param sessionKey User's session key.
+ * @return 1 on success
+ *
+ * @xmlrpc.doc List the package profiles in this organization
+ * @xmlrpc.param #param(string, sessionKey)
+ * @xmlrpc.returntype
+ *  #array()
+ *  $ProfileOverviewDtoSerializer
+ *  #array_end()
+ */
+public Object[] listPackageProfiles(String sessionKey) {
+User loggedInUser = getLoggedInUser(sessionKey);
+
+DataResult profiles = ProfileManager.listProfileOverviews(
+ loggedInUser.getOrg().getId());
+
+return profiles.toArray();
+}
+
+/**
+ * Delete

[Spacewalk-devel] [PATCH] added new API call system.listLatestAvailablePackage that will list the latest available version of a package for each system in the list

2010-07-21 Thread Aron Parsons
This patch adds a new API call that allows you to get the latest available 
version of a package
for each system in a list.  

The use case for this in spacecmd is to be able to do a 'system_installpackage 
ssm pkg', which
currently is quite slow because it has to call 
system.listLatestInstallablePackages() for each
system to see which packages are available.  By implementing this API method, a 
single call
can be made to the server to get the information, which can then be used to 
schedule the installations.

/aron
From a1a92364dd31f190bb37468d95156004eeb37abe Mon Sep 17 00:00:00 2001
From: Aron Parsons apars...@redhat.com
Date: Wed, 21 Jul 2010 13:51:35 -0400
Subject: [PATCH] added new API call system.listLatestAvailablePackage that will list the latest available version of a package for each system in the list

---
 .../rhn/frontend/xmlrpc/system/SystemHandler.java  |   63 
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
index 2d16d0a..ff4a6c7 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
@@ -1038,6 +1038,69 @@ public class SystemHandler extends BaseHandler {
 }
 
 /**
+ * Get the latest available version of a package for each system
+ * @param sessionKey The sessionKey containing the logged in user
+ * @param systemIds The IDs of the systems in question
+ * @return Returns an a map with the latest available package for each system
+ * @throws FaultException A FaultException is thrown if the server corresponding to
+ * sid cannot be found.
+ *
+ * @xmlrpc.doc Get the latest available version of a package for each system
+ * @xmlrpc.param #param(string, sessionKey)
+ * @xmlrpc.param #array_single(int, serverId)
+ * @xmlrpc.param #param(string, packageName)
+ * @xmlrpc.returntype #struct(systems)
+ *  #prop(int, serverId)
+ *  #struct(latest package)
+ *  #prop(int, id)
+ *  #prop(string, name)
+ *  #prop(string, version)
+ *  #prop(string, release)
+ *  #prop(string, epoch)
+ *  #prop(string, arch)
+ *  #struct_end()
+ */
+public Map listLatestAvailablePackage(String sessionKey, ListInteger systemIds, String name) 
+throws FaultException {
+// Get the logged in user
+User loggedInUser = getLoggedInUser(sessionKey);
+
+Map results = new HashMap();
+
+for (Integer sid : systemIds) {
+// get the package name ID
+Map pkgEvr = PackageManager.lookupEvrIdByPackageName(sid.longValue(), name);
+
+if (pkgEvr != null) {
+// find the latest package available to each system
+Package pkg = PackageManager.guestimatePackageBySystem(sid.longValue(),
+(Long) pkgEvr.get(name_id), (Long) pkgEvr.get(evr_id),
+ null, loggedInUser.getOrg());
+
+// build the hash to return
+if (pkg != null) {
+HashMap pkgMap = new HashMap();
+pkgMap.put(id, pkg.getId());
+pkgMap.put(name, pkg.getPackageName().getName());
+pkgMap.put(version, pkg.getPackageEvr().getVersion());
+pkgMap.put(release, pkg.getPackageEvr().getRelease());
+pkgMap.put(arch, pkg.getPackageArch().getLabel());
+
+if (pkg.getPackageEvr().getEpoch() != null) {
+pkgMap.put(epoch, pkg.getPackageEvr().getEpoch());
+} else {
+pkgMap.put(epoch, );
+}
+
+results.put(sid, pkgMap);
+}
+}
+}
+
+return results;
+}
+
+/**
  * Gets the entitlements for a given server.
  * @param sessionKey The sessionKey containing the logged in user
  * @param sid The id for the system in question
-- 
1.5.5.6

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] [PATCH] added new API call system.listLatestAvailablePackage that will list the latest available version of a package for each system in the list

2010-07-21 Thread Aron Parsons
Returning a hash in system.listLatestAvailablePackage didn't work in practice.  
This patch
alters the return type to an array that includes the system id, name and then a 
hash
of the package information.

/aron

- Original Message -
From: Aron Parsons apars...@redhat.com
To: spacewalk-devel spacewalk-devel@redhat.com
Sent: Wednesday, July 21, 2010 2:01:02 PM GMT -05:00 US/Canada Eastern
Subject: [Spacewalk-devel] [PATCH] added new API call 
system.listLatestAvailablePackage that will list the latest available version 
of a package for each system in the list

This patch adds a new API call that allows you to get the latest available 
version of a package
for each system in a list.  

The use case for this in spacecmd is to be able to do a 'system_installpackage 
ssm pkg', which
currently is quite slow because it has to call 
system.listLatestInstallablePackages() for each
system to see which packages are available.  By implementing this API method, a 
single call
can be made to the server to get the information, which can then be used to 
schedule the installations.

/aron

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-develFrom 23b8db5c3478d59dfddab590c637fda5aedc0ac7 Mon Sep 17 00:00:00 2001
From: Aron Parsons apars...@redhat.com
Date: Wed, 21 Jul 2010 17:08:06 -0400
Subject: [PATCH 2/2] alter the return type of system.listLatestAvailablePackage

---
 .../rhn/frontend/xmlrpc/system/SystemHandler.java  |   27 ++--
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
index 6ce5eb5..94159c3 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
@@ -1049,25 +1049,32 @@ public class SystemHandler extends BaseHandler {
  * @xmlrpc.param #param(string, sessionKey)
  * @xmlrpc.param #array_single(int, serverId)
  * @xmlrpc.param #param(string, packageName)
- * @xmlrpc.returntype #struct(systems)
- *  #prop(int, serverId)
- *  #struct(latest package)
+ * @xmlrpc.returntype
+ *  #array()
+ *#prop_desc(int, id, server ID)
+ *#prop_desc(string, name, server name)
+ *#struct(package)
  *  #prop(int, id)
  *  #prop(string, name)
  *  #prop(string, version)
  *  #prop(string, release)
  *  #prop(string, epoch)
  *  #prop(string, arch)
- *  #struct_end()
+ *  #array_end()
+ *
  */
-public Map listLatestAvailablePackage(String sessionKey, ListInteger systemIds, String name)
+public List listLatestAvailablePackage(String sessionKey, ListInteger systemIds, String name)
 throws FaultException {
 // Get the logged in user
 User loggedInUser = getLoggedInUser(sessionKey);
 
-Map results = new HashMap();
+List list = new ArrayList();
 
 for (Integer sid : systemIds) {
+Server server = lookupServer(loggedInUser, sid);
+
+Map systemMap = new HashMap();
+
 // get the package name ID
 Map pkgEvr = PackageManager.lookupEvrIdByPackageName(sid.longValue(), name);
 
@@ -1092,12 +1099,16 @@ public class SystemHandler extends BaseHandler {
 pkgMap.put(epoch, );
 }
 
-results.put(sid, pkgMap);
+systemMap.put(id, sid);
+systemMap.put(name, server.getName());
+systemMap.put(package, pkgMap);
+
+list.add(systemMap);
 }
 }
 }
 
-return results;
+return list;
 }
 
 /**
-- 
1.7.1.1

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

[Spacewalk-devel] [PATCH] added new API call schedule.rescheduleActions

2010-07-20 Thread Aron Parsons
From 47e51b58cbbc21b4fc6c3df90c2f474a98d52ade Mon Sep 17 00:00:00 2001
From: Aron Parsons apars...@redhat.com
Date: Tue, 20 Jul 2010 11:34:58 -0400
Subject: [PATCH] added new API call schedule.rescheduleActions

---
 .../frontend/xmlrpc/schedule/ScheduleHandler.java  |   31 
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/schedule/ScheduleHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/schedule/ScheduleHandler.java
index e8aba1e..fd1b997 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/schedule/ScheduleHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/schedule/ScheduleHandler.java
@@ -259,4 +259,35 @@ public class ScheduleHandler extends BaseHandler {
 dr.elaborate();
 return dr.toArray();
 }
+
+/**
+ * Reschedule all actions in the given list.
+ * @param sessionKey The sessionkey for the session containing the logged in user.
+ * @param actionIds The list of ids for actions to reschedule.
+ * @return Returns a list of actions with details
+ * @throws FaultException A FaultException is thrown if one of the actions provided
+ * is invalid.
+ *
+ * @xmlrpc.doc Reschedule all actions in the given list.
+ * @xmlrpc.param #session_key()
+ * @xmlrpc.param #array_single(int, action id)
+ * @xmlrpc.param #param_desc(boolean, onlyFailed,
+ *   True to only reschedule failed actions, False to reschedule all)
+ * @xmlrpc.returntype #return_int_success()
+ */
+public int rescheduleActions(String sessionKey, ListInteger actionIds, boolean onlyFailed)
+throws FaultException {
+
+// Get the logged in user
+User loggedInUser = getLoggedInUser(sessionKey);
+
+for (Integer actionId : actionIds) {
+Action action = ActionManager.lookupAction(loggedInUser, new Long(actionId));
+if (action != null) {
+ActionManager.rescheduleAction(action, onlyFailed);
+}
+}
+
+return 1;
+}
 }
-- 
1.5.5.6

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

[Spacewalk-devel] [PATCH] add counts for the number of completed/failed/inprogress systems to the ScheduledAction DTO

2010-07-20 Thread Aron Parsons
The purpose of this patch is provide a quick way to get a summary of the status 
of
the systems that are scheduled for an action via the API.  Currently, each 
action
needs to have three additional API calls (e.g., listInProgressSystems) to get a 
tally 
of the number of systems that are pending/completed/failed.  The performance 
hit can 
easily be seen in spacecmd's schedule_list* methods.

This patch adds three additional columns to the SQL queries that provide a list
of actions (e.g., pending_action_list, all_action_list).  It also updates
the ScheduledAction DTO so that these values can be accessed.  Finally,
the ScheduleActionSerializer has been updated to return these values in the API.

/aron
From d95bbfed67e196f1cce4a6d85a04893654d96016 Mon Sep 17 00:00:00 2001
From: Aron Parsons apars...@redhat.com
Date: Tue, 20 Jul 2010 13:07:47 -0400
Subject: [PATCH] add counts for the number of completed/failed/inprogress systems to the ScheduledAction DTO and schedule.list*Actions API calls

---
 .../common/db/datasource/xml/Action_queries.xml|   25 --
 .../redhat/rhn/frontend/dto/ScheduledAction.java   |   51 
 .../serializer/ScheduleActionSerializer.java   |6 ++
 3 files changed, 77 insertions(+), 5 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Action_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Action_queries.xml
index e51d6e1..624ec91 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Action_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Action_queries.xml
@@ -117,7 +117,10 @@ SELECT  DISTINCT UAO.id AS ID,
 UAO.type_name,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME,
 UAO.scheduler,
-WC.login AS SCHEDULER_NAME
+WC.login AS SCHEDULER_NAME,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id IN (0,1)) AS IN_PROGRESS_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 2) AS COMPLETED_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 3) AS FAILED_SYSTEMS
   FROM  rhnUserActionOverview UAO, web_contact WC
  WHERE  UAO.org_id = :org_id
AND  UAO.user_id = :user_id
@@ -162,7 +165,10 @@ SELECT  DISTINCT UAO.id AS ID,
 UAO.type_name,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME,
 UAO.scheduler,
-WC.login AS SCHEDULER_NAME
+WC.login AS SCHEDULER_NAME,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id IN (0,1)) AS IN_PROGRESS_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 2) AS COMPLETED_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 3) AS FAILED_SYSTEMS
   FROM  rhnUserActionOverview UAO, web_contact WC
  WHERE  UAO.org_id = :org_id
AND  UAO.user_id = :user_id
@@ -182,7 +188,10 @@ SELECT  DISTINCT UAO.id AS ID,
 UAO.type_name,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME,
 UAO.scheduler,
-WC.login AS SCHEDULER_NAME
+WC.login AS SCHEDULER_NAME,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id IN (0,1)) AS IN_PROGRESS_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 2) AS COMPLETED_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 3) AS FAILED_SYSTEMS
   FROM  rhnUserActionOverview UAO, web_contact WC
  WHERE  UAO.org_id = :org_id
AND  UAO.user_id = :user_id
@@ -204,7 +213,10 @@ SELECT  DISTINCT UAO.id AS ID,
 UAO.type_name,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME,
 UAO.scheduler,
-WC.login AS SCHEDULER_NAME
+WC.login AS SCHEDULER_NAME,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id IN (0,1)) AS IN_PROGRESS_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 2) AS COMPLETED_SYSTEMS,
+(SELECT COUNT(server_id) FROM rhnServerAction SA WHERE SA.action_id = UAO.id AND UAO.action_status_id = 3) AS FAILED_SYSTEMS
   FROM  rhnUserActionOverview UAO, web_contact WC
  WHERE  UAO.org_id = :org_id
AND  UAO.user_id = :user_id
@@ -226,7 +238,10 @@ SELECT  DISTINCT UAO.id AS ID,
 UAO.earliest_action AS EARLIEST,
 UAO.type_name,
 (DECODE(UAO.action_name, NULL, UAO.type_name, UAO.action_name)) AS ACTION_NAME

[Spacewalk-devel] [PATCH] 584852 - added API configchannel.listSubscribedSystems

2010-07-19 Thread Aron Parsons
This creates a new API call to list the systems subscribed to a configuration 
channel.

/aronFrom d7a50fa02432f99eebd373b2a62bff045880e1ee Mon Sep 17 00:00:00 2001
From: Aron Parsons a...@redhat.com
Date: Mon, 19 Jul 2010 14:51:16 -0400
Subject: [PATCH] 584852 - added API configchannel.listSubscribedSystems

---
 .../xmlrpc/configchannel/ConfigChannelHandler.java |   24 
 .../serializer/ConfigSystemDtoSerializer.java  |   59 
 .../xmlrpc/serializer/SerializerRegistry.java  |1 +
 3 files changed, 84 insertions(+), 0 deletions(-)
 create mode 100644 java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigSystemDtoSerializer.java

diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
index 7edfc33..8ce55c2 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java
@@ -547,4 +547,28 @@ public class ConfigChannelHandler extends BaseHandler {
 return 1;
 
 }
+
+/**
+ * List the systems subscribed to a configuration channel
+ * @param sessionKey the session key
+ * @param channelLabel the label of the config channel
+ * @return a list of dto's holding this info.
+ *
+ * @xmlrpc.doc Return a list of systems subscribed to a configuration channel
+ * @xmlrpc.param  #session_key()
+ * @xmlrpc.param #param_desc(string, channelLabel,
+ *  label of config channel to list subscribed systems.)
+ * @xmlrpc.returntype
+ * #array()
+ * $ConfigSystemDtoSerializer
+ * #array_end()
+ */
+public ListConfigSystemDto listSubscribedSystems(String sessionKey, String channelLabel) {
+User loggedInUser = getLoggedInUser(sessionKey);
+XmlRpcConfigChannelHelper configHelper = XmlRpcConfigChannelHelper.getInstance();
+ConfigChannel channel = configHelper.lookupGlobal(loggedInUser,
+  channelLabel);
+ConfigurationManager cm = ConfigurationManager.getInstance();
+return cm.listChannelSystems(loggedInUser, channel, null);
+}
 }
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigSystemDtoSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigSystemDtoSerializer.java
new file mode 100644
index 000..06e5b27
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ConfigSystemDtoSerializer.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2009--2010 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.frontend.xmlrpc.serializer;
+
+import com.redhat.rhn.frontend.dto.ConfigSystemDto;
+import com.redhat.rhn.frontend.xmlrpc.serializer.util.SerializerHelper;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import redstone.xmlrpc.XmlRpcCustomSerializer;
+import redstone.xmlrpc.XmlRpcException;
+import redstone.xmlrpc.XmlRpcSerializer;
+
+
+/**
+ * ConfigSystemDtoSerializer
+ * @version $Rev$
+ *
+ * @xmlrpc.doc
+ * #struct(system)
+ *   #prop(int, id)
+ *   #prop(string, name)
+ * #struct_end()
+ */
+public class ConfigSystemDtoSerializer implements XmlRpcCustomSerializer {
+
+/**
+ * {...@inheritdoc}
+ */
+public Class getSupportedClass() {
+return ConfigSystemDto.class;
+}
+
+/**
+ * {...@inheritdoc}builtinserializer
+ */
+public void serialize(Object value, Writer output, XmlRpcSerializer builtInSerializer)
+throws XmlRpcException, IOException {
+ConfigSystemDto dto = (ConfigSystemDto) value;
+SerializerHelper helper = new SerializerHelper(builtInSerializer);
+helper.add(id, dto.getId());
+helper.add(name, dto.getName());
+helper.writeTo(output);
+}
+
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
index bf3935d..cf537eb 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
@@ -73,6 +73,7 @@ public class SerializerRegistry {
 SERIALIZER_CLASSES.add

Re: [Spacewalk-devel] PATCH: alter system.scheduleRunScript API call to schedule multiple systems

2010-07-14 Thread Aron Parsons
Tomas,
Here is an updated patch that should apply cleanly to HEAD.  It also preserves 
the original
API call where you only pass in one server ID.

/aron

- Original Message -
From: Tomas Lestach tlest...@redhat.com
To: spacewalk-devel@redhat.com
Sent: Tuesday, July 13, 2010 4:44:48 AM GMT -05:00 US/Canada Eastern
Subject: Re: [Spacewalk-devel] PATCH: alter system.scheduleRunScript API call 
to schedule multiple systems

Hey Aron,

I reviewed your patch and it looks good, I like it.

I just have 2 comments:
- we want to keep the API we've already introduced, so if you replace the 
current api call, just create also the original call, that would call your new 
one. To keep the interface.
Something like:
public Integer scheduleScriptRun(String sessionKey, Integer sid, ...) {
   List systemIds = new ArrayList();

   systemIds.add(sid);
   return scheduleScriptRun(sessionKey, systemIds, ...);
}

- please, create a new patch against HEAD of master, because there were some 
troubles when trying to apply it. The best thing would be to send output of git 
format-patch. I'll be happy to commit it.

Best Regards,
Tomas
--
Tomas Lestach
RHN Satellite Engineering, Red Hat

$ git st
# On branch master
nothing to commit (working directory clean)
$ git pull
Already up-to-date.
$ git am 
../patches/spacewalk-schedule-script-for-multiple-systems-with-same-action-id.patch
 
Patch format detection failed.
$ patch -p1 -i 
../patches/spacewalk-schedule-script-for-multiple-systems-with-same-action-id.patch
 
(Stripping trailing CRs from patch.)
patching file 
java/code/src/com/redhat/rhn/frontend/action/rhnpackage/ScheduleRemoteCommand.java
Hunk #2 succeeded at 180 with fuzz 2.
(Stripping trailing CRs from patch.)
patching file 
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
Hunk #1 FAILED at 2986.
Hunk #2 FAILED at 3012.
2 out of 2 hunks FAILED -- saving rejects to file 
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java.rej
(Stripping trailing CRs from patch.)
patching file 
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java
Hunk #1 FAILED at 1337.
Hunk #2 FAILED at 1354.
Hunk #3 FAILED at 1368.
Hunk #4 FAILED at 1384.
Hunk #5 FAILED at 1396.
Hunk #6 FAILED at 1413.
6 out of 6 hunks FAILED -- saving rejects to file 
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java.rej
(Stripping trailing CRs from patch.)
patching file java/code/src/com/redhat/rhn/manager/action/ActionManager.java
Hunk #1 FAILED at 1273.
1 out of 1 hunk FAILED -- saving rejects to file 
java/code/src/com/redhat/rhn/manager/action/ActionManager.java.rej
(Stripping trailing CRs from patch.)
patching file 
java/code/src/com/redhat/rhn/manager/action/test/ActionManagerTest.java


- Aron Parsons apars...@redhat.com wrote:

 system.scheduleScriptRun currently only schedules one server per
 action.  When scheduling multiple systems at once via a loop, this
 really clutters the schedule history and also makes retrieval of the
 results
 pretty much useless without guessing at which actions are related.
 
 This patch changes the second argument from an integer to an array of
 integers representing the serever IDs
 to schedule.  The end result is behavior similar to scheduling a
 script for multiple systems via the
 web UI.
 
 /aron
 ___
 Spacewalk-devel mailing list
 Spacewalk-devel@redhat.com
 https://www.redhat.com/mailman/listinfo/spacewalk-devel

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel
From 0875491b0b30b4c6674978f7c1646af3881d9f6d Mon Sep 17 00:00:00 2001
From: Aron Parsons a...@redhat.com
Date: Wed, 14 Jul 2010 13:31:08 -0400
Subject: [PATCH] alter system.scheduleRunScript API call to schedule multiple systems

---
 .../action/rhnpackage/ScheduleRemoteCommand.java   |9 ++-
 .../rhn/frontend/xmlrpc/system/SystemHandler.java  |   69 
 .../xmlrpc/system/test/SystemHandlerTest.java  |   32 +++--
 .../redhat/rhn/manager/action/ActionManager.java   |   32 ++
 .../rhn/manager/action/test/ActionManagerTest.java |5 +-
 5 files changed, 114 insertions(+), 33 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/ScheduleRemoteCommand.java b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/ScheduleRemoteCommand.java
index 9f617ba..d3a9ae8 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/ScheduleRemoteCommand.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/ScheduleRemoteCommand.java
@@ -38,6 +38,7 @@ 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.Date;
 import java.util.LinkedList;
 import java.util.List;
@@ -179,6 +180,10 @@ public class

[Spacewalk-devel] [PATCH] allow multiple systems to be scheduled for an erratum via the API

2010-07-14 Thread Aron Parsons
This patch allows multiple systems to be scheduled for an erratum update via 
the API, similar to how
the web UI schedules multiple systems.  This fixes the issue of having a single 
action scheduled for 
each system, which clutters up the schedule and makes checking the status of an 
erratum update very
difficult.

/aron
From d4a87cc16fede0fd65bb5cc33e57d0e0bb401278 Mon Sep 17 00:00:00 2001
From: Aron Parsons a...@redhat.com
Date: Wed, 14 Jul 2010 16:36:24 -0400
Subject: [PATCH] allow multiple systems to be scheduled for an erratum via the API

---
 .../rhn/frontend/xmlrpc/system/SystemHandler.java  |   61 ++--
 .../xmlrpc/system/test/SystemHandlerTest.java  |7 ++-
 .../redhat/rhn/manager/errata/ErrataManager.java   |   22 
 3 files changed, 71 insertions(+), 19 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
index 9a2766f..b8eae6a 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
@@ -2550,6 +2550,53 @@ public class SystemHandler extends BaseHandler {
 }
 
 /**
+ * Schedules an action to apply errata updates to multiple systems.
+ * @param sessionKey The user's session key.
+ * @param serverIds List of server IDs to apply the errata to (as Integers)
+ * @param errataIds List of errata IDs to apply (as Integers)
+ * @return 1 if successful, exception thrown otherwise
+ *
+ * @xmlrpc.doc Schedules an action to apply errata updates to multiple systems.
+ * @xmlrpc.param #param(string, sessionKey)
+ * @xmlrpc.param #array_single(int, serverId)
+ * @xmlrpc.param #array_single(int, errataId)
+ * @xmlrpc.returntype #return_int_success()
+ */
+public int scheduleApplyErrata(String sessionKey, List serverIds, List errataIds) {
+return scheduleApplyErrata(sessionKey, serverIds, errataIds, null);
+}
+
+/**
+ * Schedules an action to apply errata updates to multiple systems at a specified time.
+ * @param sessionKey The user's session key.
+ * @param serverIds List of server IDs to apply the errata to (as Integers)
+ * @param errataIds List of errata IDs to apply (as Integers)
+ * @param earliestOccurrence Earliest occurrence of the errata update
+ * @return 1 if successful, exception thrown otherwise
+ *
+ * @xmlrpc.doc Schedules an action to apply errata updates to multiple systems at a
+ * given date/time.
+ * @xmlrpc.param #param(string, sessionKey)
+ * @xmlrpc.param #array_single(int, serverId)
+ * @xmlrpc.param #array_single(int, errataId)
+ * @xmlrpc.param dateTime.iso8601 earliestOccurrence
+ * @xmlrpc.returntype #return_int_success()
+ */
+public int scheduleApplyErrata(String sessionKey, List serverIds, List errataIds,
+Date earliestOccurrence) {
+
+// we need long values to pass to ErrataManager.applyErrataHelper
+ListLong longServerIds = new ArrayList();
+for (Iterator it = serverIds.iterator(); it.hasNext();) {
+longServerIds.add(new Long((Integer) it.next()));
+}
+
+ErrataManager.applyErrataHelper(getLoggedInUser(sessionKey),
+longServerIds, errataIds, earliestOccurrence);
+return 1;
+}
+
+/**
  * Schedules an action to apply errata updates to a system.
  * @param sessionKey The user's session key.
  * @param sid ID of the server
@@ -2585,9 +2632,10 @@ public class SystemHandler extends BaseHandler {
  * @xmlrpc.returntype #return_int_success()
  */
 public int scheduleApplyErrata(String sessionKey, Integer sid, List errataIds) {
-ErrataManager.applyErrataHelper(getLoggedInUser(sessionKey), sid.longValue(),
-errataIds, null);
-return 1;
+List serverIds = new ArrayList();
+serverIds.add(sid);
+
+return scheduleApplyErrata(sessionKey, serverIds, errataIds);
 }
 
 /**
@@ -2608,9 +2656,10 @@ public class SystemHandler extends BaseHandler {
  */
 public int scheduleApplyErrata(String sessionKey, Integer sid, List errataIds,
 Date earliestOccurrence) {
-ErrataManager.applyErrataHelper(getLoggedInUser(sessionKey),
-sid.longValue(), errataIds, earliestOccurrence);
-return 1;
+List serverIds = new ArrayList();
+serverIds.add(sid);
+
+return scheduleApplyErrata(sessionKey, serverIds, errataIds, earliestOccurrence);
 }
 
 /**
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java
index d00f55c..3a7ba12 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/test/SystemHandlerTest.java
+++ b/java/code

[Spacewalk-devel] PATCH: add serverId to structure returned by system.getScriptResults() API call

2010-07-12 Thread Aron Parsons
This script adds the serverId to the data structure returned by the 
system.getScriptResults() API call.
Currently, the array of results doesn't have a way to correlate which server 
the script output 
belongs to.  This is a problem when multiple systems are scheduled for a single 
action.

/aron
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ScriptResultSerializer.java
index a7c8980..2c4e24f 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ScriptResultSerializer.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ScriptResultSerializer.java
@@ -52,6 +52,7 @@ public class ScriptResultSerializer implements XmlRpcCustomSerializer {
 throws XmlRpcException, IOException {
 ScriptResult scriptResult = (ScriptResult)value;
 SerializerHelper helper = new SerializerHelper(builtInSerializer);
+helper.add(serverId, scriptResult.getServerId());
 helper.add(startDate, scriptResult.getStartDate());
 helper.add(stopDate, scriptResult.getStopDate());
 helper.add(returnCode, scriptResult.getReturnCode());
___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] spacecmd 0.4 - a viable alternative to the Satellite web UI

2010-07-06 Thread Aron Parsons
I created an entry for spacecmd on the Spacewalk wiki.

https://fedorahosted.org/spacewalk/wiki/spacecmd

/aron

 On Thu, Jul 01, 2010 at 03:18:19PM -0400, Aron Parsons wrote:
  I just wanted to update everyone on the status of spacecmd, a
 command-line interface to
  Satellite.  I've put a bit of work into it since its first
 release[1] and it now can manage
  nearly every aspect of Satellite.  I consider it a viable
 alternative to the web UI at
  this point and have been using it extensively.  
  
  Below is an example of how it can simplify a process that requires
 far too many clicks in the web interface:
  spacecmd errata_apply search:CVE-2009-3726 search:CVE-2010-2063
 
 Aron,
 
 would you maybe like to put a wiki page somewhere under
 https://fedorahosted.org/spacewalk/wiki/ with more info about
 spacecmd, so that we can reference it from other pages?
 
 Thank you,
 
 -- 
 Jan Pazdziora
 Principal Software Engineer, Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] [rhn-satellite-users] spacecmd 0.4 - a viable alternative to the Satellite web UI

2010-07-06 Thread Aron Parsons
It's not currently included with Satellite nor is it supported by any SLA from 
Red Hat.  However,
the API is supported, so there is some level of support if the API is the root 
cause of the
problem.

Hopefully it will make its way into Spacewalk and/or Satellite in the future.

/aron

 Hi,
 
 As a command-line lover...  Thank you for this, and for sending
 something along to this list as I'd never heard of this before.
 
 Is this functionality in Satellite Server?
 
 Marco
 
 On Thu, Jul 1, 2010 at 4:18 PM, Aron Parsons apars...@redhat.com
 wrote:
  I just wanted to update everyone on the status of spacecmd, a
 command-line interface to
  Satellite. ?I've put a bit of work into it since its first
 release[1] and it now can manage
  nearly every aspect of Satellite. ?I consider it a viable
 alternative to the web UI at
  this point and have been using it extensively.

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


[Spacewalk-devel] spacecmd 0.4 - a viable alternative to the Satellite web UI

2010-07-01 Thread Aron Parsons
I just wanted to update everyone on the status of spacecmd, a command-line 
interface to
Satellite.  I've put a bit of work into it since its first release[1] and it 
now can manage
nearly every aspect of Satellite.  I consider it a viable alternative to the 
web UI at
this point and have been using it extensively.  

Below is an example of how it can simplify a process that requires far too many 
clicks in the web interface:
spacecmd errata_apply search:CVE-2009-3726 search:CVE-2010-2063

Download:
http://people.redhat.com/aparsons/spacecmd-0.4-1.el5.noarch.rpm

Homepage:
http://github.com/aparsons/spacecmd

[1] - https://www.redhat.com/archives/spacewalk-devel/2010-April/msg00092.html

/aron

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] spacecmd - Spacewalk Command Shell

2010-04-28 Thread Aron Parsons
I was actually surprised this didn't exist yet after searching around for 
something like it.

The SSM code already supports adding/removing systems by group, so doing an 
intersection is 
just a manual step at this point.  You can also do the same thing with 
searching for systems 
(e.g., all all VMware systems by doing an 'ssm_add vendor:vmware').  Adding a 
method to handle 
this automatically would be pretty slick.

If you have patches, send them over.  I'm new to git and GitHub, but I'm sure 
I'll
figure out how to handle patches from others.

/aron

- Original Message -
From: Maxim Burgerhout ma...@wzzrd.com
To: spacewalk-devel@redhat.com
Cc: apars...@redhat.com
Sent: Wednesday, April 28, 2010 7:12:53 AM GMT -05:00 US/Canada Eastern
Subject: Re: [Spacewalk-devel] spacecmd - Spacewalk Command Shell

Cool!

A *long* time ago, I posted to this list about a very similar script I
had written. My employer had his reservations on sending the script
upstream, so it never happened. I never got to doing the cleaner
rewrite I had planned to do in my spare time (because I have none) and
submitting that.

What I hopefully *will* be able to do, is contribute to this script.
I'm checking it out right now and already love it. I admit had a lot
less methods implemented.

What I did have though, is a way of doing an intersection between more
than 2 groups. I don't think this was ever possible in the Spacewalk /
Satellite web GUI. I'll look into implementing that in your script, if
you consider it interesting.

Maxim Burgerhout
ma...@wzzrd.com

GPG Fingerprint
EB11 5E56 E648 9D99 E8EF 05FB C513 6FD4 1302 B48A



On Tue, Apr 27, 2010 at 21:43, Aron Parsons apars...@redhat.com wrote:
 I wrote a shell interface to Spacewalk that leverages the API found in 
 Spacewalk (I wrote this against Satellite 5.3, v10.8 of the API).  The focus 
 of the program is on managing systems, not all the other aspects of 
 Satellite.  However, other data in Spacewalk (e.g., Kickstarts, activation 
 keys, configuration channels) can be viewed, just not manipulated.

 I'm sure there are plenty of bugs to be found and features to be added.  
 Please provide feedback directly to me or via GitHub.  If there's any 
 interest in this, I hope maybe it can live in the 'contrib' directory of the 
 Spacewalk git repository.

 http://github.com/aparsons/spacecmd

 /aron

 ___
 Spacewalk-devel mailing list
 Spacewalk-devel@redhat.com
 https://www.redhat.com/mailman/listinfo/spacewalk-devel


___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] spacecmd - Spacewalk Command Shell

2010-04-28 Thread Aron Parsons
Those searches should work.  I made a few last minute changes that were
somewhat intrusive to the way the methods handle arguments.  I guess I
just didn't test as much as I should have there.  I'll take a look at
the patches to see if you could interpret exactly what I was trying to
do before I broke it ;-)

/aron

- Original Message -
From: Maxim Burgerhout ma...@wzzrd.com
To: Aron Parsons apars...@redhat.com
Cc: spacewalk-devel@redhat.com
Sent: Wednesday, April 28, 2010 11:31:06 AM GMT -05:00 US/Canada Eastern
Subject: Re: [Spacewalk-devel] spacecmd - Spacewalk Command Shell

I'll be keeping an eye on this. Expect more patches from me: I'm
fixing some bugs I'm running into as I'm typing this. My first (small)
patch is attached to your first issue already, and I just posted a
second one. I hope I am not patching stuff that's just not finished
yet, but I like this idea and I want to support it.

Maybe github has a method of communication for use apart from the
issue tracker, by the way. The spacewalk-devel list might not be the
best place for this.

And for the ssm_add part: you mean system.search.deviceDriver and
system.search.vendor actually work for you? I only get exceptions
there. I just filed a quick issue with RH for that (we use Satellite,
not Spacewalk).

Regards,

Maxim Burgerhout
ma...@wzzrd.com

GPG Fingerprint
EB11 5E56 E648 9D99 E8EF 05FB C513 6FD4 1302 B48A

On Wed, Apr 28, 2010 at 16:33, Aron Parsons apars...@redhat.com wrote:
 I was actually surprised this didn't exist yet after searching around for 
 something like it.

 The SSM code already supports adding/removing systems by group, so doing an 
 intersection is
 just a manual step at this point.  You can also do the same thing with 
 searching for systems
 (e.g., all all VMware systems by doing an 'ssm_add vendor:vmware').  Adding a 
 method to handle
 this automatically would be pretty slick.

 If you have patches, send them over.  I'm new to git and GitHub, but I'm sure 
 I'll
 figure out how to handle patches from others.

 /aron

 - Original Message -
 From: Maxim Burgerhout ma...@wzzrd.com
 To: spacewalk-devel@redhat.com
 Cc: apars...@redhat.com
 Sent: Wednesday, April 28, 2010 7:12:53 AM GMT -05:00 US/Canada Eastern
 Subject: Re: [Spacewalk-devel] spacecmd - Spacewalk Command Shell

 Cool!

 A *long* time ago, I posted to this list about a very similar script I
 had written. My employer had his reservations on sending the script
 upstream, so it never happened. I never got to doing the cleaner
 rewrite I had planned to do in my spare time (because I have none) and
 submitting that.

 What I hopefully *will* be able to do, is contribute to this script.
 I'm checking it out right now and already love it. I admit had a lot
 less methods implemented.

 What I did have though, is a way of doing an intersection between more
 than 2 groups. I don't think this was ever possible in the Spacewalk /
 Satellite web GUI. I'll look into implementing that in your script, if
 you consider it interesting.

 Maxim Burgerhout
 ma...@wzzrd.com
 
 GPG Fingerprint
 EB11 5E56 E648 9D99 E8EF 05FB C513 6FD4 1302 B48A



 On Tue, Apr 27, 2010 at 21:43, Aron Parsons apars...@redhat.com wrote:
 I wrote a shell interface to Spacewalk that leverages the API found in 
 Spacewalk (I wrote this against Satellite 5.3, v10.8 of the API).  The focus 
 of the program is on managing systems, not all the other aspects of 
 Satellite.  However, other data in Spacewalk (e.g., Kickstarts, activation 
 keys, configuration channels) can be viewed, just not manipulated.

 I'm sure there are plenty of bugs to be found and features to be added.  
 Please provide feedback directly to me or via GitHub.  If there's any 
 interest in this, I hope maybe it can live in the 'contrib' directory of the 
 Spacewalk git repository.

 http://github.com/aparsons/spacecmd

 /aron

 ___
 Spacewalk-devel mailing list
 Spacewalk-devel@redhat.com
 https://www.redhat.com/mailman/listinfo/spacewalk-devel



___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel