ksconf.commands package

Submodules

ksconf.commands.check module

ksconf.commands.check.do_check(args)

ksconf.commands.combine module

ksconf.commands.combine.do_combine(args)

ksconf.commands.diff module

ksconf.commands.diff.do_diff(args)

Compare two configuration files.

ksconf.commands.merge module

ksconf.commands.merge.do_merge(args)

Merge multiple configuration files into one

ksconf.commands.minimize module

ksconf.commands.minimize.do_minimize(args)
ksconf.commands.minimize.explode_default_stanza(conf, default_stanza=None)

Take the GLOBAL stanza, (aka [default]) and apply it’s settings underneath ALL other stanzas. This is mostly only useful in minimizing and other comparison operations.

ksconf.commands.promote module

ksconf.commands.promote.do_promote(args)

ksconf.commands.sort module

ksconf.commands.sort.do_sort(args)

Sort a single configuration file.

ksconf.commands.unarchive module

ksconf.commands.unarchive.do_unarchive(args)

Install / upgrade a Splunk app from an archive file

Module contents

class ksconf.commands.ConfDirProxy(name, mode, parse_profile=None)

Bases: object

get_file(relpath)
class ksconf.commands.ConfFileProxy(name, mode, stream=None, parse_profile=None, is_file=None)

Bases: object

backup(bkname=None)
checksum(hash='sha256')
close()
data
dump(data)
is_file()
load(profile=None)
reset()
set_parser_option(**kwargs)

Setting a key to None will remove that setting.

stream
class ksconf.commands.ConfFileType(mode='r', action='open', parse_profile=None, accept_dir=False)

Bases: object

Factory for creating conf file object types; returns a lazy-loader ConfFile proxy class

Started from argparse.FileType() and then changed everything. With our use case, it’s often necessary to delay writing, or read before writing to a conf file (depending on weather or not –dry-run mode is enabled, for example.)

Instances of FileType are typically passed as type= arguments to the ArgumentParser add_argument() method.

Keyword Arguments:
  • mode A string indicating how the file is to be opened. Accepts “r”, “w”, and “r+”.
  • action ‘none’, ‘open’, ‘load’. ‘none’ means no preparation or tests; ‘open’ means
    make sure the file exists/openable; ‘load’ means make sure the file can be opened and parsed successfully.