Example: added -m/-M options for testing mount-points
This commit is contained in:
parent
27b77b14bc
commit
bee30a4ea0
7 changed files with 288 additions and 50 deletions
|
|
@ -36,6 +36,8 @@
|
|||
* The example have the following optional arguments that you can pass as
|
||||
* argc/argv after -- in clixon_backend:
|
||||
* -a <..> Register callback for this yang action
|
||||
* -m <yang> Mount this yang on mountpoint
|
||||
* -M <namespace> Namespace of mountpoint, note both -m and -M must exist
|
||||
* -n Notification streams example
|
||||
* -r enable the reset function
|
||||
* -s enable the state function
|
||||
|
|
@ -68,7 +70,7 @@
|
|||
#include <clixon/clixon_backend.h>
|
||||
|
||||
/* Command line options to be passed to getopt(3) */
|
||||
#define BACKEND_EXAMPLE_OPTS "a:nrsS:x:iuUtV:"
|
||||
#define BACKEND_EXAMPLE_OPTS "a:m:M:nrsS:x:iuUtV:"
|
||||
|
||||
/* Enabling this improves performance in tests, but there may trigger the "double XPath"
|
||||
* problem.
|
||||
|
|
@ -84,6 +86,14 @@
|
|||
*/
|
||||
static char *_action_instanceid = NULL;
|
||||
|
||||
/*! Yang schema mount
|
||||
*
|
||||
* Start backend with -- -m <yang> -M <namespace>
|
||||
* Mount this yang on mountpoint
|
||||
*/
|
||||
static char *_mount_yang = NULL;
|
||||
static char *_mount_namespace = NULL;
|
||||
|
||||
/*! Notification stream
|
||||
*
|
||||
* Enable notification streams for netconf/restconf
|
||||
|
|
@ -936,18 +946,19 @@ main_yang_mount(clicon_handle h,
|
|||
*config = 1;
|
||||
if (vl)
|
||||
*vl = VL_FULL;
|
||||
if (yanglib){
|
||||
if (yanglib && _mount_yang){
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "<yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">");
|
||||
cprintf(cb, "<module-set>");
|
||||
cprintf(cb, "<name>mount</name>");
|
||||
cprintf(cb, "<name>mylabel</name>"); // XXX label in test_yang_schema_mount
|
||||
cprintf(cb, "<module>");
|
||||
cprintf(cb, "<name>clixon-example</name>");
|
||||
cprintf(cb, "<revision>2022-11-01</revision>");
|
||||
cprintf(cb, "<namespace>urn:example:urn</namespace>");
|
||||
/* In yang name+namespace is mandatory, but not revision */
|
||||
cprintf(cb, "<name>%s</name>", _mount_yang); // mandatory
|
||||
cprintf(cb, "<namespace>%s</namespace>", _mount_namespace); // mandatory
|
||||
// cprintf(cb, "<revision>2022-11-01</revision>");
|
||||
cprintf(cb, "</module>");
|
||||
cprintf(cb, "</module-set>");
|
||||
cprintf(cb, "</yang-library>");
|
||||
|
|
@ -1426,6 +1437,12 @@ clixon_plugin_init(clicon_handle h)
|
|||
case 'a':
|
||||
_action_instanceid = optarg;
|
||||
break;
|
||||
case 'm':
|
||||
_mount_yang = optarg;
|
||||
break;
|
||||
case 'M':
|
||||
_mount_namespace = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
_notification_stream = 1;
|
||||
break;
|
||||
|
|
@ -1457,7 +1474,10 @@ clixon_plugin_init(clicon_handle h)
|
|||
_validate_fail_xpath = optarg;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((_mount_yang && !_mount_namespace) || (!_mount_yang && _mount_namespace)){
|
||||
clicon_err(OE_PLUGIN, EINVAL, "Both -m and -M must be given for mounts");
|
||||
goto done;
|
||||
}
|
||||
if (_state_file){
|
||||
api.ca_statedata = example_statefile; /* Switch state data callback */
|
||||
if (_state_xpath){
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@
|
|||
|
||||
***** END LICENSE BLOCK *****
|
||||
*
|
||||
* The example have the following optional arguments that you can pass as
|
||||
* argc/argv after -- in clixon_cli:
|
||||
* -m <yang> Mount this yang on mountpoint
|
||||
* -M <namespace> Namespace of mountpoint, note both -m and -M must exist
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -52,6 +56,14 @@
|
|||
#include <clixon/clixon_cli.h>
|
||||
#include <clixon/cli_generate.h>
|
||||
|
||||
/*! Yang schema mount
|
||||
*
|
||||
* Start backend with -- -m <yang> -M <namespace>
|
||||
* Mount this yang on mountpoint
|
||||
*/
|
||||
static char *_mount_yang = NULL;
|
||||
static char *_mount_namespace = NULL;
|
||||
|
||||
/*! Example cli function */
|
||||
int
|
||||
mycallback(clicon_handle h, cvec *cvv, cvec *argv)
|
||||
|
|
@ -135,34 +147,6 @@ example_client_rpc(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
#ifndef CLIXON_STATIC_PLUGINS
|
||||
static clixon_plugin_api api = {
|
||||
"example", /* name */
|
||||
clixon_plugin_init, /* init */
|
||||
NULL, /* start */
|
||||
NULL, /* exit */
|
||||
.ca_prompt=NULL, /* cli_prompthook_t */
|
||||
.ca_suspend=NULL, /* cligen_susp_cb_t */
|
||||
.ca_interrupt=NULL, /* cligen_interrupt_cb_t */
|
||||
};
|
||||
|
||||
/*! CLI plugin initialization
|
||||
* @param[in] h Clixon handle
|
||||
* @retval NULL Error with clicon_err set
|
||||
* @retval api Pointer to API struct
|
||||
*/
|
||||
clixon_plugin_api *
|
||||
clixon_plugin_init(clicon_handle h)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
srandom(tv.tv_usec);
|
||||
|
||||
return &api;
|
||||
}
|
||||
#endif /* CLIXON_STATIC_PLUGINS */
|
||||
|
||||
/*! Translate function from an original value to a new.
|
||||
* In this case, assume string and increment characters, eg HAL->IBM
|
||||
*/
|
||||
|
|
@ -185,3 +169,111 @@ cli_incstr(cligen_handle h,
|
|||
str[i]++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Example YANG schema mount
|
||||
*
|
||||
* Given an XML mount-point xt, return XML yang-lib modules-set
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] xt XML mount-point in XML tree
|
||||
* @param[out] config If '0' all data nodes in the mounted schema are read-only
|
||||
* @param[out] validate Do or dont do full RFC 7950 validation
|
||||
* @param[out] yanglib XML yang-lib module-set tree
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* XXX hardcoded to clixon-example@2022-11-01.yang regardless of xt
|
||||
* @see RFC 8528
|
||||
*/
|
||||
int
|
||||
example_cli_yang_mount(clicon_handle h,
|
||||
cxobj *xt,
|
||||
int *config,
|
||||
validate_level *vl,
|
||||
cxobj **yanglib)
|
||||
{
|
||||
int retval = -1;
|
||||
cbuf *cb = NULL;
|
||||
|
||||
if (config)
|
||||
*config = 1;
|
||||
if (vl)
|
||||
*vl = VL_FULL;
|
||||
if (yanglib && _mount_yang){
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "<yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">");
|
||||
cprintf(cb, "<module-set>");
|
||||
cprintf(cb, "<name>mount</name>");
|
||||
cprintf(cb, "<module>");
|
||||
/* In yang name+namespace is mandatory, but not revision */
|
||||
cprintf(cb, "<name>%s</name>", _mount_yang); // mandatory
|
||||
cprintf(cb, "<namespace>%s</namespace>", _mount_namespace); // mandatory
|
||||
// cprintf(cb, "<revision>2022-11-01</revision>");
|
||||
cprintf(cb, "</module>");
|
||||
cprintf(cb, "</module-set>");
|
||||
cprintf(cb, "</yang-library>");
|
||||
if (clixon_xml_parse_string(cbuf_get(cb), YB_NONE, NULL, yanglib, NULL) < 0)
|
||||
goto done;
|
||||
if (xml_rootchild(*yanglib, 0, yanglib) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
done:
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
return retval;
|
||||
}
|
||||
|
||||
#ifndef CLIXON_STATIC_PLUGINS
|
||||
static clixon_plugin_api api = {
|
||||
"example", /* name */
|
||||
clixon_plugin_init, /* init */
|
||||
NULL, /* start */
|
||||
NULL, /* exit */
|
||||
.ca_prompt=NULL, /* cli_prompthook_t */
|
||||
.ca_suspend=NULL, /* cligen_susp_cb_t */
|
||||
.ca_interrupt=NULL, /* cligen_interrupt_cb_t */
|
||||
.ca_yang_mount=example_cli_yang_mount /* RFC 8528 schema mount */
|
||||
};
|
||||
|
||||
/*! CLI plugin initialization
|
||||
* @param[in] h Clixon handle
|
||||
* @retval NULL Error with clicon_err set
|
||||
* @retval api Pointer to API struct
|
||||
*/
|
||||
clixon_plugin_api *
|
||||
clixon_plugin_init(clicon_handle h)
|
||||
{
|
||||
struct timeval tv;
|
||||
int c;
|
||||
int argc; /* command-line options (after --) */
|
||||
char **argv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
srandom(tv.tv_usec);
|
||||
/* Get user command-line options (after --) */
|
||||
if (clicon_argv_get(h, &argc, &argv) < 0)
|
||||
goto done;
|
||||
opterr = 0;
|
||||
optind = 1;
|
||||
while ((c = getopt(argc, argv, "m:M:")) != -1)
|
||||
switch (c) {
|
||||
case 'm':
|
||||
_mount_yang = optarg;
|
||||
break;
|
||||
case 'M':
|
||||
_mount_namespace = optarg;
|
||||
break;
|
||||
}
|
||||
if ((_mount_yang && !_mount_namespace) || (!_mount_yang && _mount_namespace)){
|
||||
clicon_err(OE_PLUGIN, EINVAL, "Both -m and -M must be given for mounts");
|
||||
goto done;
|
||||
}
|
||||
return &api;
|
||||
done:
|
||||
return NULL;
|
||||
}
|
||||
#endif /* CLIXON_STATIC_PLUGINS */
|
||||
|
||||
|
|
|
|||
|
|
@ -290,6 +290,8 @@ typedef int (datastore_upgrade_t)(clicon_handle h, const char *db, cxobj *xt, mo
|
|||
* @param[out] yanglib XML yang-lib module-set tree. Freed by caller.
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
* @note For optional fields, such as revision, the callback may omit it, but will be resolved
|
||||
* at proper parse-time, but this is not visible in the yanglib return
|
||||
* @see RFC 8528 (schema-mount) and RFC 8525 (yang-lib)
|
||||
*/
|
||||
typedef int (yang_mount_t)(clicon_handle h, cxobj *xt, int *config,
|
||||
|
|
|
|||
|
|
@ -855,8 +855,7 @@ yang_lib2yspec(clicon_handle h,
|
|||
xi = vec[i];
|
||||
if ((name = xml_find_body(xi, "name")) == NULL)
|
||||
continue;
|
||||
if ((revision = xml_find_body(xi, "revision")) == NULL)
|
||||
continue;
|
||||
revision = xml_find_body(xi, "revision");
|
||||
if ((ymod = yang_find(yspec, Y_MODULE, name)) != NULL ||
|
||||
(ymod = yang_find(yspec, Y_SUBMODULE, name)) != NULL){
|
||||
/* Skip if matching or no revision
|
||||
|
|
@ -866,7 +865,7 @@ yang_lib2yspec(clicon_handle h,
|
|||
modmin++;
|
||||
continue;
|
||||
}
|
||||
if (strcmp(yang_argument_get(yrev), revision) == 0){
|
||||
if (revision && strcmp(yang_argument_get(yrev), revision) == 0){
|
||||
modmin++;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -875,7 +874,8 @@ yang_lib2yspec(clicon_handle h,
|
|||
goto fail;
|
||||
}
|
||||
#ifdef YANG_SCHEMA_MOUNT_YANG_LIB_FORCE
|
||||
/* XXX: Ensure yang-lib is always there otherwise get state dont work for mountpoint */
|
||||
/* Force add ietf-yang-library@2019-01-04 on all mount-points
|
||||
otherwise get state dont work for mountpoint */
|
||||
if ((ymod = yang_find(yspec, Y_MODULE, "ietf-yang-library")) != NULL &&
|
||||
(yrev = yang_find(ymod, Y_REVISION, NULL)) != NULL &&
|
||||
strcmp(yang_argument_get(yrev), "2019-01-04") == 0){
|
||||
|
|
|
|||
|
|
@ -255,7 +255,6 @@ xml_yang_mount_get(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
|
||||
|
||||
/*! Set yangspec mount-point via XML mount-point node
|
||||
*
|
||||
* Stored in a separate structure (not in XML config tree)
|
||||
|
|
@ -389,6 +388,7 @@ yang_schema_mount_statedata_yanglib(clicon_handle h,
|
|||
}
|
||||
if (xml_apply(*xret, CX_ELMNT, find_schema_mounts, cvv) < 0)
|
||||
goto done;
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
cv = NULL;
|
||||
while ((cv = cvec_each(cvv, cv)) != NULL) {
|
||||
xmp = cv_void_get(cv);
|
||||
|
|
@ -398,7 +398,6 @@ yang_schema_mount_statedata_yanglib(clicon_handle h,
|
|||
goto done;
|
||||
if (yanglib == NULL)
|
||||
continue;
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
if ((ret = xml_bind_yang0(h, yanglib, YB_MODULE, yspec, xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# Test for RFC8528 YANG Schema Mount
|
||||
# XXX No cli tests
|
||||
# clixon-example is top-level, mounts clixon-mount1
|
||||
# The example extends the main example using -- -m <name> -M <urn> for both backend and cli
|
||||
# Extensive testing of mounted augment/uses: see fyang0 which includes fyang1+fyang2
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
|
@ -8,7 +10,13 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
|||
APPNAME=example
|
||||
|
||||
cfg=$dir/conf_mount.xml
|
||||
clispec=$dir/automode.cli
|
||||
fyang=$dir/clixon-example.yang
|
||||
fyang0=$dir/clixon-mount0.yang
|
||||
fyang1=$dir/clixon-mount1.yang
|
||||
fyang2=$dir/clixon-mount2.yang
|
||||
|
||||
AUTOCLI=$(autocli_config clixon-\* kw-nokey false)
|
||||
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
|
|
@ -17,7 +25,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_YANG_DIR>${dir}</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||
<CLICON_YANG_LIBRARY>true</CLICON_YANG_LIBRARY>
|
||||
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
||||
<CLICON_CLISPEC_DIR>$dir</CLICON_CLISPEC_DIR>
|
||||
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
||||
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
|
|
@ -28,8 +36,19 @@ cat <<EOF > $cfg
|
|||
<CLICON_VALIDATE_STATE_XML>true</CLICON_VALIDATE_STATE_XML>
|
||||
<CLICON_STREAM_DISCOVERY_RFC5277>true</CLICON_STREAM_DISCOVERY_RFC5277>
|
||||
<CLICON_YANG_SCHEMA_MOUNT>true</CLICON_YANG_SCHEMA_MOUNT>
|
||||
<autocli>
|
||||
<module-default>false</module-default>
|
||||
<list-keyword-default>kw-nokey</list-keyword-default>
|
||||
<grouping-treeref>true</grouping-treeref>
|
||||
<rule>
|
||||
<name>include clixon</name>
|
||||
<operation>enable</operation>
|
||||
<module-name>clixon-*</module-name>
|
||||
</rule>
|
||||
</autocli>
|
||||
</clixon-config>
|
||||
EOF
|
||||
# ${AUTOCLI}
|
||||
|
||||
cat <<EOF > $fyang
|
||||
module clixon-example{
|
||||
|
|
@ -47,7 +66,7 @@ module clixon-example{
|
|||
}
|
||||
container root{
|
||||
presence "Otherwise root is not visible";
|
||||
yangmnt:mount-point "myroot"{
|
||||
yangmnt:mount-point "mylabel"{
|
||||
description "Root for other yang models";
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +75,88 @@ module clixon-example{
|
|||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF > $fyang0
|
||||
module clixon-mount0{
|
||||
yang-version 1.1;
|
||||
namespace "urn:example:mount0";
|
||||
prefix m0;
|
||||
import clixon-mount1 {
|
||||
prefix m1;
|
||||
}
|
||||
import clixon-mount2 {
|
||||
prefix m2;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF > $fyang1
|
||||
module clixon-mount1{
|
||||
yang-version 1.1;
|
||||
namespace "urn:example:mount1";
|
||||
prefix m1;
|
||||
container mount1{
|
||||
list mylist1{
|
||||
key name1;
|
||||
leaf name1{
|
||||
type string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF > $fyang2
|
||||
module clixon-mount2{
|
||||
yang-version 1.1;
|
||||
namespace "urn:example:mount2";
|
||||
prefix m2;
|
||||
import clixon-mount1 {
|
||||
prefix m1;
|
||||
}
|
||||
grouping ag2 {
|
||||
leaf option2{
|
||||
type string;
|
||||
}
|
||||
}
|
||||
grouping ag1 {
|
||||
container options {
|
||||
leaf option1{
|
||||
type string;
|
||||
}
|
||||
uses ag2;
|
||||
}
|
||||
}
|
||||
augment /m1:mount1/m1:mylist1 {
|
||||
uses ag1;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF > $clispec
|
||||
CLICON_MODE="example";
|
||||
CLICON_PROMPT="%U@%H %W> ";
|
||||
CLICON_PLUGIN="example_cli";
|
||||
|
||||
# Autocli syntax tree operations
|
||||
set @datamodel, cli_auto_set();
|
||||
merge @datamodel, cli_auto_merge();
|
||||
create @datamodel, cli_auto_create();
|
||||
delete("Delete a configuration item") @datamodel, cli_auto_del();
|
||||
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_auto_mode("candidate", "xml", 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_show_auto_mode("running", "xml", false, true);
|
||||
}
|
||||
EOF
|
||||
|
||||
new "test params: -f $cfg"
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
|
|
@ -64,8 +165,8 @@ if [ $BE -ne 0 ]; then
|
|||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
new "start backend -s init -f $cfg"
|
||||
start_backend -s init -f $cfg
|
||||
new "start backend -s init -f $cfg -- -m clixon-mount0 -M urn:example:mount0"
|
||||
start_backend -s init -f $cfg -- -m clixon-mount0 -M urn:example:mount0
|
||||
fi
|
||||
|
||||
new "wait backend"
|
||||
|
|
@ -78,14 +179,32 @@ new "netconf commit"
|
|||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><commit/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||
|
||||
new "Retrieve schema-mounts with <get> Operation"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get><filter type=\"subtree\"><schema-mounts xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-schema-mount\"></schema-mounts></filter></get></rpc>" "<rpc-reply $DEFAULTNS><data><schema-mounts xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-schema-mount\"><mount-point><module>clixon-example</module><label>myroot</label><config>true</config><inline/></mount-point></schema-mounts></data></rpc-reply>"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get><filter type=\"subtree\"><schema-mounts xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-schema-mount\"></schema-mounts></filter></get></rpc>" "<rpc-reply $DEFAULTNS><data><schema-mounts xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-schema-mount\"><mount-point><module>clixon-example</module><label>mylabel</label><config>true</config><inline/></mount-point></schema-mounts></data></rpc-reply>"
|
||||
|
||||
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>mount</name><module><name>clixon-example</name><revision>2022-11-01</revision><namespace>urn:example:urn</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>mount</name><module><name>clixon-example</name><revision>2022-11-01</revision><namespace>urn:example:urn</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"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><stats xmlns=\"http://clicon.org/lib\"></stats></rpc>" '<module-set><name>mountpoint: /top/mylist\[name="x"\]/root</name><nr>'
|
||||
|
||||
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>"
|
||||
|
||||
new "netconf commit"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><commit/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||
|
||||
new "Add mounted augment data 2"
|
||||
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><options xmlns=\"urn:example:mount2\"><option2>bar</option2></options></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||
|
||||
new "netconf commit"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><commit/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
|
||||
|
||||
new "get mounted augment data"
|
||||
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>" "<rpc-reply $DEFAULTNS><data><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x1</name1><options xmlns=\"urn:example:mount2\"><option1>foo</option1><option2>bar</option2></options></mylist1></mount1></root></mylist><mylist><name>y</name><root/></mylist></top></data></rpc-reply>"
|
||||
|
||||
new "cli show config"
|
||||
expectpart "$($clixon_cli -1 -f $cfg show config xml -- -m clixon-mount0 -M urn:example:mount0)" 0 "<top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x1</name1><options xmlns=\"urn:example:mount2\"><option1>foo</option1><option2>bar</option2></options></mylist1></mount1></root></mylist><mylist><name>y</name><root/></mylist></top>"
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
|
|
|
|||
|
|
@ -519,7 +519,13 @@ module clixon-config {
|
|||
leaf CLICON_YANG_SCHEMA_MOUNT{
|
||||
type boolean;
|
||||
description
|
||||
"YANG schema mount, RFC 8528";
|
||||
"YANG schema mount, RFC 8528.
|
||||
When enabled, mount-points as defined by the 'yangmnt:mount-point' extension can
|
||||
be populated by other YANGs than the root.
|
||||
This is controlled by the ca_yang_mount plugin callback by returning a assigning a
|
||||
yanglib module-set section that corresponds to the mounted YANGs.
|
||||
Also, schema mount statistics is added to state data
|
||||
Further, autocli syntax is added by definining a tree resolve wrapper";
|
||||
default false;
|
||||
}
|
||||
leaf CLICON_BACKEND_REGEXP {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue