forked from ungleich-public/cdist
		
	Add -b/--enable-beta option for enabling beta functionalities.
This commit is contained in:
		
					parent
					
						
							
								f858191976
							
						
					
				
			
			
				commit
				
					
						1c07b63f1d
					
				
			
		
					 4 changed files with 35 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -71,6 +71,8 @@ def inspect_ssh_mux_opts():
 | 
			
		|||
class Config(object):
 | 
			
		||||
    """Cdist main class to hold arbitrary data"""
 | 
			
		||||
 | 
			
		||||
    BETA_ARGS = ['jobs']
 | 
			
		||||
 | 
			
		||||
    def __init__(self, local, remote, dry_run=False, jobs=None):
 | 
			
		||||
 | 
			
		||||
        self.local = local
 | 
			
		||||
| 
						 | 
				
			
			@ -109,6 +111,19 @@ class Config(object):
 | 
			
		|||
                for host in source:
 | 
			
		||||
                    yield host
 | 
			
		||||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def _check_beta(cls, args_dict):
 | 
			
		||||
        if 'beta' not in args_dict:
 | 
			
		||||
            args_dict['beta'] = False
 | 
			
		||||
        # Check only if beta is not enabled: if beta option is specified then
 | 
			
		||||
        # raise error.
 | 
			
		||||
        if not args_dict['beta']:
 | 
			
		||||
            err_msg = ("\'{}\' is beta, but beta is not enabled. If you want "
 | 
			
		||||
                       "to use it please enable beta functionalities.")
 | 
			
		||||
            for arg in cls.BETA_ARGS:
 | 
			
		||||
                if arg in args_dict:
 | 
			
		||||
                    raise cdist.Error(err_msg.format(arg))
 | 
			
		||||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def commandline(cls, args):
 | 
			
		||||
        """Configure remote system"""
 | 
			
		||||
| 
						 | 
				
			
			@ -120,6 +135,10 @@ class Config(object):
 | 
			
		|||
        if args.manifest == '-' and args.hostfile == '-':
 | 
			
		||||
            raise cdist.Error(("Cannot read both, manifest and host file, "
 | 
			
		||||
                               "from stdin"))
 | 
			
		||||
 | 
			
		||||
        args_dict = vars(args)
 | 
			
		||||
        cls._check_beta(args_dict)
 | 
			
		||||
 | 
			
		||||
        # if no host source is specified then read hosts from stdin
 | 
			
		||||
        if not (args.hostfile or args.host):
 | 
			
		||||
            args.hostfile = '-'
 | 
			
		||||
| 
						 | 
				
			
			@ -148,7 +167,6 @@ class Config(object):
 | 
			
		|||
        args.remote_exec_pattern = None
 | 
			
		||||
        args.remote_copy_pattern = None
 | 
			
		||||
 | 
			
		||||
        args_dict = vars(args)
 | 
			
		||||
        # if remote-exec and/or remote-copy args are None then user
 | 
			
		||||
        # didn't specify command line options nor env vars:
 | 
			
		||||
        # inspect multiplexing options for default cdist.REMOTE_COPY/EXEC
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,8 @@
 | 
			
		|||
Changelog
 | 
			
		||||
---------
 | 
			
		||||
next:
 | 
			
		||||
	* Core: Add -j, --jobs option for parallel execution and add parallel support for global explorers (Darko Poljak)
 | 
			
		||||
	* Core: Add -b, --enable-beta option for enabling beta functionalities (Darko Poljak)
 | 
			
		||||
	* Core: Add -j, --jobs option for parallel execution and add parallel support for global explorers (currently in beta) (Darko Poljak)
 | 
			
		||||
	* Core: Add derived env vars for target hostname and fqdn (Darko Poljak)
 | 
			
		||||
	* New type: __keyboard: Set keyboard layout (Carlos Ortigoza)
 | 
			
		||||
	* Documentation: Re-license types' man pages to GPLV3+ (Dmitry Bogatov,	Darko Poljak)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ SYNOPSIS
 | 
			
		|||
 | 
			
		||||
    cdist config [-h] [-d] [-v] [-c CONF_DIR] [-f HOSTFILE] [-i MANIFEST]
 | 
			
		||||
                 [-n] [-o OUT_PATH] [-p] [-s] [--remote-copy REMOTE_COPY]
 | 
			
		||||
                 [--remote-exec REMOTE_EXEC] [-j [JOBS]]
 | 
			
		||||
                 [--remote-exec REMOTE_EXEC] [-j [JOBS]] [-b]
 | 
			
		||||
                 [host [host ...]]
 | 
			
		||||
 | 
			
		||||
    cdist shell [-h] [-d] [-v] [-s SHELL]
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +110,12 @@ Configure one or more hosts.
 | 
			
		|||
.. option:: -j [JOBS], --jobs [JOBS]
 | 
			
		||||
 | 
			
		||||
    Specify the maximum number of parallel jobs; currently only
 | 
			
		||||
    global explorers are supported
 | 
			
		||||
    global explorers are supported (currently in beta)
 | 
			
		||||
 | 
			
		||||
.. option:: -b, --enable-beta
 | 
			
		||||
 | 
			
		||||
    Enable beta functionalities. Beta functionalities include the
 | 
			
		||||
    following options: -j/--jobs.
 | 
			
		||||
 | 
			
		||||
SHELL
 | 
			
		||||
-----
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -122,10 +122,15 @@ def commandline():
 | 
			
		|||
           default=os.environ.get('CDIST_REMOTE_EXEC'))
 | 
			
		||||
    parser['config'].add_argument(
 | 
			
		||||
           '-j', '--jobs', nargs='?', type=check_positive_int,
 | 
			
		||||
           help=('Specify the maximum number of parallel jobs; currently '
 | 
			
		||||
                 'only global explorers are supported'),
 | 
			
		||||
           help=('Specify the maximum number of parallel jobs, currently '
 | 
			
		||||
                 'only global explorers are supported (currently in beta'),
 | 
			
		||||
           action='store', dest='jobs',
 | 
			
		||||
           const=multiprocessing.cpu_count())
 | 
			
		||||
    parser['config'].add_argument(
 | 
			
		||||
           '-b', '--enable-beta',
 | 
			
		||||
           help=('Enable beta functionalities. Beta functionalities '
 | 
			
		||||
                 'include the following options: -j/--jobs.'),
 | 
			
		||||
           action='store_true', dest='beta', default=False)
 | 
			
		||||
    parser['config'].set_defaults(func=cdist.config.Config.commandline)
 | 
			
		||||
 | 
			
		||||
    # Shell
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue