YANG domain/spec support
cli show mem improvement
This commit is contained in:
parent
5ebc5a2219
commit
b9ff2d083a
6 changed files with 39 additions and 36 deletions
|
|
@ -416,7 +416,7 @@ clixon_stats_datastore_get(clixon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Get clixon per datastore stats
|
/*! Get clixon per yang-spec stats
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] dbname Datastore name
|
* @param[in] dbname Datastore name
|
||||||
|
|
@ -1462,13 +1462,13 @@ from_client_stats(clixon_handle h,
|
||||||
while ((ydomain = yn_iter(ymounts, &inext)) != NULL) {
|
while ((ydomain = yn_iter(ymounts, &inext)) != NULL) {
|
||||||
domain = yang_argument_get(ydomain);
|
domain = yang_argument_get(ydomain);
|
||||||
/* per module-set, first configuration, then main dbspec, then mountpoints */
|
/* per module-set, first configuration, then main dbspec, then mountpoints */
|
||||||
|
inext2 = 0;
|
||||||
|
while ((yspec = yn_iter(ydomain, &inext2)) != NULL) {
|
||||||
cprintf(cbret, "<module-set>");
|
cprintf(cbret, "<module-set>");
|
||||||
cprintf(cbret, "<name>%s</name>", domain);
|
cprintf(cbret, "<name>%s/%s</name>", domain, yang_argument_get(yspec));
|
||||||
if (clixon_stats_module_get(h, ydomain, cbret) < 0)
|
if (clixon_stats_module_get(h, ydomain, cbret) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (modules){
|
if (modules){
|
||||||
inext2 = 0;
|
|
||||||
while ((yspec = yn_iter(ydomain, &inext2)) != NULL) {
|
|
||||||
inext3 = 0;
|
inext3 = 0;
|
||||||
while ((ymodule = yn_iter(yspec, &inext3)) != NULL) {
|
while ((ymodule = yn_iter(yspec, &inext3)) != NULL) {
|
||||||
cprintf(cbret, "<module><name>%s</name>", yang_argument_get(ymodule));
|
cprintf(cbret, "<module><name>%s</name>", yang_argument_get(ymodule));
|
||||||
|
|
@ -1477,9 +1477,9 @@ from_client_stats(clixon_handle h,
|
||||||
cprintf(cbret, "</module>");
|
cprintf(cbret, "</module>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cprintf(cbret, "</module-set>");
|
cprintf(cbret, "</module-set>");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cprintf(cbret, "</module-sets>");
|
cprintf(cbret, "</module-sets>");
|
||||||
cprintf(cbret, "</rpc-reply>");
|
cprintf(cbret, "</rpc-reply>");
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
|
||||||
|
|
@ -1883,10 +1883,10 @@ cli_show_statistics(clixon_handle h,
|
||||||
parse_tree *pt;
|
parse_tree *pt;
|
||||||
uint64_t nr;
|
uint64_t nr;
|
||||||
uint64_t tnr0;
|
uint64_t tnr0;
|
||||||
uint64_t tnr;
|
uint64_t tnr = 0;
|
||||||
size_t sz;
|
size_t sz;
|
||||||
size_t tsz0;
|
size_t tsz0;
|
||||||
size_t tsz;
|
size_t tsz = 0;
|
||||||
yang_stmt *ymounts;
|
yang_stmt *ymounts;
|
||||||
yang_stmt *ydomain;
|
yang_stmt *ydomain;
|
||||||
yang_stmt *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
@ -1946,10 +1946,10 @@ cli_show_statistics(clixon_handle h,
|
||||||
while ((yspec = yn_iter(ydomain, &inext2)) != NULL) {
|
while ((yspec = yn_iter(ydomain, &inext2)) != NULL) {
|
||||||
name = yang_argument_get(yspec);
|
name = yang_argument_get(yspec);
|
||||||
nr = 0; sz = 0;
|
nr = 0; sz = 0;
|
||||||
if (yang_stats(ydomain, 0, &nr, &sz) < 0)
|
if (yang_stats(yspec, 0, &nr, &sz) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
tnr = nr;
|
tnr += nr;
|
||||||
tsz = sz;
|
tsz += sz;
|
||||||
if (detail) {
|
if (detail) {
|
||||||
cligen_output(stdout, "YANG-%s-%s-size: %" PRIu64 "\n", domain, name, sz);
|
cligen_output(stdout, "YANG-%s-%s-size: %" PRIu64 "\n", domain, name, sz);
|
||||||
cligen_output(stdout, "YANG-%s-%s-nr: %" PRIu64 "\n", domain, name, nr);
|
cligen_output(stdout, "YANG-%s-%s-nr: %" PRIu64 "\n", domain, name, nr);
|
||||||
|
|
@ -1963,8 +1963,8 @@ cli_show_statistics(clixon_handle h,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (detail){
|
if (detail){
|
||||||
cligen_output(stdout, "YANG-total-size: %" PRIu64 "\n", sz);
|
cligen_output(stdout, "YANG-total-size: %" PRIu64 "\n", tsz);
|
||||||
cligen_output(stdout, "YANG-total-nr: %" PRIu64 "\n", sz);
|
cligen_output(stdout, "YANG-total-nr: %" PRIu64 "\n", tnr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
translatenumber(tsz, &u64, &unit);
|
translatenumber(tsz, &u64, &unit);
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ int yang_stats(yang_stmt *y, enum rfc_6020 keyw, uint64_t *nrp, size_t *s
|
||||||
/* Other functions */
|
/* Other functions */
|
||||||
yang_stmt *yspec_new(clixon_handle h, char *name);
|
yang_stmt *yspec_new(clixon_handle h, char *name);
|
||||||
yang_stmt *yspec_new1(clixon_handle h, char *domain, char *name);
|
yang_stmt *yspec_new1(clixon_handle h, char *domain, char *name);
|
||||||
yang_stmt *yspec_new_shared(clixon_handle h, char *name, char *domain, yang_stmt *yspec0);
|
yang_stmt *yspec_new_shared(clixon_handle h, char *xpath, char *domain, char *name, yang_stmt *yspec0);
|
||||||
yang_stmt *ydomain_new(clixon_handle h, char *domain);
|
yang_stmt *ydomain_new(clixon_handle h, char *domain);
|
||||||
yang_stmt *ys_new(enum rfc_6020 keyw);
|
yang_stmt *ys_new(enum rfc_6020 keyw);
|
||||||
yang_stmt *ys_prune(yang_stmt *yp, int i);
|
yang_stmt *ys_prune(yang_stmt *yp, int i);
|
||||||
|
|
|
||||||
|
|
@ -887,7 +887,9 @@ yspec_new1(clixon_handle h,
|
||||||
/*! Create or add a shared yspec
|
/*! Create or add a shared yspec
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] tag Typically an xpath, saved in cvec
|
* @param[in] xpath Mount xpath, saved in cvec
|
||||||
|
* @param[in] domain YANG domain
|
||||||
|
* @param[in] domain YANG spec name
|
||||||
* @param[in] yspec0 Input NULL if no previous shared exist, otherwise a shared yspec but new name
|
* @param[in] yspec0 Input NULL if no previous shared exist, otherwise a shared yspec but new name
|
||||||
* @retval yspec1 New or (previously shared)
|
* @retval yspec1 New or (previously shared)
|
||||||
* @retval NULL Error
|
* @retval NULL Error
|
||||||
|
|
@ -895,35 +897,27 @@ yspec_new1(clixon_handle h,
|
||||||
*/
|
*/
|
||||||
yang_stmt *
|
yang_stmt *
|
||||||
yspec_new_shared(clixon_handle h,
|
yspec_new_shared(clixon_handle h,
|
||||||
char *tag,
|
char *xpath,
|
||||||
char *domain,
|
char *domain,
|
||||||
|
char *name,
|
||||||
yang_stmt *yspec0)
|
yang_stmt *yspec0)
|
||||||
{
|
{
|
||||||
yang_stmt *yspec1 = NULL;
|
yang_stmt *yspec1 = NULL;
|
||||||
cbuf *cb = NULL;
|
|
||||||
static int nr = 0;
|
|
||||||
|
|
||||||
if (yspec0 != NULL){ /* shared */
|
if (yspec0 != NULL){ /* shared */
|
||||||
yspec1 = yspec0;
|
yspec1 = yspec0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((cb = cbuf_new()) == NULL){
|
if ((yspec1 = yspec_new1(h, domain, name)) == NULL)
|
||||||
clixon_err(OE_YANG, errno, "cbuf_new");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
cprintf(cb, "%s%d", domain, nr++);
|
|
||||||
if ((yspec1 = yspec_new1(h, domain, cbuf_get(cb))) == NULL)
|
|
||||||
goto done;
|
goto done;
|
||||||
yang_flag_set(yspec1, YANG_FLAG_SPEC_MOUNT);
|
yang_flag_set(yspec1, YANG_FLAG_SPEC_MOUNT);
|
||||||
clixon_debug(CLIXON_DBG_YANG, "new yang-spec: %p", yspec1);
|
clixon_debug(CLIXON_DBG_YANG, "new yang-spec: %p", yspec1);
|
||||||
}
|
}
|
||||||
if (yang_cvec_add(yspec1, CGV_STRING, tag) < 0){
|
if (yang_cvec_add(yspec1, CGV_STRING, xpath) < 0){
|
||||||
yspec1 = NULL;
|
yspec1 = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
if (cb)
|
|
||||||
cbuf_free(cb);
|
|
||||||
return yspec1;
|
return yspec1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -784,7 +784,9 @@ yang_schema_yanglib_parse_mount(clixon_handle h,
|
||||||
yang_stmt *yspec1 = NULL;
|
yang_stmt *yspec1 = NULL;
|
||||||
char *xpath = NULL;
|
char *xpath = NULL;
|
||||||
char *domain = NULL;
|
char *domain = NULL;
|
||||||
|
cbuf *cb = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
static unsigned int nr = 0;
|
||||||
|
|
||||||
/* 1. Get modstate (xyanglib) of node: xyanglib, by querying backend state (via callback)
|
/* 1. Get modstate (xyanglib) of node: xyanglib, by querying backend state (via callback)
|
||||||
* XXX this xyanglib is not proper RFC8525, submodules appear as modules WHY?
|
* XXX this xyanglib is not proper RFC8525, submodules appear as modules WHY?
|
||||||
|
|
@ -819,7 +821,12 @@ yang_schema_yanglib_parse_mount(clixon_handle h,
|
||||||
if (yang_schema_find_share(h, xt, xyanglib, &yspec0) < 0)
|
if (yang_schema_find_share(h, xt, xyanglib, &yspec0) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((yspec1 = yspec_new_shared(h, xpath, domain, yspec0)) < 0)
|
if ((cb = cbuf_new()) == NULL){
|
||||||
|
clixon_err(OE_YANG, errno, "cbuf_new");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
cprintf(cb, "%u", nr++);
|
||||||
|
if ((yspec1 = yspec_new_shared(h, xpath, domain, cbuf_get(cb), yspec0)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Either yspec0 = NULL and yspec1 is new, or yspec0 == yspec1 != NULL (shared) */
|
/* Either yspec0 = NULL and yspec1 is new, or yspec0 == yspec1 != NULL (shared) */
|
||||||
if (yspec0 == NULL && yspec1 != NULL){
|
if (yspec0 == NULL && yspec1 != NULL){
|
||||||
|
|
@ -835,6 +842,8 @@ yang_schema_yanglib_parse_mount(clixon_handle h,
|
||||||
yspec1 = NULL;
|
yspec1 = NULL;
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
|
if (cb)
|
||||||
|
cbuf_free(cb);
|
||||||
if (xpath)
|
if (xpath)
|
||||||
free(xpath);
|
free(xpath);
|
||||||
if (yspec1)
|
if (yspec1)
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ new "get yang-lib at mountpoint"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get><filter type=\"subtree\"><top xmlns=\"urn:example:clixon\"><mylist/></top>></filter></get></rpc>" "<rpc-reply $DEFAULTNS><data><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\"><module-set><name>mylabel</name><module><name>clixon-mount0</name><namespace>urn:example:mount0</namespace></module></module-set></yang-library></root></mylist><mylist><name>y</name><root><yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\"><module-set><name>mylabel</name><module><name>clixon-mount0</name><namespace>urn:example:mount0</namespace></module></module-set></yang-library></root></mylist></top></data></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get><filter type=\"subtree\"><top xmlns=\"urn:example:clixon\"><mylist/></top>></filter></get></rpc>" "<rpc-reply $DEFAULTNS><data><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\"><module-set><name>mylabel</name><module><name>clixon-mount0</name><namespace>urn:example:mount0</namespace></module></module-set></yang-library></root></mylist><mylist><name>y</name><root><yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\"><module-set><name>mylabel</name><module><name>clixon-mount0</name><namespace>urn:example:mount0</namespace></module></module-set></yang-library></root></mylist></top></data></rpc-reply>"
|
||||||
|
|
||||||
new "check there is statistics from mountpoint"
|
new "check there is statistics from mountpoint"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><stats xmlns=\"http://clicon.org/lib\"></stats></rpc>" "<module-set><name>mylabel</name>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><stats xmlns=\"http://clicon.org/lib\"></stats></rpc>" "<module-set><name>mylabel/0</name>"
|
||||||
|
|
||||||
new "Add data to mounts"
|
new "Add data to mounts"
|
||||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x1</name1></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x1</name1></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue