MkConf - Superclass for configuration file generation libraries
base
use MkConf; require MkConf::hosts; # to generate "/etc/hosts", for example
%ok_args = MkConf::hosts->allowed_args; # returns something like ( obj => 1, sysarch => 1)
$conf = MkConf::hosts->new($obj); $conf = MkConf::hosts->new(obj => $obj); $conf = MkConf::hosts->new(sysarch => $sysarch);
$retval = $conf->generate;
$conf->print(); $conf->print(*STDOUT);
@filelist = $conf->files;
$retval = $conf->write();
$conf->restart;
This package provides a framework and commonly used methods for generating configuration files based on the contents of the CIToolkit database. It should also support non-file based configurations, such as calling external tools to modify kernel settings.
MkConf should not be used directly. Rather, each configuration type should be generated by a subclass.
$conf = MkConf::dhcpd->new(obj => $obj);
where 'obj' and 'sysarch' are commonly used keys, or with a single Device object as the only parameter:
$conf = MkConf::dhcpd->new($obj);
new() will accept%args = MkConf::pxelinux->allowed_args();
Returns a hash, where the keys are all the valid keys
for the new() parameter hash. May be useful when
trying to decide how to create a MkConf object
for a given config file type.
By default, only ``obj'' args are allowed, but some config types may add ``sysarch'', etc.
Process the device (and arguments passed via the new call) to determine the file contents.
Returns ``0'' on successfull completion. On error, returns nonzero string describing the problem.
DEVELOPERS NOTE: generate is NOT IMPLEMENTED in the MkConf superclass, and MUST be overridden by ALL subclasses.
Keeps track of files printed, so as to only print each one ONCE.
print implies generate
Simply returns an array of filenames, with the paths used on the NFS server for the diskless hierarchy.
SOMETIMES files implies generate, but the rest of the time it isn't necessary to generate anyway.
Try to make sure currently running on a admin node at the top of the diskless hierarchy (ie. nfs host) and then write the appropriate file or files to disk.
Returns ``0'' on successfull completion. On error, returns nonzero string describing the problem.
Keeps track of files written, so as to only create each one ONCE.
write implies generate
By default this is actually a no-op. For restart to know what to do, subclasses must define the _restart_script method, and optionally the _restart_args and _restart_output_ok methods. (Described below.)
restart returns ``0'' on successfull completion. Returns nonzero on error, possibly as a string describing the problem.
Keeps track of restart commands run, so as to only execute each one ONCE.
These methods should not be used directly by parent scripts. They exist primarily so that MkConf subclasses can easily override them and change how or where configurations are generated.
Returns a string of the command name, absolute path.
DEVELOPERS NOTE: _location_dir is NOT IMPLEMENTED in the MkConf superclass, and MUST be overridden by ALL subclasses.
Returns a string.
Unless overridden by a subclass, returns the same thing as _location_dir, meaning the whole path must already be present and no subdirs will be created.
The Keywords are as follows:
self - write into a node-specific directory
image - write into the current node's image dir
leader - apply the config to the node's leader (should be followed by self or image)
By default, returns an array with just one entry: ``self''.
Need to describe the structure of:
the "parameter hash" for new()
$self->{files}
mk_conf