Currently when launching "rhncfg-client diff" it is not possible to figure out if the difference is due to a change on the server or on the client. This could be done via the /XMLRPC API (for example via configchannel.lookupFileInfo and looking at the 'modified' field) or via "rhncfg-manager diff", but both require adequate satellite credentials which in certain environments are not always available to the people needing this information.
Try and set the mtime and ctime of the temporary file created so that the "rhncfg-client diff" command shows the server last changed time-stamp. For example, with file "/etc/a" changed on server on Fri Feb 28 18:47:31, we will have: - Before the change --- /etc/a Fri Feb 28 19:02:41 2014 (time of diff execution) +++ /etc/a Fri Feb 28 17:03:55 2014 (time of local last change) @@ -1,3 +1,2 @@ this file came from config channel a -test - After the change --- /etc/a Fri Feb 28 18:47:31 2014 (timestamp on the server) +++ /etc/a Fri Feb 28 17:03:55 2014 (time of local last change) @@ -1,3 +1,2 @@ this file came from config channel a -test Tested this RHEL 5.10 and RHEL 6.5 clients against both satellite 5.5/oracle and 5.6/postgres backed instances. (satellite 5.4 did not expose the 'modified' attribute). RHEL 4 won't work without a small rhel4-only change as it spawns diff -L and that does not show the difference in time between both files. Try parsing different date formats as installations with Oracle DB's will return datetime in iso 8601 format (20130304T23:19:17) whereas postgresql backed instances will return dates in the following format: 2014-02-28 18:47:31.506953+01:00. The likelihood of changing DB and datetime format again is low and this won't really break in any case. v2: Use time.strptime() in place of dateutils.parser to be more consistent with the rest of the codebase. Signed-off-by: Michele Baldessari <mich...@acksyn.org> --- client/tools/rhncfg/config_common/file_utils.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/client/tools/rhncfg/config_common/file_utils.py b/client/tools/rhncfg/config_common/file_utils.py index 57665342a63c..a0d22e726029 100644 --- a/client/tools/rhncfg/config_common/file_utils.py +++ b/client/tools/rhncfg/config_common/file_utils.py @@ -90,6 +90,30 @@ class FileProcessor: else: fh.close() + # try to set mtime and ctime of the file to + # the last modified time on the server + if file_struct.has_key('modified'): + xmlrpc_time = file_struct['modified'] + modified = None + try: + # oracle backend: 20130304T23:19:17 + modified = time.strptime(xmlrpc_time, '%Y%m%dT%H:%M:%S') + except: + pass + + try: + # postresql backend format: 2014-02-28 18:47:31.506953+01:00 + modified = time.strptime(xmlrpc_time.split('.')[0], '%Y-%m-%d %H:%M:%S') + except: + pass + + if not modified is None: + try: + epoch_time = time.mktime(modified) + os.utime(fullpath, (epoch_time, epoch_time)) + except: + pass + return fullpath, dirs_created -- 1.8.5.3 _______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel