Commit 7dddcb79 authored by Darko Poljak's avatar Darko Poljak

Add libexec support and migrate cdist-dump

parent 98590802
Pipeline #514 passed with stage
in 49 seconds
......@@ -6,6 +6,7 @@ import collections
import functools
import cdist.configuration
import cdist.preos
import cdist.libexec as libexec
# set of beta sub-commands
......@@ -436,6 +437,9 @@ def get_parsers():
' should be POSIX compatible shell.'))
# Libexec
libexec.create_parsers(parser, parser['sub'])
for p in parser:
parser[p].epilog = EPILOG
import os
import os.path
import cdist.argparse
import subprocess
libexec_delimiter = '-'
libexec_prefix = 'cdist' + libexec_delimiter
libexec_path = os.path.abspath(
os.path.join(os.path.dirname(cdist.__file__), 'conf', 'libexec'))
def scan():
if os.path.isdir(libexec_path):
with os.scandir(libexec_path) as it:
for entry in it:
if ( and
entry.is_file() and
os.access(entry.path, os.X_OK)):
start = + 1
def is_libexec_command(name):
for x in scan():
if name == x:
return True
return False
def create_parsers(parser, parent_parser):
for name in scan():
parser[name] = parent_parser.add_parser(name, add_help=False)
def run(name, argv):
lib_name = libexec_prefix + name
lib_path = os.path.join(libexec_path, lib_name)
args = [lib_path, ]
......@@ -48,17 +48,17 @@ Using debug dump helper script
Since cdist stores data to local cache that can be used for debugging there
is a helper script that dumps data from local cache,
`cdist-dump <man1/cdist-dump.html>`_.
`cdist dump <man1/cdist-dump.html>`_.
For more info see:
.. code-block:: sh
cdist-dump -h
cdist_dump -h
Or from cdist git cloned directory:
.. code-block:: sh
./scripts/cdist-dump -h
./bin/cdist dump -h
......@@ -11,17 +11,17 @@ SYNOPSIS
cdist-dump [options] [host...]
cdist dump [options] [host...]
cdist-dump is a helper script that dumps data from local cdist cache for
cdist dump is a helper script that dumps data from local cdist cache for
specified hosts. If host is not specified then all data from cache directory
is dumped. Default cache directory is '~/.cdist/cache'.
cdist-dump can be used for debugging existing types, host configuration and
cdist dump can be used for debugging existing types, host configuration and
new types.
......@@ -88,10 +88,10 @@ EXAMPLES
.. code-block:: sh
# Dump all
% cdist-dump -a
% cdist dump -a
# Dump only code-* output
% cdist-dump -c
% cdist dump -c
......@@ -30,14 +30,20 @@ import cdist.config
import cdist.install
import cdist.inventory
import cdist.libexec as libexec
def commandline():
"""Parse command line"""
# preos subcommand hack
if len(sys.argv) > 1 and sys.argv[1] == 'preos':
return cdist.preos.PreOS.commandline(sys.argv[1:])
if len(sys.argv) > 1:
# preos subcommand hack
if sys.argv[1] == 'preos':
return cdist.preos.PreOS.commandline(sys.argv[1:])
# libexec subcommands hack
if libexec.is_libexec_command(sys.argv[1]):
return[1], sys.argv[2:])
parser, cfg = cdist.argparse.parse_and_configure(sys.argv[1:])
args = cfg.get_args()
......@@ -56,7 +56,7 @@ setup(
packages=["cdist", "cdist.core", "cdist.exec", "cdist.util", ],
package_data={'cdist': package_data},
scripts=["scripts/cdist", "scripts/cdist-dump", "scripts/cdist-new-type"],
scripts=["scripts/cdist", "scripts/cdist-new-type"],
description="A Usable Configuration Management System",
author="Nico Schottelius",
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment