New command-line option for dumping configuration options for all clixon applications after load
Removed -s dump
This commit is contained in:
parent
0e81e8137b
commit
c101799e74
12 changed files with 267 additions and 32 deletions
|
|
@ -79,7 +79,7 @@
|
|||
#include "backend_plugin_restconf.h"
|
||||
|
||||
/* Command line options to be passed to getopt(3) */
|
||||
#define BACKEND_OPTS "hD:f:E:l:d:p:b:Fza:u:P:1qs:c:U:g:y:o:"
|
||||
#define BACKEND_OPTS "hD:f:E:l:C:d:p:b:Fza:u:P:1qs:c:U:g:y:o:"
|
||||
|
||||
#define BACKEND_LOGFILE "/usr/local/var/clixon_backend.log"
|
||||
|
||||
|
|
@ -463,6 +463,7 @@ usage(clicon_handle h,
|
|||
"\t-f <file>\tClixon config file\n"
|
||||
"\t-E <dir> \tExtra configuration file directory\n"
|
||||
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
|
||||
"\t-C <format>\tDump configuration options on stdout after loading. Format is xml|json|text\n"
|
||||
"\t-d <dir>\tSpecify backend plugin directory (default: %s)\n"
|
||||
"\t-p <dir>\tAdd Yang directory path (see CLICON_YANG_DIR)\n"
|
||||
"\t-b <dir>\tSpecify datastore directory\n"
|
||||
|
|
@ -489,6 +490,8 @@ usage(clicon_handle h,
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
/* Clixon backend application main entry point
|
||||
*/
|
||||
int
|
||||
main(int argc,
|
||||
char **argv)
|
||||
|
|
@ -524,6 +527,8 @@ main(int argc,
|
|||
size_t cligen_bufthreshold;
|
||||
int dbg;
|
||||
size_t sz;
|
||||
int config_dump;
|
||||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
|
||||
/* In the startup, logs to stderr & syslog and debug flag set later */
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
|
||||
|
|
@ -535,7 +540,8 @@ main(int argc,
|
|||
zap = 0;
|
||||
extraxml_file = NULL;
|
||||
dbg = 0;
|
||||
|
||||
config_dump = 0;
|
||||
|
||||
/*
|
||||
* Command-line options for help, debug, and config-file
|
||||
*/
|
||||
|
|
@ -607,6 +613,15 @@ main(int argc,
|
|||
case 'E': /* extra config dir */
|
||||
case 'l' :
|
||||
break; /* see above */
|
||||
case 'C': /* Explicitly dump configuration */
|
||||
if (!strlen(optarg))
|
||||
usage(h, argv[0]);
|
||||
if ((config_dump_format = format_str2int(optarg)) < 0){
|
||||
fprintf(stderr, "Unrecognized dump format: %s(expected: xml|json|text)\n", argv[0]);
|
||||
usage(h, argv[0]);
|
||||
}
|
||||
config_dump++;
|
||||
break;
|
||||
case 'd': /* Plugin directory */
|
||||
if (!strlen(optarg))
|
||||
usage(h, argv[0]);
|
||||
|
|
@ -941,11 +956,6 @@ main(int argc,
|
|||
goto done;
|
||||
/* if status = STARTUP_INVALID, cbret contains info */
|
||||
break;
|
||||
case SM_DUMP_XML:
|
||||
/* dump the tree */
|
||||
cxobj *xc = clicon_conf_xml(h);
|
||||
ret = clixon_xml2file(stdout, xc, 0, 1, "", &fprintf, 0, 1);
|
||||
goto ok;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -978,7 +988,6 @@ main(int argc,
|
|||
/* if status = STARTUP_INVALID, cbret contains info */
|
||||
}
|
||||
}
|
||||
|
||||
if (status != STARTUP_OK){
|
||||
if (cbuf_len(cbret))
|
||||
clicon_log(LOG_NOTICE, "%s: %u %s", __PROGRAM__, getpid(), cbuf_get(cbret));
|
||||
|
|
@ -1005,10 +1014,19 @@ main(int argc,
|
|||
/* Call backend plugin_start with user -- options */
|
||||
if (clixon_plugin_start_all(h) < 0)
|
||||
goto done;
|
||||
/* Explicit dump of config (also debug dump below). */
|
||||
if (config_dump){
|
||||
if (clicon_option_dump1(h, stdout, config_dump_format) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* -1 option to run only once */
|
||||
if (once)
|
||||
goto ok;
|
||||
|
||||
/* Debug dump of config options */
|
||||
clicon_option_dump(h, 1);
|
||||
|
||||
/* Daemonize and initiate logging. Note error is initiated here to make
|
||||
daemonized errors OK. Before this stage, errors are logged on stderr
|
||||
also */
|
||||
|
|
@ -1056,7 +1074,6 @@ main(int argc,
|
|||
goto done;
|
||||
if (clicon_socket_set(h, ss) < 0)
|
||||
goto done;
|
||||
clicon_option_dump(h, 1);
|
||||
|
||||
/* Depending on configure setting, privileges may be dropped here after
|
||||
* initializations */
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
#include "cli_handle.h"
|
||||
|
||||
/* Command line options to be passed to getopt(3) */
|
||||
#define CLI_OPTS "+hD:f:E:l:F:1a:u:d:m:qp:GLy:c:U:o:"
|
||||
#define CLI_OPTS "+hD:f:E:l:C:F:1a:u:d:m:qp:GLy:c:U:o:"
|
||||
|
||||
/*! Check if there is a CLI history file and if so dump the CLI histiry to it
|
||||
* Just log if file does not exist or is not readable
|
||||
|
|
@ -476,6 +476,8 @@ usage(clicon_handle h,
|
|||
"\t-D <level> \tDebug level\n"
|
||||
"\t-f <file> \tConfig-file (mandatory)\n"
|
||||
"\t-E <dir> \tExtra configuration file directory\n"
|
||||
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (stderr is default)\n"
|
||||
"\t-C <format>\tDump configuration options on stdout after loading. Format is xml|json|text\n"
|
||||
"\t-F <file> \tRead commands from file (default stdin)\n"
|
||||
"\t-1\t\tDo not enter interactive mode\n"
|
||||
"\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n"
|
||||
|
|
@ -486,7 +488,7 @@ usage(clicon_handle h,
|
|||
"\t-p <dir>\tYang directory path (see CLICON_YANG_DIR)\n"
|
||||
"\t-G \t\tPrint auto-cli CLI syntax generated from YANG\n"
|
||||
"\t-L \t\tDebug print dynamic CLI syntax including completions and expansions\n"
|
||||
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (stderr is default)\n"
|
||||
|
||||
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
|
||||
"\t-c <file>\tSpecify cli spec file.\n"
|
||||
"\t-U <user>\tOver-ride unix user with a pseudo user for NACM.\n"
|
||||
|
|
@ -522,9 +524,12 @@ main(int argc,
|
|||
size_t cligen_bufthreshold;
|
||||
int dbg=0;
|
||||
int nr;
|
||||
int config_dump;
|
||||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
|
||||
/* Defaults */
|
||||
once = 0;
|
||||
config_dump = 0;
|
||||
|
||||
/* In the startup, logs to stderr & debug flag set later */
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
|
||||
|
|
@ -607,6 +612,15 @@ main(int argc,
|
|||
case 'E': /* extra config dir */
|
||||
case 'l': /* Log destination */
|
||||
break; /* see above */
|
||||
case 'C': /* Explicitly dump configuration */
|
||||
if (!strlen(optarg))
|
||||
usage(h, argv[0]);
|
||||
if ((config_dump_format = format_str2int(optarg)) < 0){
|
||||
fprintf(stderr, "Unrecognized dump format: %s(expected: xml|json|text)\n", argv[0]);
|
||||
usage(h, argv[0]);
|
||||
}
|
||||
config_dump++;
|
||||
break;
|
||||
case 'F': /* read commands from file */
|
||||
if (freopen(optarg, "r", stdin) == NULL){
|
||||
fprintf(stderr, "freopen: %s\n", strerror(errno));
|
||||
|
|
@ -833,10 +847,6 @@ main(int argc,
|
|||
if (logclisyntax)
|
||||
cli_logsyntax_set(h, logclisyntax);
|
||||
|
||||
clicon_option_dump(h, 1);
|
||||
|
||||
|
||||
|
||||
/* Clixon hardcodes variable tie-breaks to non-terminals (2)
|
||||
* There are cases in the autocli such as:
|
||||
* (<string regexp:"r1" | <string regexp:"r2"){ ... }
|
||||
|
|
@ -850,6 +860,15 @@ main(int argc,
|
|||
*/
|
||||
if (clixon_plugin_start_all(h) < 0)
|
||||
goto done;
|
||||
/* Explicit dump of config
|
||||
* (there is also debug dump below).
|
||||
*/
|
||||
if (config_dump){
|
||||
if (clicon_option_dump1(h, stdout, config_dump_format) < 0)
|
||||
goto done;
|
||||
}
|
||||
/* Debug dump of config options */
|
||||
clicon_option_dump(h, 1);
|
||||
|
||||
cligen_line_scrolling_set(cli_cligen(h), clicon_option_int(h,"CLICON_CLI_LINESCROLLING"));
|
||||
/*! Start CLI history and load from file */
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
#include "netconf_rpc.h"
|
||||
|
||||
/* Command line options to be passed to getopt(3) */
|
||||
#define NETCONF_OPTS "hD:f:E:l:q01ca:u:d:p:y:U:t:eo:"
|
||||
#define NETCONF_OPTS "hD:f:E:l:C:q01ca:u:d:p:y:U:t:eo:"
|
||||
|
||||
#define NETCONF_LOGFILE "/tmp/clixon_netconf.log"
|
||||
|
||||
|
|
@ -624,6 +624,7 @@ usage(clicon_handle h,
|
|||
"\t-f <file>\tConfiguration file (mandatory)\n"
|
||||
"\t-E <dir> \tExtra configuration file directory\n"
|
||||
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
|
||||
"\t-C <format>\tDump configuration options on stdout after loading and exit. Format is xml|json|text\n"
|
||||
"\t-q\t\tServer does not send hello message on startup\n"
|
||||
"\t-0 \t\tSet netconf base capability to 0, server does not expect hello, force EOM framing\n"
|
||||
"\t-1 \t\tSet netconf base capability to 1, server does not expect hello, force chunked framing\n"
|
||||
|
|
@ -663,6 +664,8 @@ main(int argc,
|
|||
size_t cligen_bufthreshold;
|
||||
int dbg = 0;
|
||||
size_t sz;
|
||||
int config_dump = 0;
|
||||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
|
||||
/* Create handle */
|
||||
if ((h = clicon_handle_init()) == NULL)
|
||||
|
|
@ -728,6 +731,15 @@ main(int argc,
|
|||
case 'E': /* extra config dir */
|
||||
case 'l': /* log */
|
||||
break; /* see above */
|
||||
case 'C': /* Explicitly dump configuration */
|
||||
if (!strlen(optarg))
|
||||
usage(h, argv[0]);
|
||||
if ((config_dump_format = format_str2int(optarg)) < 0){
|
||||
fprintf(stderr, "Unrecognized dump format: %s(expected: xml|json|text)\n", argv[0]);
|
||||
usage(h, argv[0]);
|
||||
}
|
||||
config_dump++;
|
||||
break;
|
||||
case 'q': /* quiet: dont write hello */
|
||||
quiet++;
|
||||
break;
|
||||
|
|
@ -867,6 +879,15 @@ main(int argc,
|
|||
if (clixon_plugin_start_all(h) < 0)
|
||||
goto done;
|
||||
|
||||
/* Explicit dump of config (also debug dump below). */
|
||||
if (config_dump){
|
||||
if (clicon_option_dump1(h, stdout, config_dump_format) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
/* Debug dump of config options */
|
||||
clicon_option_dump(h, 1);
|
||||
|
||||
/* Send hello request to backend to get session-id back
|
||||
* This is done once at the beginning of the session and then this is
|
||||
* used by the client, even though new TCP sessions are created for
|
||||
|
|
@ -890,7 +911,6 @@ main(int argc,
|
|||
#endif
|
||||
if (clixon_event_reg_fd(0, netconf_input_cb, h, "netconf socket") < 0)
|
||||
goto done;
|
||||
clicon_option_dump(h, 1);
|
||||
if (tv.tv_sec || tv.tv_usec){
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
|
|
@ -900,6 +920,7 @@ main(int argc,
|
|||
}
|
||||
if (clixon_event_loop(h) < 0)
|
||||
goto done;
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
if (ignore_packet_errors)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@
|
|||
#include "restconf_stream.h"
|
||||
|
||||
/* Command line options to be passed to getopt(3) */
|
||||
#define RESTCONF_OPTS "hD:f:E:l:p:d:y:a:u:rW:R:o:"
|
||||
#define RESTCONF_OPTS "hD:f:E:l:C:p:d:y:a:u:rW:R:o:"
|
||||
|
||||
/*! Convert FCGI parameters to clixon runtime data
|
||||
* @param[in] h Clixon handle
|
||||
|
|
@ -269,6 +269,7 @@ usage(clicon_handle h,
|
|||
"\t-f <file>\t Configuration file (mandatory)\n"
|
||||
"\t-E <dir> \t Extra configuration file directory\n"
|
||||
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
|
||||
"\t-C <format>\tDump configuration options on stdout after loading. Format is xml|json|text\n"
|
||||
"\t-p <dir>\t Yang directory path (see CLICON_YANG_DIR)\n"
|
||||
"\t-y <file>\t Load yang spec file (override yang main module)\n"
|
||||
"\t-a UNIX|IPv4|IPv6 Internal backend socket family\n"
|
||||
|
|
@ -283,8 +284,7 @@ usage(clicon_handle h,
|
|||
exit(0);
|
||||
}
|
||||
|
||||
/*! Main routine for fastcgi restconf
|
||||
*/
|
||||
/*! Main routine for fastcgi restconf */
|
||||
int
|
||||
main(int argc,
|
||||
char **argv)
|
||||
|
|
@ -314,6 +314,8 @@ main(int argc,
|
|||
char *wwwuser;
|
||||
char *inline_config = NULL;
|
||||
size_t sz;
|
||||
int config_dump;
|
||||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
|
||||
/* In the startup, logs to stderr & debug flag set later */
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
|
||||
|
|
@ -389,6 +391,15 @@ main(int argc,
|
|||
case 'E': /* extra config dir */
|
||||
case 'l': /* log */
|
||||
break; /* taken care of in earlier getopt above */
|
||||
case 'C': /* Explicitly dump configuration */
|
||||
if (!strlen(optarg))
|
||||
usage(h, argv[0]);
|
||||
if ((config_dump_format = format_str2int(optarg)) < 0){
|
||||
fprintf(stderr, "Unrecognized dump format: %s(expected: xml|json|text)\n", argv[0]);
|
||||
usage(h, argv[0]);
|
||||
}
|
||||
config_dump++;
|
||||
break;
|
||||
case 'p' : /* yang dir path */
|
||||
if (clicon_option_add(h, "CLICON_YANG_DIR", optarg) < 0)
|
||||
goto done;
|
||||
|
|
@ -528,6 +539,12 @@ main(int argc,
|
|||
if (clicon_nsctx_global_set(h, nsctx_global) < 0)
|
||||
goto done;
|
||||
|
||||
/* Explicit dump of config (also debug dump below). */
|
||||
if (config_dump){
|
||||
if (clicon_option_dump1(h, stdout, config_dump_format) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
/* Dump configuration options on debug */
|
||||
clicon_option_dump(h, 1);
|
||||
|
||||
|
|
@ -664,6 +681,7 @@ main(int argc,
|
|||
}
|
||||
}
|
||||
} /* while */
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
stream_child_freeall(h);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@
|
|||
#endif
|
||||
|
||||
/* Command line options to be passed to getopt(3) */
|
||||
#define RESTCONF_OPTS "hD:f:E:l:p:y:a:u:rW:R:o:"
|
||||
#define RESTCONF_OPTS "hD:f:E:l:C:p:y:a:u:rW:R:o:"
|
||||
|
||||
/* If set, open outwards socket non-blocking, as opposed to blocking
|
||||
* Should work both ways, but in the ninblocking case,
|
||||
|
|
@ -1116,6 +1116,7 @@ usage(clicon_handle h,
|
|||
"\t-f <file>\t Configuration file (mandatory)\n"
|
||||
"\t-E <dir> \t Extra configuration file directory\n"
|
||||
"\t-l <s|e|o|n|f<file>> \tLog on (s)yslog, std(e)rr, std(o)ut, (n)one or (f)ile (syslog is default)\n"
|
||||
"\t-C <format>\tDump configuration options on stdout after loading and exit. Format is xml|json|text\n"
|
||||
"\t-p <dir>\t Yang directory path (see CLICON_YANG_DIR)\n"
|
||||
"\t-y <file>\t Load yang spec file (override yang main module)\n"
|
||||
"\t-a UNIX|IPv4|IPv6 Internal backend socket family\n"
|
||||
|
|
@ -1130,6 +1131,8 @@ usage(clicon_handle h,
|
|||
exit(0);
|
||||
}
|
||||
|
||||
/* Clixon native restconf application main entry point
|
||||
*/
|
||||
int
|
||||
main(int argc,
|
||||
char **argv)
|
||||
|
|
@ -1144,6 +1147,8 @@ main(int argc,
|
|||
int ret;
|
||||
cxobj *xrestconf = NULL;
|
||||
char *inline_config = NULL;
|
||||
int config_dump = 0;
|
||||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
|
||||
/* In the startup, logs to stderr & debug flag set later */
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
|
||||
|
|
@ -1235,6 +1240,15 @@ main(int argc,
|
|||
case 'E': /* extra config dir */
|
||||
case 'l': /* log */
|
||||
break; /* see above */
|
||||
case 'C': /* Explicitly dump configuration */
|
||||
if (!strlen(optarg))
|
||||
usage(h, argv[0]);
|
||||
if ((config_dump_format = format_str2int(optarg)) < 0){
|
||||
fprintf(stderr, "Unrecognized dump format: %s(expected: xml|json|text)\n", argv[0]);
|
||||
usage(h, argv[0]);
|
||||
}
|
||||
config_dump++;
|
||||
break;
|
||||
case 'p' : /* yang dir path */
|
||||
if (clicon_option_add(h, "CLICON_YANG_DIR", optarg) < 0)
|
||||
goto done;
|
||||
|
|
@ -1283,6 +1297,12 @@ main(int argc,
|
|||
/* Init restconf auth-type */
|
||||
restconf_auth_type_set(h, CLIXON_AUTH_NONE);
|
||||
|
||||
/* Explicit dump of config (also debug dump below). */
|
||||
if (config_dump){
|
||||
if (clicon_option_dump1(h, stdout, config_dump_format) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
/* Dump configuration options on debug */
|
||||
clicon_option_dump(h, 1);
|
||||
|
||||
|
|
@ -1326,6 +1346,7 @@ main(int argc,
|
|||
/* Main event loop */
|
||||
if (clixon_event_loop(h) < 0)
|
||||
goto done;
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
clicon_debug(1, "restconf_main_openssl done");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue