Refactor of cli show commands:
- Changed `cli_show_config()` - Removed `cli_show_config_state()` - Replaced `cli_auto_show()` with `cli_show_auto_mode()`
This commit is contained in:
parent
9a224ea4a0
commit
a6f67755b3
32 changed files with 706 additions and 746 deletions
27
CHANGELOG.md
27
CHANGELOG.md
|
|
@ -70,10 +70,31 @@ Users may have to change how they access the system
|
|||
|
||||
Developers may need to change their code
|
||||
|
||||
* CLISPEC change: Changed signature of `cli_show_auto()` and `cli_show_auto_state()`
|
||||
* CLISPEC changes of cli show functions
|
||||
* For details of updated API, see https://clixon-docs.readthedocs.io/en/latest/cli.html#show-commands
|
||||
* Changed `cli_show_auto()`
|
||||
* Added parameters for pretty-print, state and with-default
|
||||
* As developer, you only need to replace the old functions if you have the cli prefix parameter set:
|
||||
* `cli_show_auto(<db>, <format>, <prefix>)` -> `cli_show_auto(<db>, <format>, true, false, "report-all", <prefix>)`
|
||||
* If you have the <prefix> parameter, you need to change the call as follows:
|
||||
* `cli_show_auto(<db>, <format>, <prefix>)` -> `cli_show_auto(<db>, <format>, true, false, NULL, <prefix>)`
|
||||
* Otherwise it is backward-compatible
|
||||
* Changed `cli_show_config()`
|
||||
* Added parameters for pretty-print, state and with-default
|
||||
* If you have the <prefix> parameter, you need to change the call as follows:
|
||||
* `cli_show_config(<db>, <format>, <xpath>, <ns>, <prefix>)` -> `cli_show_auto(<db>, <format>, <xpath>, <ns>, true, false, NULL, <prefix>)`
|
||||
* Otherwise it is backward-compatible
|
||||
* Removed `cli_show_auto_state()`, replace with `cli_show_auto` with state set to `true`
|
||||
* Removed `cli_show_config_state()`, replace with `cli_auto_show` with state set to `tru
|
||||
e`
|
||||
* Replaced `cli_auto_show()` with `cli_show_auto_mode()`
|
||||
* The first argument is removed. You need to change all calls as follows:
|
||||
* `cli_show_config(<treename>, <db>, ...` -> `cli_show_auto_menu(<db>, ...)`
|
||||
* The `cli_auto_show()` callback remains in 5.9.0 for backward compatible reasons, but will be removed in later releaes.
|
||||
|
||||
### Minor features
|
||||
|
||||
* Restconf:
|
||||
* Openssl 3.0 is supported
|
||||
* Refactoring of the closing of SSL sockets. Some cornercase bugs have been removed.
|
||||
|
||||
### Corrected Bugs
|
||||
|
||||
|
|
|
|||
|
|
@ -337,201 +337,6 @@ cli_auto_top(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! CLI callback: Working point tree show
|
||||
* @param[in] h CLICON handle
|
||||
* @param[in] cvv Vector of variables from CLIgen command-line
|
||||
* @param[in] argv Vector of user-supplied keywords
|
||||
* Format of argv:
|
||||
* <treename> Name of generated cligen parse-tree, eg "datamodel"
|
||||
* <dbname> "running"|"candidate"|"startup"
|
||||
* <format> "text"|"xml"|"json"|"cli"|"netconf" (see format_enum)
|
||||
* <pretty> true|false: pretty-print or not
|
||||
* <state> true|false: also print state
|
||||
* <default> Retrieval default mode: report-all, trim, explicit, report-all-tagged,
|
||||
* report-all-tagged-default, report-all-tagged-strip
|
||||
* <prefix> CLI prefix: to print before cli syntax output
|
||||
* @see cli_show_auto
|
||||
* @note default mods accorsing to RFC6243 + two extra modes based on report-all-tagged:
|
||||
* report-all-tagged-default Strip "default" attribute (=report-all xxx)
|
||||
* report-all-tagged-strip Strip "default" attribute and all nodes tagged with it (=trim)
|
||||
* XXX Merge with cli_show_auto
|
||||
*/
|
||||
int
|
||||
cli_auto_show(clicon_handle h,
|
||||
cvec *cvv,
|
||||
cvec *argv)
|
||||
{
|
||||
int retval = -1;
|
||||
char *treename;
|
||||
char *db;
|
||||
char *api_path = NULL;
|
||||
char *formatstr;
|
||||
enum format_enum format;
|
||||
pt_head *ph;
|
||||
char *xpath = NULL;
|
||||
cxobj *xp;
|
||||
cvec *nsc = NULL;
|
||||
yang_stmt *yspec;
|
||||
cxobj *xerr;
|
||||
cxobj *xt = NULL;
|
||||
cxobj **vec = NULL;
|
||||
size_t veclen;
|
||||
int i;
|
||||
int skiproot;
|
||||
int pretty;
|
||||
char *prefix = NULL;
|
||||
int state;
|
||||
cg_var *boolcv = NULL;
|
||||
char *defaultstr = NULL; /* with extended tagged modes */
|
||||
char *withdefaultstr = NULL; /* RFC 6243 modes */
|
||||
|
||||
if (cvec_len(argv) < 5 || cvec_len(argv) > 7){
|
||||
clicon_err(OE_PLUGIN, EINVAL, "Usage: <treename> <database> <format> <pretty> <state> [<default> <cli-prefix>].");
|
||||
goto done;
|
||||
}
|
||||
/* First argv argument: treename */
|
||||
treename = cv_string_get(cvec_i(argv, 0));
|
||||
/* Second argv argument: Database */
|
||||
db = cv_string_get(cvec_i(argv, 1));
|
||||
/* Third format: output format */
|
||||
formatstr = cv_string_get(cvec_i(argv, 2));
|
||||
if ((int)(format = format_str2int(formatstr)) < 0){
|
||||
clicon_err(OE_PLUGIN, 0, "Not valid format: %s", formatstr);
|
||||
goto done;
|
||||
}
|
||||
/* Fourth: pretty-print */
|
||||
if ((boolcv = cv_new(CGV_BOOL)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cv_new");
|
||||
goto done;
|
||||
}
|
||||
if (cv_parse(cv_string_get(cvec_i(argv, 3)), boolcv) < 0){
|
||||
clicon_err(OE_UNIX, errno, "Parse boolean %s", cv_string_get(cvec_i(argv, 3)));
|
||||
goto done;
|
||||
}
|
||||
pretty = cv_bool_get(boolcv);
|
||||
/* Fifth: state */
|
||||
if (cv_parse(cv_string_get(cvec_i(argv, 4)), boolcv) < 0){
|
||||
clicon_err(OE_UNIX, errno, "Parse boolean %s", cv_string_get(cvec_i(argv, 4)));
|
||||
goto done;
|
||||
}
|
||||
state = cv_bool_get(boolcv);
|
||||
/* Sixth: default */
|
||||
if (cvec_len(argv) > 5) {
|
||||
defaultstr = cv_string_get(cvec_i(argv, 5));
|
||||
/* From extended to RFC6243 withdefault modes */
|
||||
if (strcmp(defaultstr, "report-all-tagged-strip") == 0)
|
||||
withdefaultstr = "report-all-tagged";
|
||||
else if (strcmp(defaultstr, "report-all-tagged-default") == 0)
|
||||
withdefaultstr = "report-all-tagged";
|
||||
else if (strcmp(defaultstr, "report-all") != 0 &&
|
||||
strcmp(defaultstr, "trim") != 0 &&
|
||||
strcmp(defaultstr, "explicit") != 0 &&
|
||||
strcmp(defaultstr, "report-all-tagged") != 0){
|
||||
clicon_err(OE_YANG, EINVAL, "Unexpected with-default option: %s", defaultstr);
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
withdefaultstr = defaultstr;
|
||||
}
|
||||
/* Seventh: cli prefix */
|
||||
if (cvec_len(argv) > 6) {
|
||||
prefix = cv_string_get(cvec_i(argv, 6));
|
||||
}
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_FATAL, 0, "No DB_SPEC");
|
||||
goto done;
|
||||
}
|
||||
if ((ph = cligen_ph_find(cli_cligen(h), treename)) == NULL){ /* XXX not used */
|
||||
clicon_err(OE_PLUGIN, 0, "No such parsetree header: %s", treename);
|
||||
goto done;
|
||||
}
|
||||
/* Store this as edit-mode */
|
||||
if (clicon_data_get(h, "cli-edit-mode", &api_path) == 0 && strlen(api_path))
|
||||
;
|
||||
else
|
||||
api_path = "/";
|
||||
if (api_path2xpath(api_path, yspec, &xpath, &nsc, NULL) < 0)
|
||||
goto done;
|
||||
skiproot = (xpath != NULL) && (strcmp(xpath,"/") != 0);
|
||||
if (state && strcmp(db, "running") != 0){
|
||||
clicon_err(OE_FATAL, 0, "Show state only for running database, not %s", db);
|
||||
goto done;
|
||||
}
|
||||
if (state == 0){ /* Get configuration-only from a database */
|
||||
if (clicon_rpc_get_config(h, NULL, db, xpath, nsc, withdefaultstr, &xt) < 0)
|
||||
goto done;
|
||||
}
|
||||
else { /* Get configuration and state from running */
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, withdefaultstr, &xt) < 0)
|
||||
goto done;
|
||||
}
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
/* Special tagged modes: strip wd:default=true attribute and (optionally) nodes associated with it */
|
||||
if (defaultstr &&
|
||||
(strcmp(defaultstr, "report-all-tagged-strip") == 0 ||
|
||||
strcmp(defaultstr, "report-all-tagged-default") == 0)){
|
||||
if (purge_tagged_nodes(xt, IETF_NETCONF_WITH_DEFAULTS_ATTR_NAMESPACE, "default", "true",
|
||||
strcmp(defaultstr, "report-all-tagged-strip")
|
||||
) < 0)
|
||||
goto done;
|
||||
/* Remove empty containers */
|
||||
if (xml_defaults_nopresence(xt, 2) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (xpath_vec(xt, nsc, "%s", &vec, &veclen, xpath) < 0)
|
||||
goto done;
|
||||
|
||||
for (i=0; i<veclen; i++){
|
||||
xp = vec[i];
|
||||
/* Print configuration according to format */
|
||||
switch (format){
|
||||
case FORMAT_XML:
|
||||
if (clixon_xml2file(stdout, xp, 0, pretty, cligen_output, skiproot, 1) < 0)
|
||||
goto done;
|
||||
fprintf(stdout, "\n");
|
||||
break;
|
||||
case FORMAT_JSON:
|
||||
if (clixon_json2file(stdout, xp, pretty, cligen_output, skiproot, 1) < 0)
|
||||
goto done;
|
||||
fprintf(stdout, "\n");
|
||||
break;
|
||||
case FORMAT_TEXT:
|
||||
if (clixon_txt2file(stdout, xp, 0, cligen_output, skiproot, 1) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case FORMAT_CLI:
|
||||
if (clixon_cli2file(h, stdout, xp, prefix, cligen_output, skiproot) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case FORMAT_NETCONF:
|
||||
cligen_output(stdout, "<rpc xmlns=\"%s\" %s><edit-config><target><candidate/></target><config>",
|
||||
NETCONF_BASE_NAMESPACE, NETCONF_MESSAGE_ID_ATTR);
|
||||
if (pretty)
|
||||
cligen_output(stdout, "\n");
|
||||
if (clixon_xml2file(stdout, xp, 2, pretty, cligen_output, skiproot, 1) < 0)
|
||||
goto done;
|
||||
cligen_output(stdout, "</config></edit-config></rpc>]]>]]>\n");
|
||||
break;
|
||||
} /* switch */
|
||||
}
|
||||
retval = 0;
|
||||
done:
|
||||
if (boolcv)
|
||||
cv_free(boolcv);
|
||||
if (xt)
|
||||
xml_free(xt);
|
||||
if (nsc)
|
||||
xml_nsctx_free(nsc);
|
||||
if (vec)
|
||||
free(vec);
|
||||
if (xpath)
|
||||
free(xpath);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*! CLI callback: set auto db item
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] cvv Vector of cli string and instantiated variables
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -148,8 +148,6 @@ int cli_show_config_state(clicon_handle h, cvec *cvv, cvec *argv);
|
|||
|
||||
int cli_show_auto(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
|
||||
int cli_show_auto_state(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
|
||||
int cli_show_options(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
|
||||
/* cli_auto.c: Autocli mode support */
|
||||
|
|
@ -157,7 +155,10 @@ int cli_show_options(clicon_handle h, cvec *cvv, cvec *argv);
|
|||
int cli_auto_edit(clicon_handle h, cvec *cvv1, cvec *argv);
|
||||
int cli_auto_up(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
int cli_auto_top(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
#if 1 // Obsolete: Use cli_show_auto_mode instead
|
||||
int cli_auto_show(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
#endif
|
||||
int cli_show_auto_mode(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
int cli_auto_set(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
int cli_auto_merge(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
int cli_auto_create(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
|
|
|
|||
|
|
@ -90,32 +90,32 @@ show("Show a particular state of the system"){
|
|||
text, cli_pagination("use xpath var", "es", "http://example.com/ns/example-social", "text", "10");
|
||||
json, cli_pagination("use xpath var", "es", "http://example.com/ns/example-social", "json", "10");
|
||||
}
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", true, false);{
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false);{
|
||||
default("With-default mode"){
|
||||
report-all, cli_auto_show("datamodel", "candidate", "xml", true, false, "report-all");
|
||||
trim, cli_auto_show("datamodel", "candidate", "xml", true, false, "trim");
|
||||
explicit, cli_auto_show("datamodel", "candidate", "xml", true, false, "explicit");
|
||||
report-all-tagged, cli_auto_show("datamodel", "candidate", "xml", true, false, "report-all-tagged");
|
||||
report-all-tagged-default, cli_auto_show("datamodel", "candidate", "xml", true, false, "report-all-tagged-default");
|
||||
report-all-tagged-strip, cli_auto_show("datamodel", "candidate", "xml", true, false, "report-all-tagged-strip");
|
||||
report-all, cli_show_auto_mode("candidate", "xml", true, false, "report-all");
|
||||
trim, cli_show_auto_mode("candidate", "xml", true, false, "trim");
|
||||
explicit, cli_show_auto_mode("candidate", "xml", true, false, "explicit");
|
||||
report-all-tagged, cli_show_auto_mode("candidate", "xml", true, false, "report-all-tagged");
|
||||
report-all-tagged-default, cli_show_auto_mode("candidate", "xml", true, false, "report-all-tagged-default");
|
||||
report-all-tagged-strip, cli_show_auto_mode("candidate", "xml", true, false, "report-all-tagged-strip");
|
||||
}
|
||||
}
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", true, false, "explicit", "set ");
|
||||
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", true, false);
|
||||
text("Show configuration as text"), cli_auto_show("datamodel", "candidate", "text", true, false);
|
||||
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", true, false);
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "explicit", "set ");
|
||||
netconf("Show configuration as netconf edit-config operation"), cli_show_auto_mode("candidate", "netconf", true, false);
|
||||
text("Show configuration as text"), cli_show_auto_mode("candidate", "text", true, false);
|
||||
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", true, false);
|
||||
|
||||
}
|
||||
state("Show configuration and state"), cli_auto_show("datamodel", "running", "text", true, true); {
|
||||
xml("Show configuration and state as XML"), cli_auto_show("datamodel", "running", "xml", true, true);{
|
||||
state("Show configuration and state"), cli_show_auto_mode("running", "text", true, true); {
|
||||
xml("Show configuration and state as XML"), cli_show_auto_mode("running", "xml", true, true);{
|
||||
default("With-default mode"){
|
||||
report-all, cli_auto_show("datamodel", "running", "xml", true, true, "report-all");
|
||||
trim, cli_auto_show("datamodel", "running", "xml", true, true, "trim");
|
||||
explicit, cli_auto_show("datamodel", "running", "xml", true, true, "explicit");
|
||||
report-all-tagged, cli_auto_show("datamodel", "running", "xml", true, true, "report-all-tagged");
|
||||
report-all-tagged-default, cli_auto_show("datamodel", "running", "xml", true, true, "report-all-tagged-default");
|
||||
report-all-tagged-strip, cli_auto_show("datamodel", "running", "xml", true, true, "report-all-tagged-strip");
|
||||
report-all, cli_show_auto_mode("running", "xml", true, true, "report-all");
|
||||
trim, cli_show_auto_mode("running", "xml", true, true, "trim");
|
||||
explicit, cli_show_auto_mode("running", "xml", true, true, "explicit");
|
||||
report-all-tagged, cli_show_auto_mode("running", "xml", true, true, "report-all-tagged");
|
||||
report-all-tagged-default, cli_show_auto_mode("running", "xml", true, true, "report-all-tagged-default");
|
||||
report-all-tagged-strip, cli_show_auto_mode("running", "xml", true, true, "report-all-tagged-strip");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,14 +80,14 @@ validate("Validate changes"), cli_validate();
|
|||
commit("Commit the changes"), cli_commit();
|
||||
quit("Quit"), cli_quit();
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "report-all", "set ");
|
||||
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
|
||||
text("Show configuration as text"), cli_auto_show("datamodel", "candidate", "text", false, false);
|
||||
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", false, false, "report-all", "set ");
|
||||
netconf("Show configuration as netconf edit-config operation"), cli_show_auto_mode("candidate", "netconf", false, false);
|
||||
text("Show configuration as text"), cli_show_auto_mode("candidate", "text", false, false);
|
||||
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", false, false);
|
||||
}
|
||||
state("Show configuration and state"), cli_auto_show("datamodel", "running", "xml", false, true);
|
||||
state("Show configuration and state"), cli_show_auto_mode("running", "xml", false, true);
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ delete("Delete a configuration item") {
|
|||
all("Delete whole candidate configuration"), delete_all("candidate");
|
||||
}
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -148,11 +148,13 @@ set @datamodel, cli_set();
|
|||
merge @datamodel, cli_merge();
|
||||
create @datamodel, cli_create();
|
||||
delete @datamodel, cli_del();
|
||||
show config, cli_show_config("candidate", "cli", "/", 0, "set ");
|
||||
show config, cli_show_config("candidate", "cli", "/", NULL, true, false, NULL,"set ");
|
||||
show config @datamodel, cli_show_auto("candidate", "cli", true, false, "report-all", "set ");
|
||||
show state, cli_show_config_state("running", "cli", "/", "set ");
|
||||
show state @datamodelstate, cli_show_auto_state("running", "cli", true, true, "report-all", "set ");
|
||||
show xml, cli_show_config("candidate", "xml", "/");
|
||||
|
||||
show state, cli_show_auto_mode("running", "cli", true, true, NULL, "set ");
|
||||
|
||||
show state @datamodelstate, cli_show_auto("running", "cli", true, true, "report-all", "set ");
|
||||
show xml, cli_show_config("candidate", "xml");
|
||||
show xml @datamodel, cli_show_auto("candidate", "xml");
|
||||
commit, cli_commit();
|
||||
discard, discard_changes();
|
||||
|
|
@ -267,7 +269,6 @@ function testrun()
|
|||
fi
|
||||
|
||||
new "set a"
|
||||
echo "$clixon_cli -1 -f $cfg set$table parameter$name a value x"
|
||||
expectpart "$($clixon_cli -1 -f $cfg set$table parameter$name a value x)" 0 ""
|
||||
|
||||
new "set b"
|
||||
|
|
|
|||
|
|
@ -80,18 +80,18 @@ quit("Quit"), cli_quit();
|
|||
discard("Discard edits (rollback 0)"), discard_changes();
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"){
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", false, false);
|
||||
text("Show configuration as TEXT"), cli_auto_show("datamodel", "candidate", "text", false, false);
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "report-all", "set ");
|
||||
netconf("Show configuration as NETCONF"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", false, false);
|
||||
text("Show configuration as TEXT"), cli_show_auto_mode("candidate", "text", false, false);
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", false, false, NULL, "set ");
|
||||
netconf("Show configuration as NETCONF"), cli_show_auto_mode("candidate", "netconf", false, false);
|
||||
}
|
||||
auto("Show auto") {
|
||||
xml("Show configuration as XML") @datamodelshow, cli_show_auto("candidate", "xml", false, false, "report-all");
|
||||
json("Show configuration as JSON") @datamodelshow, cli_show_auto("candidate", "json", false, false, "report-all");
|
||||
text("Show configuration as TEXT")@datamodelshow, cli_show_auto("candidate", "text", false, false, "report-all");
|
||||
cli("Show configuration as CLI commands") @datamodelshow, cli_show_auto("candidate", "cli", false, false, "report-all", "set ");
|
||||
netconf("Show configuration as NETCONF")@datamodelshow, cli_show_auto("candidate", "netconf", false, false, "report-all");
|
||||
xml("Show configuration as XML") @datamodelshow, cli_show_auto("candidate", "xml", false, false, NULL);
|
||||
json("Show configuration as JSON") @datamodelshow, cli_show_auto("candidate", "json", false, false, NULL);
|
||||
text("Show configuration as TEXT")@datamodelshow, cli_show_auto("candidate", "text", false, false, NULL);
|
||||
cli("Show configuration as CLI commands") @datamodelshow, cli_show_auto("candidate", "cli", false, false, NULL, "set ");
|
||||
netconf("Show configuration as NETCONF")@datamodelshow, cli_show_auto("candidate", "netconf", false, false, NULL);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -79,14 +79,14 @@ validate("Validate changes"), cli_validate();
|
|||
commit("Commit the changes"), cli_commit();
|
||||
quit("Quit"), cli_quit();
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "report-all", "set ");
|
||||
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
|
||||
text("Show configuration as text"), cli_auto_show("datamodel", "candidate", "text", false, false);
|
||||
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", false, false, "report-all", "set ");
|
||||
netconf("Show configuration as netconf edit-config operation"), cli_show_auto_mode("candidate", "netconf", false, false);
|
||||
text("Show configuration as text"), cli_show_auto_mode("candidate", "text", false, false);
|
||||
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", false, false);
|
||||
}
|
||||
state("Show configuration and state"), cli_auto_show("datamodel", "running", "xml", false, true);
|
||||
state("Show configuration and state"), cli_show_auto_mode("running", "xml", false, true);
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ delete("Delete a configuration item") {
|
|||
all("Delete whole candidate configuration"), delete_all("candidate");
|
||||
}
|
||||
show("Show a particular state of the system")
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
EOF
|
||||
|
||||
# Yang specs must be here first for backend. But then the specs are changed but just for CLI
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ delete("Delete a configuration item") {
|
|||
all("Delete whole candidate configuration"), delete_all("candidate");
|
||||
}
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -111,14 +111,14 @@ CLICON_MODE="example";
|
|||
CLICON_PROMPT="%U@%H> ";
|
||||
|
||||
show {
|
||||
base @datamodel, cli_show_auto_state("running", "cli", true, false, "report-all","set ");
|
||||
add-nonconfig @datamodelstate, cli_show_auto_state("running", "cli", true, false, "report-all","set ");
|
||||
add-show @datamodelshow, cli_show_auto_state("running", "cli", true, false, "report-all","set ");
|
||||
base @datamodel, cli_show_auto("running", "cli", true, true, "report-all","set ");
|
||||
add-nonconfig @datamodelstate, cli_show_auto("running", "cli", true, true, "report-all","set ");
|
||||
add-show @datamodelshow, cli_show_auto("running", "cli", true, true, "report-all","set ");
|
||||
}
|
||||
|
||||
auto {
|
||||
set @datamodel, cli_auto_set();
|
||||
show, cli_auto_show("datamodel", "candidate", "text", true, false);
|
||||
show, cli_show_auto_mode("candidate", "text", true, false);
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -200,9 +200,9 @@ quit("Quit"), cli_quit();
|
|||
discard("Discard edits (rollback 0)"), discard_changes();
|
||||
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", true, false, "report-all", "set ");
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", true, false, NULL);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "report-all", "set ");
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false, NULL);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ quit("Quit"), cli_quit();
|
|||
discard("Discard edits (rollback 0)"), discard_changes();
|
||||
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -133,10 +133,10 @@ show("Show a particular state of the system"){
|
|||
xml("Show comparison in xml"), compare_dbs((int32)0);
|
||||
text("Show comparison in text"), compare_dbs((int32)1);
|
||||
}
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", true, false, "report-all", "set ");
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", true, false);
|
||||
text("Show configuration as TEXT"), cli_auto_show("datamodel", "candidate", "text", true, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "report-all", "set ");
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false);
|
||||
text("Show configuration as TEXT"), cli_show_auto_mode("candidate", "text", true, false);
|
||||
}
|
||||
}
|
||||
save("Save candidate configuration to XML file") <filename:string>("Filename (local filename)"), save_config_file("candidate","filename", "xml"){
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ validate("Validate changes"), cli_validate();
|
|||
commit("Commit the changes"), cli_commit();
|
||||
quit("Quit"), cli_quit();
|
||||
show("Show a particular state of the system")
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);
|
||||
@extra;
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ delete("Delete a configuration item") {
|
|||
all("Delete whole candidate configuration"), delete_all("candidate");
|
||||
}
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -166,8 +166,8 @@ delete("Delete a configuration item") {
|
|||
}
|
||||
show("Show a particular state of the system"){
|
||||
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", true, false, "report-all", "set ");
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "report-all", "set ");
|
||||
}
|
||||
}
|
||||
validate("Validate changes"), cli_validate();
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ cat <<EOF > $clidir/cli1.cli
|
|||
( <desc:rest>
|
||||
| <desc:rest expand_dbvar("candidate","/clixon-example:description")> ),
|
||||
cli_set("/clixon-example:description");
|
||||
show configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
show configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
EOF
|
||||
|
||||
new "test params: -f $cfg"
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ CLICON_PLUGIN="example_cli";
|
|||
translate <value:string translate:cli_incstr()>, cli_set("/clixon-example:table/parameter=translate/value");
|
||||
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
}
|
||||
validate("Validate changes"), cli_validate();
|
||||
commit("Commit the changes"), cli_commit();
|
||||
|
|
|
|||
|
|
@ -93,8 +93,8 @@ commit("Commit the changes"), cli_commit();
|
|||
quit("Quit"), cli_quit();
|
||||
show("Show a particular state of the system"){
|
||||
auto("Show expand") @datamodel, cli_show_auto("running", "xml");
|
||||
candidate("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
running("Show configuration"), cli_auto_show("datamodel", "running", "xml", false, false);
|
||||
candidate("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
running("Show configuration"), cli_show_auto_mode("running", "xml", false, false);
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -103,10 +103,10 @@ show("Show a particular state of the system"){
|
|||
xml("Show comparison in xml"), compare_dbs((int32)0);
|
||||
text("Show comparison in text"), compare_dbs((int32)1);
|
||||
}
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", true, false, "report-all", "set ");
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", true, false);
|
||||
text("Show configuration as TEXT"), cli_auto_show("datamodel", "candidate", "text", true, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", true, false, "report-all", "set ");
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false);
|
||||
text("Show configuration as TEXT"), cli_show_auto_mode("candidate", "text", true, false);
|
||||
}
|
||||
}
|
||||
save("Save candidate configuration to XML file") <filename:string>("Filename (local filename)"), save_config_file("candidate","filename", "xml"){
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ save("Save candidate configuration to XML file") <filename:string>("Filename (lo
|
|||
json("Save configuration as JSON"), save_config_file("candidate","filename", "json");
|
||||
}
|
||||
show("Show a particular state of the system")
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
quit("Quit"), cli_quit();
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ validate("Validate changes"), cli_validate();
|
|||
commit("Commit the changes"), cli_commit();
|
||||
quit("Quit"), cli_quit();
|
||||
show("Show a particular state of the system")
|
||||
configuration("Show configuration"), cli_show_config("candidate", "text", "/");
|
||||
configuration("Show configuration"), cli_show_config("candidate", "text");
|
||||
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -70,10 +70,7 @@ new "test params: -y $fyang"
|
|||
|
||||
testrun "top one leaf-list" '{"json:l1":[1]}' '<l1 xmlns="urn:example:clixon">1</l1>'
|
||||
|
||||
# XXX There is a problem with how clixon shows json and xml on top-level
|
||||
# Typically, there is a loop over xml children to cope with the case if there is more
|
||||
# than one top-level which is invalid in XML.
|
||||
# See for example clixon_util_xml.c, clixon_util_json.c, cli_auto_show, cli_show_config
|
||||
|
||||
#testrun "top two leaf-list" '{"json:l1":[1,2]}' '<l1 xmlns="urn:example:clixon">1</l1><l1 xmlns="urn:example:clixon">2</l1>'
|
||||
|
||||
testrun "one leaf-list" '{"json:c":{"l1":[1]}}' '<c xmlns="urn:example:clixon"><l1>1</l1></c>'
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ save("Save candidate configuration to XML file") <filename:string>("Filename (lo
|
|||
cli("Save configuration as CLI commands"), save_config_file("candidate","filename", "cli");
|
||||
}
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
version("Show version"), cli_show_version("candidate", "text", "/");
|
||||
}
|
||||
validate("Validate changes"), cli_validate();
|
||||
|
|
|
|||
|
|
@ -213,14 +213,14 @@ validate("Validate changes"), cli_validate();
|
|||
commit("Commit the changes"), cli_commit();
|
||||
quit("Quit"), cli_quit();
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", true, false);
|
||||
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "report-all", "set ");
|
||||
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
|
||||
text("Show configuration as text"), cli_auto_show("datamodel", "candidate", "text", false, false);
|
||||
json("Show configuration as JSON"), cli_auto_show("datamodel", "candidate", "json", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", true, false);
|
||||
cli("Show configuration as CLI commands"), cli_show_auto_mode("candidate", "cli", false, false, "report-all", "set ");
|
||||
netconf("Show configuration as netconf edit-config operation"), cli_show_auto_mode("candidate", "netconf", false, false);
|
||||
text("Show configuration as text"), cli_show_auto_mode("candidate", "text", false, false);
|
||||
json("Show configuration as JSON"), cli_show_auto_mode("candidate", "json", false, false);
|
||||
}
|
||||
state("Show configuration and state"), cli_auto_show("datamodel", "running", "xml", false, true);
|
||||
state("Show configuration and state"), cli_show_auto_mode("running", "xml", false, true);
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
@ -334,8 +334,8 @@ if [ $t -lt 2 -o $t -gt 4 ]; then
|
|||
fi
|
||||
|
||||
t0=$(date +"%s")
|
||||
new "Send GET and try idle-timeout, client keeps socket open"
|
||||
expectpart "$(${clixon_restconf_callhome_client} -o -t 30 -p 8336 -D $DBG -f $frequest -a 127.0.0.1 -c $srvcert -k $srvkey -C $cacert -n 1)" 0 "HTTP/$HVERCH 200" "OK 1" $expectreply "Close 1 remote" --not-- "OK 2" "Close 2"
|
||||
new "Send GET: idle-timeout, client keeps socket open, server closes"
|
||||
expectpart "$(${clixon_restconf_callhome_client} -o -t 60 -p 8336 -D $DBG -f $frequest -a 127.0.0.1 -c $srvcert -k $srvkey -C $cacert -n 1)" 0 "HTTP/$HVERCH 200" "OK 1" $expectreply "Close 1 remote" --not-- "OK 2" "Close 2"
|
||||
t1=$(date +"%s")
|
||||
|
||||
let t=t1-t0
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ cat <<EOF > $dclispec/clispec.cli
|
|||
set @datamodel, cli_set();
|
||||
merge @datamodel, cli_merge();
|
||||
create @datamodel, cli_create();
|
||||
show, cli_show_config("candidate", "text", "/");
|
||||
show, cli_show_config("candidate", "text");
|
||||
quit("Quit"), cli_quit();
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ set @datamodel, cli_set();
|
|||
commit("Commit the changes"), cli_commit();
|
||||
quit("Quit"), cli_quit();
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_show_config("candidate", "text", "/");
|
||||
configuration("Show configuration"), cli_show_config("candidate", "text");
|
||||
version("Show version"), cli_show_version("candidate", "text", "/");
|
||||
xpath("Show configuration") <xpath:string>("XPATH expression") <ns:string>("Namespace"), show_conf_xpath("candidate");
|
||||
yang("Show yang specs"), show_yang(); {
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ delete("Delete a configuration item") {
|
|||
all("Delete whole candidate configuration"), delete_all("candidate");
|
||||
}
|
||||
show("Show a particular state of the system"){
|
||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||
configuration("Show configuration"), cli_show_auto_mode("candidate", "text", true, false);{
|
||||
xml("Show configuration as XML"), cli_show_auto_mode("candidate", "xml", false, false);
|
||||
}
|
||||
}
|
||||
validate("Validate changes"), cli_validate();
|
||||
|
|
|
|||
|
|
@ -131,22 +131,22 @@ show("Show a particular state of the system"){
|
|||
configuration("Show configuration")
|
||||
xml("Show configuration and state as XML")
|
||||
default("With-default mode"){
|
||||
report-all, cli_auto_show("datamodel", "candidate", "xml", false, false, "report-all");
|
||||
trim, cli_auto_show("datamodel", "candidate", "xml", false, false, "trim");
|
||||
explicit, cli_auto_show("datamodel", "candidate", "xml", false, false, "explicit");
|
||||
report-all-tagged, cli_auto_show("datamodel", "candidate", "xml", false, false, "report-all-tagged");
|
||||
report-all-tagged-default, cli_auto_show("datamodel", "candidate", "xml", false, false, "report-all-tagged-default");
|
||||
report-all-tagged-strip, cli_auto_show("datamodel", "candidate", "xml", false, false, "report-all-tagged-strip");
|
||||
report-all, cli_show_auto_mode("candidate", "xml", false, false, "report-all");
|
||||
trim, cli_show_auto_mode("candidate", "xml", false, false, "trim");
|
||||
explicit, cli_show_auto_mode("candidate", "xml", false, false, "explicit");
|
||||
report-all-tagged, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged");
|
||||
report-all-tagged-default, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged-default");
|
||||
report-all-tagged-strip, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged-strip");
|
||||
}
|
||||
state("Show configuration and state")
|
||||
xml("Show configuration and state as XML")
|
||||
default("With-default mode"){
|
||||
report-all, cli_auto_show("datamodel", "running", "xml", false, true, "report-all");
|
||||
trim, cli_auto_show("datamodel", "running", "xml", false, true, "trim");
|
||||
explicit, cli_auto_show("datamodel", "running", "xml", false, true, "explicit");
|
||||
report-all-tagged, cli_auto_show("datamodel", "running", "xml", false, true, "report-all-tagged");
|
||||
report-all-tagged-default, cli_auto_show("datamodel", "running", "xml", false, true, "report-all-tagged-default");
|
||||
report-all-tagged-strip, cli_auto_show("datamodel", "running", "xml", false, true, "report-all-tagged-strip");
|
||||
report-all, cli_show_auto_mode("running", "xml", false, true, "report-all");
|
||||
trim, cli_show_auto_mode("running", "xml", false, true, "trim");
|
||||
explicit, cli_show_auto_mode("running", "xml", false, true, "explicit");
|
||||
report-all-tagged, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged");
|
||||
report-all-tagged-default, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged-default");
|
||||
report-all-tagged-strip, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged-strip");
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue