Bug 856368 - Spacewalk API channel.software.listChannelRepos call, and other calls that return ContentSource objectsdoes not return an array of struct as described in documentation.
Spacewalk API channel.software.listChannelRepos call, and other calls that re...
Status: CLOSED CURRENTRELEASE
Product: Spacewalk
Classification: Community
Component: API (Show other bugs)
1.2
All Linux
unspecified Severity medium
: ---
: ---
Assigned To: Tomas Lestach
Red Hat Satellite QA List
:
Depends On:
Blocks: 857943 space18
  Show dependency treegraph
 
Reported: 2012-09-11 18:01 EDT by David Deaderick
Modified: 2012-11-01 12:18 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 857943 (view as bug list)
Environment:
Last Closed: 2012-11-01 12:18:16 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Python Script to Collect Channel Information (17.05 KB, application/x-zip-compressed)
2012-09-11 18:01 EDT, David Deaderick
no flags Details

  None (edit)
Description David Deaderick 2012-09-11 18:01:08 EDT
Created attachment 611948 [details]
Python Script to Collect Channel Information

Description of problem:

Using a python script to make a call to namespace=channel.software, method=listChannelRepos, passing in my sessionKey and Channel Label. I expected to have returned: 

array: 
    struct - channel 
        int "id" 
     string "label"
     string "sourceUrl"
     string "type"

Instead a text representation


Version-Release number of selected component (if applicable):
RHN Satellite 5.4.1
spacewalk-java-1.2.39-126.el6sat.src.rpm

How reproducible:
100%

Steps to Reproduce:
1. Call channel.software.listChannelRepos(sessionKey, 'ese-custom-6')
2. Print returned object
3.
  
Actual results:

[{'value': 'com.redhat.rhn.domain.channel.ContentSource@75d175d1[id=500,org=com.redhat.rhn.domain.org.Org@18451845[id=1,name=US Department of Veterans Affairs],type=com.redhat.rhn.domain.channel.ContentSourceType@45e045e[id=500,label=yum,created=2012-04-30,modified=2012-04-30],sourceUrl=http://vhaetnmon33.vha.med.va.gov/repos/ese-custom/,label=ESE Custom RPMs,channels=[com.redhat.rhn.domain.channel.Channel@392f392f[id=142,label=ese-custom-6], com.redhat.rhn.domain.channel.Channel@7c637c63[id=161,label=ese-custom-5]],created=2012-05-08 13:24:53.0,modified=2012-05-08 13:24:53.0]'}, {'value': 'com.redhat.rhn.domain.channel.ContentSource@76f676f6[id=501,org=com.redhat.rhn.domain.org.Org@18451845[id=1,name=US Department of Veterans Affairs],type=com.redhat.rhn.domain.channel.ContentSourceType@45e045e[id=500,label=yum,created=2012-04-30,modified=2012-04-30],sourceUrl=http://vhaetnmon33.vha.med.va.gov/repos/ese-third-party/,label=ESE Third Party RPMs,channels=[com.redhat.rhn.domain.channel.Channel@392f392f[id=142,label=ese-custom-6], com.redhat.rhn.domain.channel.Channel@7c637c63[id=161,label=ese-custom-5]],created=2012-05-08 14:16:47.0,modified=2012-05-08 14:16:47.0]'}, {'value': 'com.redhat.rhn.domain.channel.ContentSource@77ca77ca[id=502,org=com.redhat.rhn.domain.org.Org@18451845[id=1,name=US Department of Veterans Affairs],type=com.redhat.rhn.domain.channel.ContentSourceType@45e045e[id=500,label=yum,created=2012-04-30,modified=2012-04-30],sourceUrl=http://vhaetnmon33.vha.med.va.gov/repos/ese-v2s/,label=ESE V2S RPMs,channels=[com.redhat.rhn.domain.channel.Channel@392f392f[id=142,label=ese-custom-6], com.redhat.rhn.domain.channel.Channel@7c637c63[id=161,label=ese-custom-5]],created=2012-05-08 14:17:35.0,modified=2012-05-08 14:17:35.0]'}]

Expected results:

[{'sourceUrl': 'http://vhaetnmon33.vha.med.va.gov/repos/ese-custom/', 'type': 'yum', 'id': 500, 'label': 'ESE Custom RPMs'}, {'sourceUrl': 'http://vhaetnmon33.vha.med.va.gov/repos/ese-third-party/', 'type': 'yum', 'id': 501, 'label': 'ESE Third Party RPMs'}, {'sourceUrl': 'http://vhaetnmon33.vha.med.va.gov/repos/ese-v2s/', 'type': 'yum', 'id': 502, 'label': 'ESE V2S RPMs'}]

Additional info:

Possible patch for spacewalk-java-1.2.39-126.el6sat.src.rpm:

diff --git a/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java b/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
index 2d29a28..a725dd8 100644
--- a/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
+++ b/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
@@ -2384,10 +2384,22 @@ public class ChannelSoftwareHandler extends BaseHandler {
      *          $ContentSourceSerializer
      *      #array_end()
      */
-    public List<ContentSource> listChannelRepos(String sessionKey, String channelLabel) {
-        User loggedInUser = getLoggedInUser(sessionKey);
-        Channel channel = lookupChannelByLabel(loggedInUser, channelLabel);
-        return ChannelFactory.lookupContentSources(loggedInUser.getOrg(), channel);
+    public List listChannelRepos(String sessionKey, String channelLabel) {
+        User user = getLoggedInUser(sessionKey);
+        Channel channel = lookupChannelByLabel(user, channelLabel);
+        List<ContentSource> result = ChannelFactory.lookupContentSources(user.getOrg(), channel);
+
+        List list = new ArrayList();
+        for (Iterator itr = result.iterator(); itr.hasNext();) {
+            ContentSource cs = (ContentSource) itr.next();
+            Map map = new HashMap();
+            map.put("id", cs.getId());
+            map.put("label", cs.getLabel());
+            map.put("sourceUrl", cs.getSourceUrl());
+            map.put("type", cs.getType().getLabel());
+            list.add(map);
+        }
+        return list;
     }

     /**


I have tested the patch with positive results.
Comment 1 David Deaderick 2012-09-12 15:13:35 EDT
When I discovered other calls that should return Repository Informaion had similar issues, I investigated further and discovered the ContentSourceSerializer was not registered. I backed out my previous patch and applied the following patch to correct the issue in multiple calls:

diff --git a/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java b/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
index c701ac2..1dd51c3 100644
--- a/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
+++ b/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/SerializerRegistry.java
@@ -44,6 +44,7 @@ public class SerializerRegistry {
         SERIALIZER_CLASSES.add(ChannelArchSerializer.class);
         SERIALIZER_CLASSES.add(ChannelOverviewSerializer.class);
         SERIALIZER_CLASSES.add(ChannelSerializer.class);
+        SERIALIZER_CLASSES.add(ContentSourceSerializer.class);
         SERIALIZER_CLASSES.add(CpuSerializer.class);
         SERIALIZER_CLASSES.add(DeviceSerializer.class);
         SERIALIZER_CLASSES.add(DmiSerializer.class);
Comment 2 Tomas Lestach 2012-09-13 11:00:29 EDT
Patch in Comment#1 is correct. However, we have this patch in Spacewalk since Tue Aug 28 2012.

spacewalk.git: ad74aa7f79a9730ae7b67cce88cf152fffc839e6

Thank you.
Comment 3 Jan Pazdziora 2012-10-30 15:23:09 EDT
Moving ON_QA. Packages that address this bugzilla should now be available in yum repos at http://yum.spacewalkproject.org/nightly/
Comment 4 Jan Pazdziora 2012-11-01 12:18:16 EDT
Spacewalk 1.8 has been released: https://fedorahosted.org/spacewalk/wiki/ReleaseNotes18

Note You need to log in before you can comment on or make changes to this bug.