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 on RHEL 5.10 and RHEL 6.5 clients (on both satellite 5.5/oracle and 5.6/postgres backed instances). RHEL 4 systems will retain previous behaviour as dateutil.parser is not present on those systems (python 2.3). Using a simple approach with dateutil.parser in favour of handparsing the dates, as satellites 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. Signed-off-by: Michele Baldessari <mich...@acksyn.org> --- client/tools/rhncfg/config_common/file_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/tools/rhncfg/config_common/file_utils.py b/client/tools/rhncfg/config_common/file_utils.py index 57665342a63c..361d76f939d5 100644 --- a/client/tools/rhncfg/config_common/file_utils.py +++ b/client/tools/rhncfg/config_common/file_utils.py @@ -90,6 +90,19 @@ 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'): + try: + import dateutil.parser + import time + xmlrpc_time = file_struct['modified'] + ftime = dateutil.parser.parse(xmlrpc_time.value) + epoch_time = time.mktime(ftime.timetuple()) + os.utime(fullpath, (epoch_time, epoch_time)) + except Exception: + 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