Update trigger to config

This commit is contained in:
Darko Poljak 2019-01-28 16:46:40 +01:00
parent a87a69e281
commit 0e92f5bb0a
3 changed files with 60 additions and 44 deletions

View file

@ -440,11 +440,8 @@ def get_parsers():
parser['trigger'] = parser['sub'].add_parser( parser['trigger'] = parser['sub'].add_parser(
'trigger', parents=[parser['loglevel'], 'trigger', parents=[parser['loglevel'],
parser['beta'], parser['beta'],
parser['common'],
parser['config_main']]) parser['config_main']])
parser['trigger'].add_argument(
'-6', '--ipv6', default=False,
help=('Listen to both IPv4 and IPv6 (instead of only IPv4)'),
action='store_true')
parser['trigger'].add_argument( parser['trigger'].add_argument(
'-D', '--directory', action='store', required=False, '-D', '--directory', action='store', required=False,
help=('Where to create local files')) help=('Where to create local files'))
@ -452,7 +449,11 @@ def get_parsers():
'-H', '--http-port', action='store', default=3000, required=False, '-H', '--http-port', action='store', default=3000, required=False,
help=('Create trigger listener via http on specified port')) help=('Create trigger listener via http on specified port'))
parser['trigger'].add_argument( parser['trigger'].add_argument(
'-S', '--source', action='store', required=False, '--ipv6', default=False,
help=('Listen to both IPv4 and IPv6 (instead of only IPv4)'),
action='store_true')
parser['trigger'].add_argument(
'-O', '--source', action='store', required=False,
help=('Which file to copy for creation')) help=('Which file to copy for creation'))
parser['trigger'].set_defaults(func=cdist.trigger.Trigger.commandline) parser['trigger'].set_defaults(func=cdist.trigger.Trigger.commandline)

View file

@ -140,7 +140,7 @@ class Config(object):
# Determine forcing IPv4/IPv6 options if any, only for # Determine forcing IPv4/IPv6 options if any, only for
# default remote commands. # default remote commands.
if args.force_ipv: if hasattr(args, 'force_ipv') and args.force_ipv:
force_addr_opt = " -{}".format(args.force_ipv) force_addr_opt = " -{}".format(args.force_ipv)
else: else:
force_addr_opt = "" force_addr_opt = ""
@ -353,12 +353,15 @@ class Config(object):
@staticmethod @staticmethod
def _address_family(args): def _address_family(args):
if hasattr(args, 'force_ipv'):
if args.force_ipv == 4: if args.force_ipv == 4:
family = socket.AF_INET family = socket.AF_INET
elif args.force_ipv == 6: elif args.force_ipv == 6:
family = socket.AF_INET6 family = socket.AF_INET6
else: else:
family = 0 family = 0
else:
family = 0
return family return family
@staticmethod @staticmethod

View file

@ -87,12 +87,12 @@ SYNOPSIS
cdist shell [-h] [-l LOGLEVEL] [-q] [-v] [-s SHELL] cdist shell [-h] [-l LOGLEVEL] [-q] [-v] [-s SHELL]
cdist trigger [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-C CACHE_PATH_PATTERN] cdist trigger [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] [-4]
[-c CONF_DIR] [-i MANIFEST] [-j [JOBS]] [-n] [-6] [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST]
[-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]] [-j [JOBS]] [-n] [-o OUT_PATH] [-P]
[-r REMOTE_OUT_PATH] [--remote-copy REMOTE_COPY] [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_PATH]
[--remote-exec REMOTE_EXEC] [-6] [-D DIRECTORY] [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC]
[-H HTTP_PORT] [-S SOURCE] [-S] [-D DIRECTORY] [-H HTTP_PORT] [--ipv6] [-O SOURCE]
DESCRIPTION DESCRIPTION
@ -633,64 +633,76 @@ This command returns the following response codes to client requests:
* 599 for cdist run errors * 599 for cdist run errors
* 500 for cdist/server errors. * 500 for cdist/server errors.
**-4, -force-ipv4**
Force to use IPv4 addresses only. No influence for
custom remote commands.
**-6, --ipv6** **-6, --force-ipv6**
Force to use IPv6 addresses only. No influence for
Listen to both IPv4 and IPv6 (instead of only IPv4) custom remote commands.
**-b, --beta**
Enable beta functionality.
**-C CACHE_PATH_PATTERN, --cache-path-pattern CACHE_PATH_PATTERN** **-C CACHE_PATH_PATTERN, --cache-path-pattern CACHE_PATH_PATTERN**
Specify custom cache path pattern. If it is not set
Sepcify custom cache path pattern. It can also be set by then default hostdir is used.
CDIST_CACHE_PATH_PATTERN environment variable. If it is not set then
default hostdir is used. For more info on format see
:strong:`CACHE PATH PATTERN FORMAT` below.
**-c CONF_DIR, --conf-dir CONF_DIR** **-c CONF_DIR, --conf-dir CONF_DIR**
Add configuration directory (can be repeated, last one
Add configuration directory (can be repeated, last one wins) wins).
**-D DIRECTORY, --directory DIRECTORY** **-D DIRECTORY, --directory DIRECTORY**
Where to create local files Where to create local files
**-H HTTP_PORT, --http-port HTTP_PORT** **-g CONFIG_FILE, --config-file CONFIG_FILE**
Use specified custom configuration file.
**-H HTTP_PORT, --http-port HTTP_PORT**
Create trigger listener via http on specified port Create trigger listener via http on specified port
**-i MANIFEST, --initial-manifest MANIFEST** **-i MANIFEST, --initial-manifest MANIFEST**
Path to a cdist manifest or '-' to read from stdin.
path to a cdist manifest or '-' to read from stdin. **--ipv6**
Listen to both IPv4 and IPv6 (instead of only IPv4)
**-j [JOBS], --jobs [JOBS]** **-j [JOBS], --jobs [JOBS]**
Operate in parallel in specified maximum number of
Specify the maximum number of parallel jobs, currently jobs. Global explorers, object prepare and object run
only global explorers are supported are supported. Without argument CPU count is used by
default. Currently in beta.
**-n, --dry-run** **-n, --dry-run**
Do not execute code.
do not execute code **-O SOURCE, --source SOURCE**
Which file to copy for creation
**-o OUT_PATH, --out-dir OUT_PATH** **-o OUT_PATH, --out-dir OUT_PATH**
Directory to save cdist output in.
directory to save cdist output in **-P, --timestamp**
Timestamp log messages with the current local date and
time in the format: YYYYMMDDHHMMSS.us.
**-R [{tar,tgz,tbz2,txz}], --use-archiving [{tar,tgz,tbz2,txz}]**
Operate by using archiving with compression where
appropriate. Supported values are: tar - tar archive,
tgz - gzip tar archive (the default), tbz2 - bzip2 tar
archive and txz - lzma tar archive. Currently in beta.
**-r REMOTE_OUT_PATH, --remote-out-dir REMOTE_OUT_PATH** **-r REMOTE_OUT_PATH, --remote-out-dir REMOTE_OUT_PATH**
Directory to save cdist output in on the target host.
Directory to save cdist output in on the target host
**--remote-copy REMOTE_COPY** **--remote-copy REMOTE_COPY**
Command to use for remote copy (should behave like
Command to use for remote copy (should behave like scp) scp).
**--remote-exec REMOTE_EXEC** **--remote-exec REMOTE_EXEC**
Command to use for remote execution (should behave
like ssh).
Command to use for remote execution (should behave like ssh) **-S, --disable-saving-output-streams**
Disable saving output streams.
**-S SOURCE, --source SOURCE**
Which file to copy for creation
CONFIGURATION CONFIGURATION
------------- -------------