Hello Miroslav and Jan, 

Follow a better patch for BZ#699966 with --ignore-missing and a better
logical flow. 

[root@dhcp96 ~]# rhncfg-manager  update --channel=test2-channel
--ignore-missing /etc/hosts /etc/shadow /etc/autofss /etc/group /etc/bunda
Local file /etc/autofss does not exist. Ignoring file...
Local file /etc/bunda does not exist. Ignoring file...
Pushing to channel nega:
Local file /etc/hosts -> remote file /etc/hosts
Local file /etc/shadow -> remote file /etc/shadow
Local file /etc/group -> remote file /etc/group

Thank you for guidelines guys!

Cheers, 
Marcelo


On Wed, 2011-04-27 at 10:45 +0200, Miroslav Suchý wrote:
> On 04/27/2011 07:46 AM, Marcelo Moreira de Mello wrote:
> > Hello, 
> > 
> > This patch adds a new option in rhncfg-manager which allows to continue
> > if local files were missing. 
> > 
> > Per example: 
> > 
> > [root@server ~]# rhncfg-manager  update --help
> > usage: rhncfg-manager update [options] file [ file ... ]
> > 
> > options:
> >   -c CHANNEL, --channel=CHANNEL
> >                         Upload files in this config channel
> >   -d DEST_FILE, --dest-file=DEST_FILE
> >                         Upload the file as this path
> >   -t TOPDIR, --topdir=TOPDIR
> >                         Make all files relative to this string
> >   --delim-start=DELIM_START
> >                         Start delimiter for variable interpolation
> >   --delim-end=DELIM_END
> >                         End delimiter for variable interpolation
> >   -f, --force           Ignore errors if some local files does not exist
> >   -h, --help            show this help message and exit
> > 
> > [root@server ~]# rhncfg-manager  update --channel=test-channel
> > --force /etc/shadow /etc/autofss /etc/group /etc/no_exists
> > Local file /etc/autofss does not exist. Ignoring file...
> > Local file /etc/no_exists does not exist. Ignoring file...
> > Pushing to channel test-channel:
> > Local file /etc/shadow -> remote file /etc/shadow
> > Local file /etc/group -> remote file /etc/group
> > 
> > 
> > Cheers, 
> > Marcelo
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Spacewalk-devel mailing list
> > Spacewalk-devel@redhat.com
> > https://www.redhat.com/mailman/listinfo/spacewalk-devel
> 
> 
> I do not like this:
> -            if not os.path.exists(local_file):
> -                die(9, "No such file `%s'" % local_file)
> +            if self.options.force:
> +                if not os.path.exists(local_file):
> +                    files_to_push.remove((local_file,remote_file))
> +                    print "Local file %s does not exist. Ignoring
> file..." %(local_file)
> +            else:
> +                if not os.path.exists(local_file):
> +                    die(9, "No such file `%s'" % local_file)
> 
> I would rather use:
> 
> if not os.path.exists(local_file):
>       if self.options.force:
>               files_to_push.remove((local_file,remote_file))
>                 print "Local file %s does not exist. Ignoring
>       else:
>               die(9, "No such file `%s'" % local_file)
> 
> This is very similar, but you do not duplicate that line with:
>  os.path.exists(local_file)
> also IMHO it better reflect the logical flow.
> 

-- 
Marcelo Moreira de Mello <mme...@redhat.com>
Red Hat Inc.
From: Marcelo Moreira de Mello <mme...@redhat.com>
Date: Wed, 27 Apr 2011 09:32:24 -0300
Subject: [PATCH]   699966 - added --ignore-missing option in rhncfg-manager to ignore missing local files when adding or uploading files

---
 .../tools/rhncfg/config_management/rhncfg_add.py   |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/client/tools/rhncfg/config_management/rhncfg_add.py b/client/tools/rhncfg/config_management/rhncfg_add.py
index 0795691..b88fbc1 100644
--- a/client/tools/rhncfg/config_management/rhncfg_add.py
+++ b/client/tools/rhncfg/config_management/rhncfg_add.py
@@ -44,6 +44,10 @@ class Handler(handler_base.HandlerBase):
             '--delim-end',          action="store",
              help="End delimiter for variable interpolation",
          ),
+        handler_base.HandlerBase._option_class(
+            '-i', '--ignore-missing',       action="store_true",
+             help="Ignore missing local files",
+         ),
     ]
                                                     
     def run(self):
@@ -96,7 +100,11 @@ class Handler(handler_base.HandlerBase):
 
         for (local_file, remote_file) in files_to_push:
             if not os.path.exists(local_file):
-                die(9, "No such file `%s'" % local_file)
+                if self.options.ignore_missing:
+                    files_to_push.remove((local_file,remote_file))
+                    print "Local file %s does not exist. Ignoring file..." %(local_file)
+                else:
+                    die(9, "No such file `%s'" % local_file)
 
         print "Pushing to channel %s:" % (channel, )
 
-- 
1.7.1

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to