Hi all (and apologies for the cross-post)

I'm battling this again as we're really needing this call to be working.

I've found that in 
'code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java',
 the method 'lookupFileInfo(String sessionKey, Integer sid, List<String> paths, 
boolean searchLocal)' isn't passing 'cm.lookupConfigFile(loggedInUser, 
server.getLocalOverride().getId(), path)' the right info.  I've come to this 
conclusion by adding a bunch of println statements and then checking 
/var/log/tomcat5/catalina.out.

If you look at the below 'git diff' extract:
---
diff --git 
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
 
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
index 0c11a95..a7dfd47 100644
--- 
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
+++ 
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/config/ServerConfigHandler.java
@@ -187,23 +187,32 @@ public class ServerConfigHandler extends BaseHandler {
     public List<ConfigRevision> lookupFileInfo(String sessionKey,
         Integer sid, List<String> paths, boolean searchLocal) {

+System.out.println("In lookupFileInfo");
         User loggedInUser = getLoggedInUser(sessionKey);
         XmlRpcSystemHelper sysHelper = XmlRpcSystemHelper.getInstance();
         Server server = sysHelper.lookupServer(loggedInUser, sid);
         ConfigurationManager cm = ConfigurationManager.getInstance();
         List <ConfigRevision> revisions = new LinkedList<ConfigRevision>();
         for (String path : paths) {
+System.out.println("In lookupFileInfo - path is " + path);
             ConfigFile cf;
             if (searchLocal) {
+System.out.println("In lookupFileInfo - file is local");
                 cf = cm.lookupConfigFile(loggedInUser,
                                     server.getLocalOverride().getId(), path);
             }
             else {
+System.out.println("In lookupFileInfo - file is not local");
                 cf = cm.lookupConfigFile(loggedInUser,
                         server.getSandboxOverride().getId(), path);
             }
             if (cf != null) {
+System.out.println("In lookupFileInfo - cf is not null");
                 revisions.add(cf.getLatestConfigRevision());
+System.out.println("In lookupFileInfo - should have rev info now");
+            }
+            else {
+System.out.println("In lookupFileInfo - cf is null :(");
             }
         }
         return revisions;
diff --git 
a/java/code/src/com/redhat/rhn/manager/configuration/ConfigurationManager.java 
b/java/code/src/com/redhat/rhn/manager/configuration/ConfigurationManager.java
index ffe75b2..3b0b68d 100644
--- 
a/java/code/src/com/redhat/rhn/manager/configuration/ConfigurationManager.java
+++ 
b/java/code/src/com/redhat/rhn/manager/configuration/ConfigurationManager.java
@@ -1758,6 +1758,7 @@ public class ConfigurationManager extends BaseManager {
      * @return The sought for config file.
      */
     public ConfigFile lookupConfigFile(User user, Long id) {
+System.out.println("in lookupConfigFile(User user, Long id)");
         log.debug("lookupConfigFile: " + id);
         if (!accessToFile(user.getId(), id)) {
             LocalizationService ls = LocalizationService.getInstance();
@@ -1785,6 +1786,7 @@ public class ConfigurationManager extends BaseManager {
      * have sufficient access
      */
     public ConfigFile lookupConfigFile(User user, Long ccid, String path) {
+System.out.println("in lookupConfigFile(User user, Long ccid, String path)");
         if (!accessToChannel(user.getId(), ccid)) {
             LocalizationService ls = LocalizationService.getInstance();
             LookupException e =
@@ -1795,6 +1797,10 @@ public class ConfigurationManager extends BaseManager {
             throw e;
         }
         ConfigFileName cfn = 
ConfigurationFactory.lookupOrInsertConfigFileName(path);
+System.out.println("in lookupConfigFile(User user, Long ccid, String path) - 
ID is " + cfn.getId());
+System.out.println("in lookupConfigFile(User user, Long ccid, String path) - 
CCID is " + ccid);
+System.out.println("in lookupConfigFile(User user, Long ccid, String path) - 
user is " + user);
+System.out.println("in lookupConfigFile(User user, Long ccid, String path) - 
path is " + path);
         return ConfigurationFactory.lookupConfigFileByChannelAndName(ccid, 
cfn.getId());
     }
---

I get the following in /var/log/tomcat5/catalina.out:
---
In lookupFileInfo
In lookupFileInfo - path is /etc/ssh/ssh_host_dsa_key.pub
In lookupFileInfo - file is local
in lookupConfigFile(User user, Long ccid, String path)
in lookupConfigFile(User user, Long ccid, String path) - ID is 2
in lookupConfigFile(User user, Long ccid, String path) - CCID is 2
in lookupConfigFile(User user, Long ccid, String path) - user is User spacewalk 
(id 1, org_id 1)
in lookupConfigFile(User user, Long ccid, String path) - path is 
/etc/ssh/ssh_host_dsa_key.pub
In lookupFileInfo - cf is null :(
---

Now, the interesting thing is the config channel ID is not '2', it is '1'.  
When I change the code from
---
                cf = cm.lookupConfigFile(loggedInUser,
                                    server.getLocalOverride().getId(), path);
---
to
---
                 cf = cm.lookupConfigFile(loggedInUser, 1L, path);
---

My test Perl API script now returns the right things.
---
[EMAIL PROTECTED] ~]# perl lookupFileInfo.pl /etc/ssh/ssh_host_dsa_key.pub
[3289x5a8bc177c1392e701eed85db0a15ff3f] [1013775633] 
[/etc/ssh/ssh_host_dsa_key.pub] [Frontier::RPC2::Integer=SCALAR(0x15131570)]
$VAR1 = [
          {
            'owner' => 'root',
            'permissions' => '644',
            'contents' => 'ssh-dss 
AAAAB3NzaC1kc3MAAACBAM35V/k6/tGn0SqZPcL6dfm4uMxisEm8yzlYc7r2bxQ7yQpjAdmuLAIVDo7GWAWYcDFQN7UYzw3YF+ZNjAqbK4nkMQvgiVnpQUhCgy5mM0P7YeBDb4SKgSwQGWIo1DqJSpdwLLAv8aLaFtAXWhGNdjCZQ8LlVtbMC3T8w7slIFM3AAAAFQCJFB1cZnC/hhirZKLwhWCjQBVXIQAAAIEAnYM5Ux3LNMuc2FYxnMgZmQN8K9GXkD2CJf9tLfJVCwLAOlDyqcPa4NfpZVzfXpf1u9dlhdE0Og4MpFzqCBs0KeJM2JVnwb7QWPEjeoicXxAgUCnczz3sx5DF0NpAOHukDhsHut+KolXd0+w+z1RDY2abWaR1BQwN1+hnlFXUBp8AAACAOkBPr75XCnua0htL/YAyksxyjkJkxenaONb/5zRl0TaGPblrW3ij340CmBU4RPrpioj9p2DPE0V1IjllLH/QmUBUQcvA76mMR1+z3EP+51HFpdJhwyGd2JQ+DNul0C6sJcj/I4lpqfWtJ5zqtjupy/FxCZx+y/DUsfZZP17IvHU=',
            'binary' => bless( do{\(my $o = '0')}, 'Frontier::RPC2::Boolean' ),
            'channel' => 'cc-vm1',
            'path' => '/etc/ssh/ssh_host_dsa_key.pub',
            'modified' => bless( do{\(my $o = '20081001T13:46:37')}, 
'Frontier::RPC2::DateTime::ISO8601' ),
            'revision' => '6',
            'group' => 'root',
            'macro-end-delimiter' => '|}',
            'macro-start-delimiter' => '{|',
            'type' => 'file',
            'md5' => '08a01bd33eeb244d021c72d984090d11',
            'creation' => bless( do{\(my $o = '20081001T13:46:37')}, 
'Frontier::RPC2::DateTime::ISO8601' )
          }
        ];
---

I know that this email has gone on for a while but we're nearly done now.  So 
the problem is with the call to 'server.getLocalOverride().getId()' returning 
some value other than the value of the config channel ID (could be the config 
file's ID).

Could one of the Satellite/Spacewalk dev's have a look at this and fill in the 
blanks?  I'm really not sure what should be called instead of 
'server.getLocalOverride().getId()' but I really need this API call working in 
Satellite.

Thanks

CC

PS: On a related note, the API call configchannel.lookupFileInfo doesn't return 
the file contents even though the docs state that it should.  The attached 
patch fixes this.



NOTICE: This email and any attachments are confidential. 
They may contain legally privileged information or 
copyright material. You must not read, copy, use or 
disclose them without authorisation. If you are not an 
intended recipient, please contact us at once by return 
email and then delete both messages and all attachments.

Attachment: 0008-Return-file-contents-in-configchannel.lookupFileInfo.patch
Description: 0008-Return-file-contents-in-configchannel.lookupFileInfo.patch

_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to