Ahem... ________________________________________ From: [email protected] [[email protected]] On Behalf Of Miroslav Suchý [[email protected]] Sent: Thursday, 12 February 2009 7:31 PM To: [email protected]; Coe, Colin C. (Unix Engineer) Subject: Re: [Spacewalk-devel] PATCH: Allow for rhncfg-client get to --exclude files
Coe, Colin C. (Unix Engineer) wrote: > This patch (which I'm submitting on behalf of a college, Ian Chapman) adds an > --exclude parameter to 'rhncfg-client get'. This allows you to get all files > for this system except that one. > > Example: > rhncfg-client get --exclude /etc/ldap.conf --exclude /etc/openldap/ldap.conf > > Please credit this to Ian. Hmm, did you intend to actually attach the patch to your email? :)) -- Miroslav Suchy RHN Satellite Engineering, Red Hat _______________________________________________ Spacewalk-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/spacewalk-devel 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.
From 114364d3c9a14fc5ef49d7f4b80141d399640ab1 Mon Sep 17 00:00:00 2001 From: Colin Coe <[email protected]> Date: Thu, 12 Feb 2009 19:09:07 +0900 Subject: [PATCH] Allow for rhncfg-client get to --exclude files --- client/tools/rhncfg/config_client/handler_base.py | 6 +++- client/tools/rhncfg/config_client/rhncfgcli_get.py | 39 ++++++++++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/client/tools/rhncfg/config_client/handler_base.py b/client/tools/rhncfg/config_client/handler_base.py index 729e93c..270a5ad 100644 --- a/client/tools/rhncfg/config_client/handler_base.py +++ b/client/tools/rhncfg/config_client/handler_base.py @@ -50,7 +50,7 @@ class HandlerBase(handler_base.HandlerBase): files.append(file) files.sort() return files - + # Main function to be run def run(self): log_debug(2) @@ -76,6 +76,10 @@ class TopdirHandlerBase(HandlerBase): '--topdir', action="store", help="Make all file operations relative to this directory.", ), + HandlerBase._option_class( + '--exclude', action="append", + help="Excludes a file from being deployed with 'get'. May be used multiple times.", + ), ] def get_dest_file(self, file): diff --git a/client/tools/rhncfg/config_client/rhncfgcli_get.py b/client/tools/rhncfg/config_client/rhncfgcli_get.py index d361949..b808b7f 100644 --- a/client/tools/rhncfg/config_client/rhncfgcli_get.py +++ b/client/tools/rhncfg/config_client/rhncfgcli_get.py @@ -24,7 +24,7 @@ import handler_base def deploying_mesg_callback(path): print "Deploying %s" % path - + class Handler(handler_base.TopdirHandlerBase): _usage_options = handler_base.HandlerBase._usage_options + " [ files ... ]" def run(self): @@ -32,14 +32,20 @@ class Handler(handler_base.TopdirHandlerBase): dep_trans = DeployTransaction(transaction_root=topdir) dep_trans.deploy_callback(deploying_mesg_callback) - + + # Setup the excludes hash + excludes = {} + if self.options.exclude is not None: + for exclude in enumerate(self.options.exclude): + excludes[exclude[1]] = None + for path in self.get_valid_files(): (directory, filename) = os.path.split(path) - directory = os.path.normpath("%s%s%s" % (topdir, os.sep, directory)) + directory = os.path.normpath("%s%s%s" % (topdir, os.sep, directory)) try: - finfo = self.repository.get_file_info(path, auto_delete=0, dest_directory=directory) + finfo = self.repository.get_file_info(path, auto_delete=0, dest_directory=directory) except cfg_exceptions.DirectoryEntryIsFile, e: print "Error: unable to deploy directory %s, as it is already a file on disk" % (e[0], ) continue @@ -50,14 +56,17 @@ class Handler(handler_base.TopdirHandlerBase): (processed_path, file_info, dirs_created) = finfo - try: - dep_trans.add_preprocessed(path, processed_path, file_info, dirs_created) - except cfg_exceptions.UserNotFound, e: - print "Error: unable to deploy file %s, information on user '%s' could not be found." % (path,e[0]) - continue - except cfg_exceptions.GroupNotFound, e: - print "Error: unable to deploy file %s, information on group '%s' could not be found." % (path, e[0]) - continue + if excludes.has_key(path): + print "Excluding %s" % path + else: + try: + dep_trans.add_preprocessed(path, processed_path, file_info, dirs_created) + except cfg_exceptions.UserNotFound, e: + print "Error: unable to deploy file %s, information on user '%s' could not be found." % (path,e[0]) + continue + except cfg_exceptions.GroupNotFound, e: + print "Error: unable to deploy file %s, information on group '%s' could not be found." % (path, e[0]) + continue try: dep_trans.deploy() @@ -87,7 +96,7 @@ class Handler(handler_base.TopdirHandlerBase): except cfg_exceptions.GroupNotFound, f: pass print "Error: unable to deploy file %s, information on group '%s' could not be found." % (e[0], f[0]) - + except cfg_exceptions.FileEntryIsDirectory, e: try: dep_trans.rollback() @@ -99,7 +108,7 @@ class Handler(handler_base.TopdirHandlerBase): #5/5/05 wregglej - 136415 Added exception handling for missing group except cfg_exceptions.GroupNotFound, f: pass - + print "Error: unable to deploy file %s, as it is already a directory on disk" % (e[0],) except cfg_exceptions.DirectoryEntryIsFile, e: try: @@ -123,7 +132,7 @@ class Handler(handler_base.TopdirHandlerBase): #5/5/05 wregglej - 136415 Added exception handling for unknown group except cfg_exceptions.GroupNotFound, f: pass - raise + raise else: print "Deploy failed, rollback successful" raise -- 1.5.5.1
_______________________________________________ Spacewalk-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/spacewalk-devel
