cli show options. doc and testing
This commit is contained in:
parent
6f2c4a076d
commit
09d33acd45
8 changed files with 64 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<img src="http://www.clicon.org/Clixon_logga_liggande_med-ikon.png" width="400">
|
<img src="https://www.clicon.org/Clixon_logga_liggande_med-ikon.png" width="400">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
[](https://travis-ci.org/clicon/clixon) [](https://clixon-docs.readthedocs.io/en/latest/?badge=latest)
|
[](https://travis-ci.org/clicon/clixon) [](https://clixon-docs.readthedocs.io/en/latest/?badge=latest)
|
||||||
|
|
|
||||||
|
|
@ -847,3 +847,54 @@ cli_show_auto_state(clicon_handle h,
|
||||||
return cli_show_auto1(h, 1, cvv, argv);
|
return cli_show_auto1(h, 1, cvv, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Show clixon configuration options as loaded
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
cli_show_options(clicon_handle h,
|
||||||
|
cvec *cvv,
|
||||||
|
cvec *argv)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
clicon_hash_t *hash = clicon_options(h);
|
||||||
|
int i;
|
||||||
|
char **keys = NULL;
|
||||||
|
void *val;
|
||||||
|
size_t klen;
|
||||||
|
size_t vlen;
|
||||||
|
cxobj *x = NULL;
|
||||||
|
|
||||||
|
if (clicon_hash_keys(hash, &keys, &klen) < 0)
|
||||||
|
goto done;
|
||||||
|
for(i = 0; i < klen; i++) {
|
||||||
|
val = clicon_hash_value(hash, keys[i], &vlen);
|
||||||
|
if (vlen){
|
||||||
|
if (((char*)val)[vlen-1]=='\0') /* assume string */
|
||||||
|
fprintf(stdout, "%s: \"%s\"\n", keys[i], (char*)val);
|
||||||
|
else
|
||||||
|
fprintf(stdout, "%s: 0x%p , length %zu\n", keys[i], val, vlen);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fprintf(stdout, "%s: NULL", keys[i]);
|
||||||
|
}
|
||||||
|
/* Next print CLICON_FEATURE and CLICON_YANG_DIR from config tree
|
||||||
|
* Since they are lists they are placed in the config tree.
|
||||||
|
*/
|
||||||
|
x = NULL;
|
||||||
|
while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) {
|
||||||
|
if (strcmp(xml_name(x), "CLICON_YANG_DIR") != 0)
|
||||||
|
continue;
|
||||||
|
fprintf(stdout, "%s: \"%s\"", xml_name(x), xml_body(x));
|
||||||
|
}
|
||||||
|
x = NULL;
|
||||||
|
while ((x = xml_child_each(clicon_conf_xml(h), x, CX_ELMNT)) != NULL) {
|
||||||
|
if (strcmp(xml_name(x), "CLICON_FEATURE") != 0)
|
||||||
|
continue;
|
||||||
|
fprintf(stdout, "%s: \"%s\"\n", xml_name(x), xml_body(x));
|
||||||
|
}
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
if (keys)
|
||||||
|
free(keys);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,8 @@ 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(clicon_handle h, cvec *cvv, cvec *argv);
|
||||||
|
|
||||||
int cli_show_state_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);
|
||||||
|
|
||||||
#endif /* _CLIXON_CLI_API_H_ */
|
#endif /* _CLIXON_CLI_API_H_ */
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ compare("Compare running and candidate"), compare_dbs((int32)1);
|
||||||
show("Show a particular state of the system"){
|
show("Show a particular state of the system"){
|
||||||
xpath("Show configuration") <xpath:string>("XPATH expression") <ns:string>("Namespace"), show_conf_xpath("candidate");
|
xpath("Show configuration") <xpath:string>("XPATH expression") <ns:string>("Namespace"), show_conf_xpath("candidate");
|
||||||
version("Show version"), cli_show_version("candidate", "text", "/");
|
version("Show version"), cli_show_version("candidate", "text", "/");
|
||||||
|
options("Show clixon options"), cli_show_options();
|
||||||
compare("Compare candidate and running databases"), compare_dbs((int32)0);{
|
compare("Compare candidate and running databases"), compare_dbs((int32)0);{
|
||||||
xml("Show comparison in xml"), compare_dbs((int32)0);
|
xml("Show comparison in xml"), compare_dbs((int32)0);
|
||||||
text("Show comparison in text"), compare_dbs((int32)1);
|
text("Show comparison in text"), compare_dbs((int32)1);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
*
|
*
|
||||||
***** BEGIN LICENSE BLOCK *****
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
Copyright (C) 2009-2019 Olof Hagsand
|
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
||||||
|
Copyright (C) 2017-2019 Olof Hagsand
|
||||||
|
Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
||||||
|
|
||||||
This file is part of CLIXON.
|
This file is part of CLIXON.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -293,8 +293,8 @@ static int
|
||||||
msg_dump(struct clicon_msg *msg)
|
msg_dump(struct clicon_msg *msg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char buf[9*8];
|
char buf[9*8+1];
|
||||||
char buf2[9*8];
|
char buf2[9*8+1];
|
||||||
|
|
||||||
memset(buf2, 0, sizeof(buf2));
|
memset(buf2, 0, sizeof(buf2));
|
||||||
snprintf(buf2, sizeof(buf2), "%s:", __FUNCTION__);
|
snprintf(buf2, sizeof(buf2), "%s:", __FUNCTION__);
|
||||||
|
|
|
||||||
|
|
@ -881,7 +881,7 @@ xml_child_order(cxobj *xp,
|
||||||
* Further, never manipulate the child-list during operation or using the
|
* Further, never manipulate the child-list during operation or using the
|
||||||
* same object recursively, the function uses an internal field to remember the
|
* same object recursively, the function uses an internal field to remember the
|
||||||
* index used. It works as long as the same object is not iterated concurrently.
|
* index used. It works as long as the same object is not iterated concurrently.
|
||||||
* If you need to delete a node you can do somethjing like:
|
* If you need to delete a node you can do somethhing like:
|
||||||
* @code
|
* @code
|
||||||
* cxobj *xprev = NULL;
|
* cxobj *xprev = NULL;
|
||||||
* cxobj *x = NULL;
|
* cxobj *x = NULL;
|
||||||
|
|
@ -892,6 +892,7 @@ xml_child_order(cxobj *xp,
|
||||||
* x = xprev;
|
* x = xprev;
|
||||||
* continue;
|
* continue;
|
||||||
* }
|
* }
|
||||||
|
* xprev = x;
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
#ifdef XML_EXPLICIT_INDEX
|
#ifdef XML_EXPLICIT_INDEX
|
||||||
|
|
|
||||||
|
|
@ -310,6 +310,7 @@ xml_nsctx_node(cxobj *xn,
|
||||||
* xml_nsctx_free(nsc)
|
* xml_nsctx_free(nsc)
|
||||||
* @endcode
|
* @endcode
|
||||||
* @see RFC7950 Sections 6.4.1 (and 9.9.2?)
|
* @see RFC7950 Sections 6.4.1 (and 9.9.2?)
|
||||||
|
* @note Assume yn is in a yang structure (eg has parents and belongs to a (sub)module)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml_nsctx_yang(yang_stmt *yn,
|
xml_nsctx_yang(yang_stmt *yn,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue