diff --git a/CHANGELOG.md b/CHANGELOG.md index 6296c455..128b63bb 100644 --- a/CHANGELOG.md +++ b/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()` - * 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(, , )` -> `cli_show_auto(, , true, false, "report-all", )` +* 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 + * If you have the parameter, you need to change the call as follows: + * `cli_show_auto(, , )` -> `cli_show_auto(, , true, false, NULL, )` + * Otherwise it is backward-compatible + * Changed `cli_show_config()` + * Added parameters for pretty-print, state and with-default + * If you have the parameter, you need to change the call as follows: + * `cli_show_config(, , , , )` -> `cli_show_auto(, , , , true, false, NULL, )` + * 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(, , ...` -> `cli_show_auto_menu(, ...)` + * 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 diff --git a/apps/cli/cli_auto.c b/apps/cli/cli_auto.c index a3f0f5d8..7502ec34 100644 --- a/apps/cli/cli_auto.c +++ b/apps/cli/cli_auto.c @@ -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: - * Name of generated cligen parse-tree, eg "datamodel" - * "running"|"candidate"|"startup" - * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum) - * true|false: pretty-print or not - * true|false: also print state - * Retrieval default mode: report-all, trim, explicit, report-all-tagged, - * report-all-tagged-default, report-all-tagged-strip - * 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: [ ]."); - 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", - 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, "]]>]]>\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 diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index 8fd305f1..1b0e794f 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -402,412 +402,72 @@ show_yang(clicon_handle h, return 0; } -/*! Show configuration and state internal function +/*! Common internal show routine for several show cli callbacks * - * @param[in] h CLICON handle - * @param[in] state If set, show both config and state, otherwise only config - * @param[in] cvv Vector of variables from CLIgen command-line - * @param[in] argv String vector: [] - * Format of argv: - * "running"|"candidate"|"startup" # note only running state=1 - * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum) - * xpath expression, that may contain one %, eg "/sender[name='foo']" - * If xpath set, the namespace the symbols in xpath belong to (optional) - * to print before cli syntax output (optional) - * @code - * show config id , cli_show_config("running","xml","iface[name='foo']","urn:example:example"); - * @endcode - * @note if state parameter is set, then db must be running - * @see cli_show_auto1 - */ + * @param[in] h Clixon handle + * @param[in] db Datastore + * @param[in] format Output format + * @param[in] pretty + * @param[in] state + * @param[in] withdefault RFC 6243 with-default modes + * @param[in] extdefault with-defaults with propriatary extensions + * @param[in] prefix CLI prefix to prepend cli syntax, eg "set " + * @param[in] xpath XPath + * @param[in] nsc Namespace mapping for xpath + * @param[in] skiproot If set, do not show object itself, only its children + */ static int -cli_show_config1(clicon_handle h, - int state, - cvec *cvv, - cvec *argv) +cli_show_common(clicon_handle h, + char *db, + enum format_enum format, + int pretty, + int state, + char *withdefault, + char *extdefault, + char *prefix, + char *xpath, + cvec *nsc, + int skiproot + ) { - int retval = -1; - char *db; - char *formatstr; - char *xpath; - enum format_enum format; - cbuf *cbxpath = NULL; - char *val = NULL; - cxobj *xt = NULL; - cxobj *xerr; - yang_stmt *yspec; - char *namespace = NULL; - cvec *nsc = NULL; - char *prefix = NULL; + int retval = -1; + cxobj *xt = NULL; + cxobj *xerr; + cxobj **vec = NULL; + size_t veclen; + cxobj *xp; + yang_stmt *yp; + enum rfc_6020 ys_keyword; + int i; - if (cvec_len(argv) < 3 || cvec_len(argv) > 5){ - clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: ,,[,, []]", cvec_len(argv)); - - goto done; - } - if ((yspec = clicon_dbspec_yang(h)) == NULL){ - clicon_err(OE_FATAL, 0, "No DB_SPEC"); - goto done; - } - /* First argv argument: Database */ - db = cv_string_get(cvec_i(argv, 0)); - /* Second argv argument: Format */ - formatstr = cv_string_get(cvec_i(argv, 1)); - if ((int)(format = format_str2int(formatstr)) < 0){ - clicon_err(OE_PLUGIN, 0, "Not valid format: %s", formatstr); - goto done; - } - /* Third argv argument: xpath */ - xpath = cv_string_get(cvec_i(argv, 2)); - - /* Create XPATH variable string */ - if ((cbxpath = cbuf_new()) == NULL){ - clicon_err(OE_PLUGIN, errno, "cbuf_new"); - goto done; - } - cprintf(cbxpath, "%s", xpath); - /* Fourth argument is namespace */ - if (cvec_len(argv) > 3){ - namespace = cv_string_get(cvec_i(argv, 3)); - if ((nsc = xml_nsctx_init(NULL, namespace)) == NULL) - goto done; - } - if (cvec_len(argv) > 4){ - prefix = cv_string_get(cvec_i(argv, 4)); - } - if (state == 0){ /* Get configuration-only from database */ - if (clicon_rpc_get_config(h, NULL, db, cbuf_get(cbxpath), nsc, NULL, &xt) < 0) - goto done; - } - else { /* Get configuration and state from database */ - if (strcmp(db, "running") != 0){ - clicon_err(OE_FATAL, 0, "Show state only for running database, not %s", db); - goto done; - } - if (clicon_rpc_get(h, cbuf_get(cbxpath), nsc, CONTENT_ALL, -1, NULL, &xt) < 0) - goto done; - } - if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){ - clixon_netconf_error(xerr, "Get configuration", NULL); - goto done; - } - /* Print configuration according to format */ - switch (format){ - case FORMAT_XML: - if (clixon_xml2file(stdout, xt, 0, 1, cligen_output, 1, 1) < 0) - goto done; - break; - case FORMAT_JSON: - if (clixon_json2file(stdout, xt, 1, cligen_output, 0, 1) < 0) - goto done; - break; - case FORMAT_TEXT: - if (clixon_txt2file(stdout, xt, 0, cligen_output, 1, 1) < 0) - goto done; - break; - case FORMAT_CLI: - if (clixon_cli2file(h, stdout, xt, prefix, cligen_output, 1) < 0) - goto done; - break; - case FORMAT_NETCONF: - cligen_output(stdout, "\n", - NETCONF_BASE_NAMESPACE, NETCONF_MESSAGE_ID_ATTR); - if (clixon_xml2file(stdout, xt, 2, 1, cligen_output, 1, 1) < 0) - goto done; - cligen_output(stdout, "]]>]]>\n"); - break; - } - retval = 0; -done: - if (nsc) - xml_nsctx_free(nsc); - if (xt) - xml_free(xt); - if (val) - free(val); - if (cbxpath) - cbuf_free(cbxpath); - return retval; -} - -/*! Show configuration and state CLIGEN callback function - * - * @param[in] h CLICON handle - * @param[in] cvv Vector of variables from CLIgen command-line - * @param[in] argv String vector: [] - * Format of argv: - * "running"|"candidate"|"startup" - * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum) - * xpath expression, that may contain one %, eg "/sender[name="%s"]" - * If xpath set, the namespace the symbols in xpath belong to (optional) - * to print before cli syntax output - * @code - * show config id , cli_show_config("running","xml","iface[name='foo']","urn:example:example"); - * @endcode - * @see cli_show_config_state For config and state data (not only config) - */ -int -cli_show_config(clicon_handle h, - cvec *cvv, - cvec *argv) -{ - return cli_show_config1(h, 0, cvv, argv); -} - -/*! Show configuration and state CLIgen callback function - * - * @param[in] h CLICON handle - * @param[in] cvv Vector of variables from CLIgen command-line - * @param[in] argv String vector: [] - * Format of argv: - * "running" - * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum) - * xpath expression, that may contain one %, eg "/sender[name="%s"]" - * optional name of variable in cvv. If set, xpath must have a '%s' - * @code - * show state id , cli_show_config_state("running","xml","iface[name='foo']","urn:example:example"); - * @endcode - * @see cli_show_config For config-only, no state - */ -int -cli_show_config_state(clicon_handle h, - cvec *cvv, - cvec *argv) -{ - return cli_show_config1(h, 1, cvv, argv); -} - -/*! Show configuration as text given an xpath using canonical namespace - * - * Utility function used by cligen spec file - * @param[in] h CLICON handle - * @param[in] cvv Vector of variables from CLIgen command-line must contain xpath and default namespace (if any) - * @param[in] argv A string: - * @note Hardcoded that variable xpath and ns cvv must exist. (kludge) - */ -int -show_conf_xpath(clicon_handle h, - cvec *cvv, - cvec *argv) -{ - int retval = -1; - char *dbname; - char *xpath; - cg_var *cv; - cxobj *xt = NULL; - cxobj *xerr; - cxobj **xv = NULL; - size_t xlen; - int i; - cvec *nsc = NULL; - yang_stmt *yspec; - - if (cvec_len(argv) != 1){ - clicon_err(OE_PLUGIN, EINVAL, "Requires one element to be "); - goto done; - } - if ((yspec = clicon_dbspec_yang(h)) == NULL){ - clicon_err(OE_FATAL, 0, "No DB_SPEC"); - goto done; - } - dbname = cv_string_get(cvec_i(argv, 0)); - /* Dont get attr here, take it from arg instead */ - if (strcmp(dbname, "running") != 0 && - strcmp(dbname, "candidate") != 0 && - strcmp(dbname, "startup") != 0){ - clicon_err(OE_PLUGIN, 0, "No such db name: %s", dbname); - goto done; - } - /* Look for xpath in command (kludge: cv must be called "xpath") */ - if ((cv = cvec_find(cvv, "xpath")) == NULL){ - clicon_err(OE_PLUGIN, EINVAL, "Requires one variable to be "); - goto done; - } - xpath = cv_string_get(cv); - - /* Create canonical namespace */ - if (xml_nsctx_yangspec(yspec, &nsc) < 0) - goto done; - /* Look for and add default namespace variable in command */ - if ((cv = cvec_find(cvv, "ns")) != NULL){ - if (xml_nsctx_add(nsc, NULL, cv_string_get(cv)) < 0) - goto done; - } -#if 0 /* Use state get instead of config (XXX: better use this but test_cli.sh fails) */ - if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, &xt) < 0) - goto done; -#else - if (clicon_rpc_get_config(h, NULL, dbname, xpath, nsc, NULL, &xt) < 0) - goto done; -#endif - if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){ - clixon_netconf_error(xerr, "Get configuration", NULL); - goto done; - } - if (xpath_vec(xt, nsc, "%s", &xv, &xlen, xpath) < 0) - goto done; - for (i=0; i [] - * Format of argv: - * Generated API PATH - * "running"|"candidate"|"startup" - * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum) - * true|false: pretty-print or not (Optional) - * true|false: also print state - * Retrieval default mode: report-all, trim, explicit, report-all-tagged, - * report-all-tagged-default, report-all-tagged-strip (Optional) - * To print before cli syntax outptu - * @note if state parameter is set, then db must be running - * @note that first argument is generated by code. - * @see cli_show_config1 - * XXX Merge with cli_auto_show - */ -static int -cli_show_auto1(clicon_handle h, - int state, - cvec *cvv, - cvec *argv) -{ - int retval = 1; - yang_stmt *yspec; - char *api_path_fmt; /* xml key format */ - char *db; - char *xpath = NULL; - cvec *nsc = NULL; - char *formatstr; - enum format_enum format = FORMAT_XML; - cxobj *xt = NULL; - cxobj *xp; - cxobj *xerr; - char *api_path = NULL; - char *prefix = NULL; - int cvvi = 0; - cg_var *boolcv = NULL; - char *defaultstr = NULL; /* with extended tagged modes */ - char *withdefaultstr = NULL; /* RFC 6243 modes */ - int pretty = 1; - cxobj **vec = NULL; - size_t veclen; - int i; - yang_stmt *yp; - enum rfc_6020 ys_keyword; - - if (cvec_len(argv) < 3 || cvec_len(argv) > 7){ - clicon_err(OE_PLUGIN, EINVAL, "Usage: * [ ]. Number of args:%d", cvec_len(argv)); - goto done; - } - /* First argv argument: API_path format */ - api_path_fmt = 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; - } - if (cvec_len(argv) > 3){ - /* 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); - } - if (cvec_len(argv) > 4){ - 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); - } - 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; - } - if (cvec_len(argv) > 6){ - /* Fourth format: prefix to print before cli syntax */ - 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 (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvvi) < 0) - goto done; - if (api_path2xpath(api_path, yspec, &xpath, &nsc, NULL) < 0) - goto done; - if (xpath == NULL){ - clicon_err(OE_FATAL, 0, "Invalid api-path-fmt: %s", api_path_fmt); - goto done; - } - /* XXX Kludge to overcome a trailing / in show, that I cannot add to - * yang2api_path_fmt_1 where it should belong. - */ - if (xpath && xpath[strlen(xpath)-1] == '/') - xpath[strlen(xpath)-1] = '\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) + if (clicon_rpc_get_config(h, NULL, db, xpath, nsc, withdefault, &xt) < 0) goto done; } else { /* Get configuration and state from running */ - if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, withdefaultstr, &xt) < 0) + if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, withdefault, &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 (extdefault && + (strcmp(extdefault, "report-all-tagged-strip") == 0 || + strcmp(extdefault, "report-all-tagged-default") == 0)){ + if (purge_tagged_nodes(xt, IETF_NETCONF_WITH_DEFAULTS_ATTR_NAMESPACE, "default", "true", + strcmp(extdefault, "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; if (veclen){ @@ -837,21 +497,21 @@ cli_show_auto1(clicon_handle h, /* Print configuration according to format */ switch (format){ case FORMAT_XML: - if (clixon_xml2file(stdout, xp, 0, pretty, cligen_output, 0, 1) < 0) + if (clixon_xml2file(stdout, xp, 0, pretty, cligen_output, skiproot, 1) < 0) goto done; if (!pretty && i == veclen-1) cligen_output(stdout, "\n"); break; case FORMAT_JSON: - if (clixon_json2file(stdout, xp, pretty, cligen_output, 0, 1) < 0) + if (clixon_json2file(stdout, xp, pretty, cligen_output, skiproot, 1) < 0) goto done; break; case FORMAT_TEXT: /* XXX does not handle multiple leaf-list */ - if (clixon_txt2file(stdout, xp, 0, cligen_output, 0, 1) < 0) + 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, 0) < 0) /* cli syntax */ + if (clixon_cli2file(h, stdout, xp, prefix, cligen_output, skiproot) < 0) /* cli syntax */ goto done; break; case FORMAT_NETCONF: @@ -861,74 +521,549 @@ cli_show_auto1(clicon_handle h, if (pretty) cligen_output(stdout, "\n"); } - if (clixon_xml2file(stdout, xp, 2, pretty, cligen_output, 0, 1) < 0) + if (clixon_xml2file(stdout, xp, 2, pretty, cligen_output, skiproot, 1) < 0) goto done; if (i == veclen-1) cligen_output(stdout, "]]>]]>\n"); break; } } - - } retval = 0; - done: - if (boolcv) - cv_free(boolcv); - if (nsc) - xml_nsctx_free(nsc); - if (api_path) - free(api_path); +done: if (vec) free(vec); - if (xpath) - free(xpath); if (xt) xml_free(xt); return retval; } -/*! Generic show configuration CLIgen callback using generated CLI syntax - * Format of argv: - * Generated API PATH - * "running"|"candidate"|"startup" - * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum) - * true|false: pretty-print or not (Optional) - * true|false: also print state - * Retrieval default mode: report-all, trim, explicit, report-all-tagged, - * report-all-tagged-default, report-all-tagged-strip (Optional) - * To print before cli syntax outptu - * @see cli_show_auto_state For config and state - * @note SHOULD be used: ... @datamodel, cli_show_auto(,...) to get correct #args - * @see cli_auto_show - * @see cli_show_config +/*! Common internal parse cli show format option + * + * @param[in] argv String vector: [] + * @param[in] argc Index into argv + * @param[out] format Output format + * @retval 0 OK + * @retval -1 Error + */ +static int +cli_show_option_format(cvec *argv, + int argc, + enum format_enum *format) +{ + int retval = -1; + char *formatstr; + + formatstr = cv_string_get(cvec_i(argv, argc)); + if ((int)(*format = format_str2int(formatstr)) < 0){ + clicon_err(OE_PLUGIN, 0, "Not valid format: %s", formatstr); + goto done; + } + retval = 0; + done: + return retval; +} + +/*! Common internal parse cli show boolean option + * + * @param[in] argv String vector: [] + * @param[in] argc Index into argv + * @param[out] bool result boolean: 0 or 1 + * @retval 0 OK + * @retval -1 Error + */ +static int +cli_show_option_bool(cvec *argv, + int argc, + int *bool + ) +{ + int retval = -1; + char *boolstr; + cg_var *boolcv = NULL; + + boolstr = cv_string_get(cvec_i(argv, argc)); + if ((boolcv = cv_new(CGV_BOOL)) == NULL){ + clicon_err(OE_UNIX, errno, "cv_new"); + goto done; + } + if (cv_parse(boolstr, boolcv) < 0){ + clicon_err(OE_UNIX, errno, "Parse boolean %s", boolstr); + goto done; + } + *bool = cv_bool_get(boolcv); + retval = 0; + done: + if (boolcv) + cv_free(boolcv); + return retval; +} + +/*! Common internal parse cli show with-default option + * + * Ddefault modes accorsing to RFC6243 + three extra modes based on report-all-tagged: + * 1) NULL + * 2) report-all-tagged-default Strip "default" attribute (=report-all) + * 3) report-all-tagged-strip Strip "default" attribute and all nodes tagged with it (=trim) + * @param[in] argv String vector: [] + * @param[in] argc Index into argv + * @param[in] withdefault RFC 6243 with-default modes + * @param[in] extdefault with-defaults with propriatary extensions + * @retval 0 OK + * @retval -1 Error + */ +static int +cli_show_option_withdefault(cvec *argv, + int argc, + char **withdefault, + char **extdefault) +{ + int retval = -1; + char *e; + + e = cv_string_get(cvec_i(argv, argc)); + /* From extended to RFC6243 withdefault modes */ + if (strcmp(e, "report-all-tagged-strip") == 0) + *withdefault = "report-all-tagged"; + else if (strcmp(e, "report-all-tagged-default") == 0) + *withdefault = "report-all-tagged"; + else if (strcmp(e, "NULL") == 0){ + e = NULL; + *withdefault = NULL; + } + else if (strcmp(e, "report-all") != 0 && + strcmp(e, "trim") != 0 && + strcmp(e, "explicit") != 0 && + strcmp(e, "report-all-tagged") != 0){ + clicon_err(OE_YANG, EINVAL, "Unexpected with-default option: %s", e); + goto done; + } + else + *withdefault = e; + *extdefault = e; + retval = 0; + done: + return retval; +} + +/*! Generic show configuration callback + * + * Does not need to be used with the autocli as cli_show_auto does + * @param[in] h CLICON handle + * @param[in] cvv Vector of variables from CLIgen command-line + * @param[in] argv String vector of show options, format: + * Name of datastore, such as "running" + * -- from here optional: + * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum), default: xml + * xpath expression, that may contain one %, eg "/sender[name='foo']" + * xpath default namespace (or NULL) not needed for xpath=NULL + * true|false: pretty-print or not + * true|false: also print state + * Retrieval mode: report-all, trim, explicit, report-all-tagged, + * NULL, report-all-tagged-default, report-all-tagged-strip (extended) + * CLI prefix: prepend before cli syntax output + * @code + * clispec: + * show config, cli_show_config("running","xml"); + * cli run: + * > set table parameter a value x + * > show config + * + * + * a + * x + * + *
+ * @endcode + * @see cli_show_auto autocli with expansion + * @see cli_show_auto_mode autocli with edit menu support + */ +int +cli_show_config(clicon_handle h, + cvec *cvv, + cvec *argv) +{ + int retval = -1; + char *dbname; + enum format_enum format = FORMAT_XML; + cvec *nsc = NULL; + int pretty = 1; + char *prefix = NULL; + int state = 0; + char *withdefault = NULL; /* RFC 6243 modes */ + char *extdefault = NULL; /* with extended tagged modes */ + int argc = 0; + int skiproot = 0; + char *xpath = "/"; + char *namespace = NULL; + + if (cvec_len(argv) < 2 || cvec_len(argv) > 8){ + clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: [ ]", cvec_len(argv)); + goto done; + } + dbname = cv_string_get(cvec_i(argv, argc++)); + if (cvec_len(argv) > argc) + if (cli_show_option_format(argv, argc++, &format) < 0) + goto done; + if (cvec_len(argv) > argc) + xpath = cv_string_get(cvec_i(argv, argc++)); + if (cvec_len(argv) > argc){ + namespace = cv_string_get(cvec_i(argv, argc++)); + /* Special symbol NULL means no namespace */ + if (strcmp(namespace, "NULL") != 0) + if ((nsc = xml_nsctx_init(NULL, namespace)) == NULL) + goto done; + } + if (cvec_len(argv) > argc){ + if (cli_show_option_bool(argv, argc++, &pretty) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + if (cli_show_option_bool(argv, argc++, &state) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + if (cli_show_option_withdefault(argv, argc++, + &withdefault, + &extdefault) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + prefix = cv_string_get(cvec_i(argv, argc++)); + } + if (cli_show_common(h, dbname, format, pretty, state, + withdefault, extdefault, + prefix, xpath, nsc, skiproot) < 0) + goto done; + retval = 0; + done: + if (nsc) + xml_nsctx_free(nsc); + return retval; +} + +/*! Show configuration and state CLIGEN callback function + * + * @param[in] h CLICON handle + * @param[in] cvv Vector of variables from CLIgen command-line + * @param[in] argv String vector of show options, format: + * "running"|"candidate"|"startup" + * @code + * show config id , cli_show_config("running","xml","iface[name='foo']","urn:example:example"); + * @endcode + * @see cli_show_config_state For config and state data (not only config) + */ + +/*! Show configuration as text given an xpath using canonical namespace + * + * Utility function used by cligen spec file + * @param[in] h CLICON handle + * @param[in] cvv Vector of variables from CLIgen command-line must contain xpath and default namespace (if any) + * @param[in] argv A string: + * @note Different from cli_show_conf: values taken cvv "xpath" and "ns" instead of argv + */ +int +show_conf_xpath(clicon_handle h, + cvec *cvv, + cvec *argv) +{ + int retval = -1; + char *dbname; + char *xpath; + cg_var *cv; + cvec *nsc = NULL; + yang_stmt *yspec; + + if (cvec_len(argv) != 1){ + clicon_err(OE_PLUGIN, EINVAL, "Requires one element to be "); + goto done; + } + if ((yspec = clicon_dbspec_yang(h)) == NULL){ + clicon_err(OE_FATAL, 0, "No DB_SPEC"); + goto done; + } + dbname = cv_string_get(cvec_i(argv, 0)); + /* Look for xpath in command (kludge: cv must be called "xpath") */ + if ((cv = cvec_find(cvv, "xpath")) == NULL){ + clicon_err(OE_PLUGIN, EINVAL, "Requires one variable to be "); + goto done; + } + xpath = cv_string_get(cv); + /* Create canonical namespace */ + if (xml_nsctx_yangspec(yspec, &nsc) < 0) + goto done; + /* Look for and add default namespace variable in command */ + if ((cv = cvec_find(cvv, "ns")) != NULL){ + if (xml_nsctx_add(nsc, NULL, cv_string_get(cv)) < 0) + goto done; + } + if (cli_show_common(h, dbname, FORMAT_XML, 1, 0, + NULL, NULL, + NULL, xpath, nsc, 0) < 0) + goto done; + retval = 0; +done: + if (nsc) + xml_nsctx_free(nsc); + return retval; +} + +int cli_show_version(clicon_handle h, + cvec *vars, + cvec *argv) +{ + fprintf(stdout, "%s\n", CLIXON_VERSION_STRING); + return 0; +} + +/*! Show configuration callback using auto CLI syntax with expansion + * + * Can be used only in context of an autocli generated syntax tree, such as: + * show @datamodel, cli_show_auto(); + * This show command can use expansion to "TAB" inside the syntax tree to show + * portions of the syntax. + * @param[in] h Clixon handle + * @param[in] cvv Vector of variables from CLIgen command-line + * @param[in] argv String vector of show options, format: + * Generated API PATH + * Name of datastore, such as "running" + * -- from here optional: + * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum), default: xml + * true|false: pretty-print or not + * true|false: also print state + * Retrieval mode: report-all, trim, explicit, report-all-tagged, + * NULL, report-all-tagged-default, report-all-tagged-strip (extended) + * CLI prefix: prepend before cli syntax output + * @code + * clispec: + * show config @datamodelshow, cli_show_auto("candidate", "xml"); + * cli run: + * > set table parameter a value x + * > show config table parameter a + * + * a + * x + * + * @endcode + * @see cli_show_config with no autocli coupling + * @see cli_show_auto_mode autocli with edit menu support + * + * XXX merge cli_show_auto and cli_show_auto_mode */ int cli_show_auto(clicon_handle h, cvec *cvv, cvec *argv) { - return cli_show_auto1(h, 0, cvv, argv); + int retval = -1; + char *dbname; + enum format_enum format = FORMAT_XML; + cvec *nsc = NULL; + int pretty = 1; + char *prefix = NULL; + int state = 0; + char *withdefault = NULL; /* RFC 6243 modes */ + char *extdefault = NULL; /* with extended tagged modes */ + int argc = 0; + int skiproot = 0; + char *xpath = NULL; + yang_stmt *yspec; + char *api_path = NULL; + int cvvi = 0; + char *api_path_fmt; /* xml key format */ + + if (cvec_len(argv) < 2 || cvec_len(argv) > 7){ + clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected:: * [ ]", cvec_len(argv)); + goto done; + } + api_path_fmt = cv_string_get(cvec_i(argv, argc++)); + dbname = cv_string_get(cvec_i(argv, argc++)); + if (cvec_len(argv) > argc) + if (cli_show_option_format(argv, argc++, &format) < 0) + goto done; + if (cvec_len(argv) > argc){ + if (cli_show_option_bool(argv, argc++, &pretty) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + if (cli_show_option_bool(argv, argc++, &state) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + if (cli_show_option_withdefault(argv, argc++, + &withdefault, + &extdefault) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + prefix = cv_string_get(cvec_i(argv, argc++)); + } + if ((yspec = clicon_dbspec_yang(h)) == NULL){ + clicon_err(OE_FATAL, 0, "No DB_SPEC"); + goto done; + } + if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvvi) < 0) + goto done; + if (api_path2xpath(api_path, yspec, &xpath, &nsc, NULL) < 0) + goto done; + if (xpath == NULL){ + clicon_err(OE_FATAL, 0, "Invalid api-path-fmt: %s", api_path_fmt); + goto done; + } + if (cli_show_common(h, dbname, format, pretty, state, + withdefault, extdefault, + prefix, xpath, nsc, skiproot) < 0) + goto done; + retval = 0; + done: + if (nsc) + xml_nsctx_free(nsc); + if (xpath) + free(xpath); + if (api_path) + free(api_path); + return retval; } -/*! Generic show config and state CLIgen callback using generated CLI syntax - * Format of argv: - * Generated API PATH - * "running" - * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum) - * true|false: pretty-print or not (Optional) - * Retrieval default mode: report-all, trim, explicit, report-all-tagged, - * report-all-tagged-default, report-all-tagged-strip (Optional) - * to print before cli syntax output - * @see cli_show_auto For config only - * @see cli_show_config_state Not auto-generated +/*! Show configuration callback for autocli edit modes using tree working point + * + * Can be used together with "edit modes". The xpath is derived from + * the current "cli-edit-mode" as described here: + * https://clixon-docs.readthedocs.io/en/latest/cli.html#edit-modes + * @param[in] h Clixon handle + * @param[in] cvv Vector of variables from CLIgen command-line + * @param[in] argv String vector of show options, format: + * Name of datastore, such as "running" + * -- from here optional: + * "text"|"xml"|"json"|"cli"|"netconf" (see format_enum), default: xml + * true|false: pretty-print or not + * true|false: also print state + * Retrieval mode: report-all, trim, explicit, report-all-tagged, + * NULL, report-all-tagged-default, report-all-tagged-strip (extended) + * CLI prefix: prepend before cli syntax output + * @code + * clispec: + * show config, cli_show_auto_mode("candidate"); + * cli run: + * > set table parameter a value x + * > edit table + * > show config + * + * a + * x + * + * @endcode + * @see cli_show_auto autocli with expansion + * @see cli_show_config with no autocli coupling + * + * XXX merge cli_show_auto and cli_show_auto_mode + */ +int +cli_show_auto_mode(clicon_handle h, + cvec *cvv, + cvec *argv) +{ + int retval = -1; + char *dbname; + enum format_enum format = FORMAT_XML; + cvec *nsc = NULL; + int pretty = 1; + char *prefix = NULL; + int state = 0; + char *withdefault = NULL; /* RFC 6243 modes */ + char *extdefault = NULL; /* with extended tagged modes */ + int argc = 0; + int skiproot = 0; + char *xpath = NULL; + yang_stmt *yspec; + char *api_path = NULL; + + if (cvec_len(argv) < 2 || cvec_len(argv) > 7){ + clicon_err(OE_PLUGIN, EINVAL, "Received %d arguments. Expected: [ ]", cvec_len(argv)); + goto done; + } + dbname = cv_string_get(cvec_i(argv, argc++)); + if (cvec_len(argv) > argc) + if (cli_show_option_format(argv, argc++, &format) < 0) + goto done; + if (cvec_len(argv) > argc){ + if (cli_show_option_bool(argv, argc++, &pretty) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + if (cli_show_option_bool(argv, argc++, &state) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + if (cli_show_option_withdefault(argv, argc++, + &withdefault, + &extdefault) < 0) + goto done; + } + if (cvec_len(argv) > argc){ + prefix = cv_string_get(cvec_i(argv, argc++)); + } + /* Store this as edit-mode */ + if (clicon_data_get(h, "cli-edit-mode", &api_path) == 0 && strlen(api_path)) + ; + else + api_path = "/"; + if ((yspec = clicon_dbspec_yang(h)) == NULL){ + clicon_err(OE_FATAL, 0, "No DB_SPEC"); + goto done; + } + if (api_path2xpath(api_path, yspec, &xpath, &nsc, NULL) < 0) + goto done; + if (xpath == NULL){ + clicon_err(OE_FATAL, 0, "Invalid api-path: %s", api_path); + goto done; + } + skiproot = (strcmp(xpath,"/") != 0); + if (cli_show_common(h, dbname, format, pretty, state, + withdefault, extdefault, + prefix, xpath, nsc, skiproot) < 0) + goto done; + retval = 0; + done: + if (nsc) + xml_nsctx_free(nsc); + if (xpath) + free(xpath); + return retval; +} + +/*! Obsolete Show configuration callback for autocli edit modes using tree working point + * + * @note Please use cli_show_auto_mode instead, + * but since that function does not use treename(argv[0]) that must be stripped */ int -cli_show_auto_state(clicon_handle h, - cvec *cvv, - cvec *argv) +cli_auto_show(clicon_handle h, + cvec *cvv, + cvec *argv0) { - return cli_show_auto1(h, 1, cvv, argv); + int retval = -1; + cvec *argv1 = NULL; + cg_var *cv; + + if ((argv1 = cvec_new(0)) == NULL){ + clicon_err(OE_UNIX, errno, "cvec_new"); + goto done; + } + cv = NULL; + while ((cv = cvec_each1(argv0, cv)) != NULL) { + if (cvec_append_var(argv1, cv) == NULL){ + clicon_err(OE_UNIX, errno, "cvec_append_var"); + goto done; + } + } + if (cli_show_auto_mode(h, cvv, argv1) < 0) + goto done; + retval = 0; + done: + if (argv1) + cvec_free(argv1); + return retval; } /*! Show clixon configuration options as loaded diff --git a/apps/cli/clixon_cli_api.h b/apps/cli/clixon_cli_api.h index 553dbb04..7352789d 100644 --- a/apps/cli/clixon_cli_api.h +++ b/apps/cli/clixon_cli_api.h @@ -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); diff --git a/example/main/example_cli.cli b/example/main/example_cli.cli index afcec4de..e06c2c92 100644 --- a/example/main/example_cli.cli +++ b/example/main/example_cli.cli @@ -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"); } } } diff --git a/test/test_autocli_editmode.sh b/test/test_autocli_editmode.sh index 2b3b6042..0d88373f 100755 --- a/test/test_autocli_editmode.sh +++ b/test/test_autocli_editmode.sh @@ -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 diff --git a/test/test_autocli_extension.sh b/test/test_autocli_extension.sh index d6e58e57..86b2e511 100755 --- a/test/test_autocli_extension.sh +++ b/test/test_autocli_extension.sh @@ -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 diff --git a/test/test_autocli_listkey_compress.sh b/test/test_autocli_listkey_compress.sh index ce981d6e..65f2c816 100755 --- a/test/test_autocli_listkey_compress.sh +++ b/test/test_autocli_listkey_compress.sh @@ -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" diff --git a/test/test_autocli_show.sh b/test/test_autocli_show.sh index 79b2fdfe..ea9cd0a4 100755 --- a/test/test_autocli_show.sh +++ b/test/test_autocli_show.sh @@ -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 diff --git a/test/test_autocli_spec.sh b/test/test_autocli_spec.sh index 6284a562..6a1ae8e5 100755 --- a/test/test_autocli_spec.sh +++ b/test/test_autocli_spec.sh @@ -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 diff --git a/test/test_autocli_strict_expand.sh b/test/test_autocli_strict_expand.sh index 307a33fd..4337f566 100755 --- a/test/test_autocli_strict_expand.sh +++ b/test/test_autocli_strict_expand.sh @@ -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 diff --git a/test/test_autocli_sub.sh b/test/test_autocli_sub.sh index 952d0865..2b090828 100755 --- a/test/test_autocli_sub.sh +++ b/test/test_autocli_sub.sh @@ -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 diff --git a/test/test_autocli_treeref.sh b/test/test_autocli_treeref.sh index 761103f9..dc4d1cc2 100755 --- a/test/test_autocli_treeref.sh +++ b/test/test_autocli_treeref.sh @@ -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 diff --git a/test/test_choice.sh b/test/test_choice.sh index 115260e2..040da440 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -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 diff --git a/test/test_choice_recursive.sh b/test/test_choice_recursive.sh index 9cd55ed1..f012ed7b 100755 --- a/test/test_choice_recursive.sh +++ b/test/test_choice_recursive.sh @@ -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 diff --git a/test/test_cli.sh b/test/test_cli.sh index 0b812f98..fd25c37e 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -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 (local filename)"), save_config_file("candidate","filename", "xml"){ diff --git a/test/test_cli_duplicates.sh b/test/test_cli_duplicates.sh index 279532ed..485d542a 100755 --- a/test/test_cli_duplicates.sh +++ b/test/test_cli_duplicates.sh @@ -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 diff --git a/test/test_cli_expand.sh b/test/test_cli_expand.sh index e108d3c7..592ff32a 100755 --- a/test/test_cli_expand.sh +++ b/test/test_cli_expand.sh @@ -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 diff --git a/test/test_cli_leafref.sh b/test/test_cli_leafref.sh index 46a03171..487ef084 100755 --- a/test/test_cli_leafref.sh +++ b/test/test_cli_leafref.sh @@ -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(); diff --git a/test/test_cli_rest.sh b/test/test_cli_rest.sh index f375f569..8cb951a8 100755 --- a/test/test_cli_rest.sh +++ b/test/test_cli_rest.sh @@ -51,7 +51,7 @@ cat < $clidir/cli1.cli ( | ), 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" diff --git a/test/test_cli_translate.sh b/test/test_cli_translate.sh index e95aac3e..b8262023 100755 --- a/test/test_cli_translate.sh +++ b/test/test_cli_translate.sh @@ -62,7 +62,7 @@ CLICON_PLUGIN="example_cli"; translate , 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(); diff --git a/test/test_cli_union.sh b/test/test_cli_union.sh index 8802ed8f..88694abf 100755 --- a/test/test_cli_union.sh +++ b/test/test_cli_union.sh @@ -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 diff --git a/test/test_datastore_format.sh b/test/test_datastore_format.sh index 5d1084f7..2d6dca62 100755 --- a/test/test_datastore_format.sh +++ b/test/test_datastore_format.sh @@ -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 (local filename)"), save_config_file("candidate","filename", "xml"){ diff --git a/test/test_db.sh b/test/test_db.sh index f3335889..c64e0789 100755 --- a/test/test_db.sh +++ b/test/test_db.sh @@ -82,7 +82,7 @@ save("Save candidate configuration to XML file") ("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 diff --git a/test/test_helloworld.sh b/test/test_helloworld.sh index 2aa2ffb2..c635d864 100755 --- a/test/test_helloworld.sh +++ b/test/test_helloworld.sh @@ -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 diff --git a/test/test_json_list.sh b/test/test_json_list.sh index 48d4d38c..f2af66e3 100755 --- a/test/test_json_list.sh +++ b/test/test_json_list.sh @@ -70,10 +70,7 @@ new "test params: -y $fyang" testrun "top one leaf-list" '{"json:l1":[1]}' '1' -# 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]}' '12' testrun "one leaf-list" '{"json:c":{"l1":[1]}}' '1' diff --git a/test/test_openconfig_network_instance.sh b/test/test_openconfig_network_instance.sh index 6f4a7d0f..e09694f4 100755 --- a/test/test_openconfig_network_instance.sh +++ b/test/test_openconfig_network_instance.sh @@ -100,7 +100,7 @@ save("Save candidate configuration to XML file") ("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(); diff --git a/test/test_restconf_callhome.sh b/test/test_restconf_callhome.sh index b99c2710..24d3adf0 100755 --- a/test/test_restconf_callhome.sh +++ b/test/test_restconf_callhome.sh @@ -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 diff --git a/test/test_type_range.sh b/test/test_type_range.sh index d644df48..35a7b3e8 100755 --- a/test/test_type_range.sh +++ b/test/test_type_range.sh @@ -164,7 +164,7 @@ cat < $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 diff --git a/test/test_yang.sh b/test/test_yang.sh index 192fae1f..6116be9a 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -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 expression") ("Namespace"), show_conf_xpath("candidate"); yang("Show yang specs"), show_yang(); { diff --git a/test/test_yang_when.sh b/test/test_yang_when.sh index 9c528f85..69f02260 100755 --- a/test/test_yang_when.sh +++ b/test/test_yang_when.sh @@ -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(); diff --git a/test/test_yang_with_defaults.sh b/test/test_yang_with_defaults.sh index 5f0e8c5f..f8a34a74 100755 --- a/test/test_yang_with_defaults.sh +++ b/test/test_yang_with_defaults.sh @@ -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