Name

confd_load — Command line utility to load and save ConfD configurations

Synopsis

confd_load [-W] [-S] [(1) common options] [filename]

confd_load -l [ -m | -r ] [-D] [(1) common options] [filename...]

confd_load -C [-R] [filename...]

confd_load -h | -?
(1) [-d] [-t] [-F { x | p | o | j | c | i } ] [ -H | -U ] [-a] [-e] [ [-u user] [-g group...] [-c context] | [-i]] [[-p keypath] | [-P XPath]] [-o] [-s]

DESCRIPTION

The confd_load command is a command line interface to the functions maapi_save_config(), maapi_load_config(), maapi_load_config_stream(), and cdb_load_file() respectively.

This command provides a convenient way of loading and saving all or parts of the configuration in different formats. It can be used to initialize or restore configurations as well as in CLI commands.

If you run confd_load without any options it will print the current configuration in XML format on stdout. The exit status will be zero on success and non-zero otherwise.

Source code to this utility is included in the distribution as src/confd/tools/confd_load.c.

COMMON OPTIONS

-d

Debug flag. Add more to increase debug level. All debug output will be to stderr.

-t

Measure how long the requested command takes and print the result on stderr.

-F x | p | o | j | c | i

Selects the format of the configuration, must be set both when loading and saving. One of XML (x), pretty XML (p), JSON (o), curly braces J-style CLI (j), C-style CLI (c), or I-style CLI (i). Default is XML.

-H

Hide all hidden nodes. By default, no nodes are hidden unless confd_load has attached to an existing transaction, in which case the hidden nodes are the same as in that transaction's session.

-U

Unhide all hidden nodes. By default, no nodes are hidden unless confd_load has attached to an existing transaction, in which case the hidden nodes are the same as in that transaction's session.

-u user, -g group ..., -c context

Loading and saving the configuration is done in a user session, using these options it is possible to specify which user, groups (more than one -g can be used to add groups), and context that should be used when starting the user session. If only a user is supplied the user is assumed to belong to a single group with the same name as the user. This is significant in that AAA rules will be applied for the specified user / groups / context combination. The default is to use the system context, which implies that AAA rules will not be applied at all.

Note

If the environment variables CONFD_MAAPI_USID and CONFD_MAAPI_THANDLE are set (see the ENVIRONMENT section), or if the -i option is used, these options are silently ignored, since confd_load will attach to an existing transaction.

-i

Instead of starting a new user session and transaction, confd_load will try to attach to the init session. This is only valid when ConfD is in start phase 0, and will fail otherwise. It can be used to load a factory defaultfile during startup, or loading a file during upgrade.

-s

Start transaction towards the startup datastore (instead of the default running). I.e. when loading, the configuration loaded will be committed to startup, and as such won't take effect until ConfD is restarted.

SAVE CONFIGURATION

By default the complete current configuration will be output on stdout. To save it in a file add the filename on the command line (the -f option is deprecated). The file is opened by the confd_load utility, permissions and ownership will be determined by the user running confd_load. Output format is specified using the -F option.

When saving the configuration in XML format, the context of the user session (see the -c option) will determine which namespaces with export restriction (from tailf:export) that are included. If the system context is used (this is the default), all namespaces are saved, regardless of export restriction. When saving the configuration in one of the CLI formats, the context used for this selection is always cli.

A number of options are only applicable, or have a special meaning when saving the configuration:

-f filename

Filename to save configuration to (option is deprecated, just give the filename on the command line).

-W

Include leaves which are unset (set to their default value) in the output. By default these leaves are not included in the output. (Corresponds to the MAAPI_CONFIG_WITH_DEFAULTS flag).

-S

Include the default value of a leaf as a comment (only works for CLI formats, not XML). (Corresponds to the MAAPI_CONFIG_SHOW_DEFAULTS flag).

-p keypath

Only include the configuration below keypath in the output.

-P XPath

Filter the configuration using the XPath expression. (Only works for the XML format.)

-o

Include operational data in the output. (Corresponds to the MAAPI_CONFIG_WITH_OPER flag).

LOAD CONFIGURATION

When the -l option is present confd_load will load all the files listed on the command line using the maapi_load_config() function. The file(s) are expected to be in XML format unless otherwise specified using the -F flag. Note that it is the ConfD daemon that opens the file(s), it must have permission to do so. However relative pathnames are assumed to be relative to the working directory of the confd_load command (it will pass an absolute pathname to maapi_load_config()).

If neither of the -m and -r options are given when multiple files are listed on the command line, confd_load will silently treat the second and subsequent files as if -m had been given, i.e. it will merge in the contents of these files instead of deleting and replacing the configuration for each file. Note, we almost always want the merge behavior. If no file is given, or "-" is given as a filename, confd_load will stream standard input to ConfD by using maapi_load_config_stream().

-f filename

The file to load (deprecated, just list the file after the options instead).

-m

Merge in the contents of filename, the (somewhat unfortunate) default is to delete and replace. (Corresponds to the MAAPI_CONFIG_MERGE flag).

-x

Lax loading. Only applies to XML loading. Ignore unknown namespaces, attributes and elements.

-r

Replace the part of the configuration that is present in filename, the default is to delete and replace. (Corresponds to the MAAPI_CONFIG_REPLACE flag).

-a

When loading configuration in 'i' or 'c' format, do a commit operation after each line. Default and recommended is to only commit when all the configuration has been loaded. (Corresponds to the MAAPI_CONFIG_AUTOCOMMIT flag).

-e

When loading configuration do not abort when encountering errors (corresponds to the MAAPI_CONFIG_CONTINUE_ON_ERROR flag).

-D

Call maapi_delete_all (MAAPI_DEL_ALL) before loading the file.

-p keypath

Call maapi_delete(keypath) before loading the file.

-o

Accept but ignore contents in the file which is operational data (without this flag it will be an error). (Corresponds to the MAAPI_CONFIG_WITH_OPER flag)

LOAD CDB OPERATIONAL

The -C option is a direct interface to the cdb_load_file() function.

The -C option is used to load operational data. When you use -C all other options except -R (and -d) are ignored, since they don't apply. Files on the command line must be in XML format and will be fed to cdb_load_file() in the order they are listed. If no file is given, or "-" is given as a filename, confd_load will read standard input and use cdb_load_str() to load the collected data. If the -R option is included, CDB operational subscription notifications will be generated.

Any data which isn't part of CDB operational per the data model will be ignored. This means that you can save a single file with both configuration and operational data and feed it back to confd_load.

If you use a relative path for filename it is assumed to be relative to the working directory of the confd_load command (it will pass an absolute pathname to cdb_load_file()).

EXAMPLES

Example 144. Reloading all xml files in the cdb directory

confd_load -D -m -l cdb/*.xml

Example 145. Merging in the contents of conf.cli

confd_load -l -m -F j conf.cli

Example 146. Print interface config and statistics data in cli format

confd_load -F i -o -p /sys:sys/ifc

Example 147. Using xslt to format output

confd_load -F x -p /sys:sys/ifc | xsltproc fmtifc.xsl -

Example 148. Using xmllint to pretty print the xml output

confd_load -F x | xmllint --format -

Example 149. Saving config and operational data to /tmp/conf.xml

confd_load -F x -o > /tmp/conf.xml

Example 150. Restoring both config and operational data

confd_load -l -F x -o /tmp/conf.xml
confd_load -C /tmp/conf.xml

Example 151. Measure how long it takes to fetch config

confd_load -t > /dev/null
elapsed time: 0.011 s

Example 152. Output all instances in list /foo/table which has ix larger than 10

confd_load -F x -P "/foo/table[ix > 10]"

ENVIRONMENT

CONFD_IPC_ADDR, CONFD_IPC_EXTADDR

The address used to connect to the ConfD daemon, overrides the compiled in default.

CONFD_IPC_PORT

The port number to connect to the ConfD daemon on, overrides the compiled in default.

CONFD_IPC_EXTSOPATH

The absolute path to the shared object to use for a connection using external IPC when CONFD_IPC_EXTADDR is given.

CONFD_MAAPI_USID, CONFD_MAAPI_THANDLE

If set confd_load will use maapi_attach2() to attach to an existing transaction in an existing user session instead of starting a new session.

These environment variables are set by the ConfD CLI when it invokes external commands, which means you can run confd_load directly from the CLI. For example, the following addition to the <operationalMode> in a clispec file (see clispec(5))

<cmd name="servers" mount="show">
  <info/>
  <help/>
  <callback>
    <exec>
      <osCommand>confd_load</osCommand>
          <args>-F j -p /system/servers</args>
    </exec>
  </callback>
</cmd>

will add a show servers command which, when run will invoke confd_load -F j -p /system/servers. This will output the configuration below /system/servers in curly braces format.

Note that when these environment variables are set, it means that the configuration will be loaded into the current CLI transaction (which must be in configure mode, and have AAA permissions to actually modify the config). To load (or save) a file in a separate transaction, unset these two environment variables before invoking the confd_load command.

SEE ALSO

confd_lib_maapi(3) - Confd MAAPI library

confd_lib_cdb(3) - Confd CDB library