autocli sub fixes
This commit is contained in:
parent
75f85e0253
commit
542c0495b3
5 changed files with 86 additions and 41 deletions
|
|
@ -63,6 +63,8 @@ Developers may need to change their code
|
||||||
|
|
||||||
### Minor changes
|
### Minor changes
|
||||||
|
|
||||||
|
* Change comment character to be active anywhere to beginning of _word_ only.
|
||||||
|
* See [Change CLIgen comments](https://github.com/clicon/cligen/issues/55)
|
||||||
* Improved performance of parsing files as described in [Bytewise read() of files is slow #146](https://github.com/clicon/clixon/issues/146), thanks: @hjelmeland
|
* Improved performance of parsing files as described in [Bytewise read() of files is slow #146](https://github.com/clicon/clixon/issues/146), thanks: @hjelmeland
|
||||||
* Added new backend plugin: ca_pre-demon called if backend is daemonized just prior to forking.
|
* Added new backend plugin: ca_pre-demon called if backend is daemonized just prior to forking.
|
||||||
* Added XPATH functions `position`
|
* Added XPATH functions `position`
|
||||||
|
|
|
||||||
|
|
@ -289,8 +289,7 @@ cli_auto_top(clicon_handle h,
|
||||||
cligen_ph_workpoint_set(ph, NULL);
|
cligen_ph_workpoint_set(ph, NULL);
|
||||||
/* Store this as edit-mode */
|
/* Store this as edit-mode */
|
||||||
clicon_data_set(h, "cli-edit-mode", "");
|
clicon_data_set(h, "cli-edit-mode", "");
|
||||||
if (clicon_data_cvec_get(h, "cli-edit-cvv") != NULL)
|
clicon_data_cvec_del(h, "cli-edit-cvv");
|
||||||
clicon_data_del(h, "cli-edit-cvv");
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -617,11 +616,12 @@ cli_auto_sub_enter(clicon_handle h,
|
||||||
cvec *cvv,
|
cvec *cvv,
|
||||||
cvec *argv)
|
cvec *argv)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char *api_path_fmt; /* Contains wildcards as %.. */
|
char *api_path_fmt; /* Contains wildcards as %.. */
|
||||||
char *api_path = NULL;
|
char *api_path = NULL;
|
||||||
char *treename;
|
char *treename;
|
||||||
cvec *cvv1 = NULL;
|
cvec *cvv1 = NULL;
|
||||||
|
cvec *cvv2 = NULL;
|
||||||
int i;
|
int i;
|
||||||
cg_var *cv = NULL;
|
cg_var *cv = NULL;
|
||||||
pt_head *ph;
|
pt_head *ph;
|
||||||
|
|
@ -662,23 +662,28 @@ cli_auto_sub_enter(clicon_handle h,
|
||||||
}
|
}
|
||||||
if (api_path_fmt2api_path(api_path_fmt, cvv1, &api_path) < 0)
|
if (api_path_fmt2api_path(api_path_fmt, cvv1, &api_path) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Set the mode as a static variable to this command */
|
/* Assign the variables */
|
||||||
|
if ((cvv2 = cvec_append(clicon_data_cvec_get(h, "cli-edit-cvv"), cvv1)) == NULL)
|
||||||
|
goto done;
|
||||||
|
/* Store this as edit-mode */
|
||||||
if (clicon_data_set(h, "cli-edit-mode", api_path) < 0)
|
if (clicon_data_set(h, "cli-edit-mode", api_path) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Assign the variables */
|
if (clicon_data_cvec_set(h, "cli-edit-cvv", cvv2) < 0)
|
||||||
if (cvec_append(clicon_data_cvec_get(h, "cli-edit-cvv"), cvv1) == NULL)
|
|
||||||
goto done;
|
goto done;
|
||||||
/* Find current cligen tree */
|
/* Find current cligen tree */
|
||||||
if ((ph = cligen_ph_find(cli_cligen(h), treename)) == NULL){
|
if ((ph = cligen_ph_find(cli_cligen(h), treename)) == NULL){
|
||||||
clicon_err(OE_PLUGIN, 0, "No such parsetree header: %s", treename);
|
clicon_err(OE_PLUGIN, ENOENT, "No such parsetree header: %s", treename);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Find the point in the generated clispec tree where workpoint should be set */
|
/* Find the point in the generated clispec tree where workpoint should be set */
|
||||||
fa.fa_str = api_path_fmt;
|
fa.fa_str = api_path_fmt;
|
||||||
if (pt_apply(cligen_ph_parsetree_get(ph), cli_auto_findpt, &fa) < 0)
|
if (pt_apply(cligen_ph_parsetree_get(ph), cli_auto_findpt, &fa) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (fa.fa_co)
|
if (fa.fa_co == NULL){
|
||||||
cligen_ph_workpoint_set(ph, fa.fa_co);
|
clicon_err(OE_PLUGIN, ENOENT, "No such cligen object found %s", api_path);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
cligen_ph_workpoint_set(ph, fa.fa_co);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
if (api_path)
|
if (api_path)
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ clicon_data_cvec_get(clicon_handle h,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Set generic cligen varaibel vector (cvv) on the form <name>=<val> where <val> is cvv
|
/*! Set generic cligen variable vector (cvv) on the form <name>=<val> where <val> is cvv
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] name Name
|
* @param[in] name Name
|
||||||
* @param[in] cvv CLIgen variable vector (cvv) (malloced)
|
* @param[in] cvv CLIgen variable vector (cvv) (malloced)
|
||||||
|
|
@ -182,7 +182,7 @@ clicon_data_cvec_set(clicon_handle h,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Delete generic cligen varaibel vector (cvv)
|
/*! Delete generic cligen variable vector (cvv)
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] name Name
|
* @param[in] name Name
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ validate("Validate changes"), cli_validate();
|
||||||
commit("Commit the changes"), cli_commit();
|
commit("Commit the changes"), cli_commit();
|
||||||
quit("Quit"), cli_quit();
|
quit("Quit"), cli_quit();
|
||||||
show("Show a particular state of the system"){
|
show("Show a particular state of the system"){
|
||||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "xml", false, false);{
|
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||||
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, 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, "set ");
|
cli("Show configuration as CLI commands"), cli_auto_show("datamodel", "candidate", "cli", false, false, "set ");
|
||||||
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
|
netconf("Show configuration as netconf edit-config operation"), cli_auto_show("datamodel", "candidate", "netconf", false, false);
|
||||||
|
|
@ -105,25 +105,25 @@ fi
|
||||||
|
|
||||||
# First go down in structure and show config
|
# First go down in structure and show config
|
||||||
new "show top tree"
|
new "show top tree"
|
||||||
expectpart "$(echo "show config" | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
expectpart "$(echo "show config xml" | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
||||||
|
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
up
|
up
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "up show"
|
new "up show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
||||||
|
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table
|
edit table
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table; show"
|
new "edit table; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table>" "<parameter><name>a</name><value>42</value></parameter>$" --not-- '<table xmlns="urn:example:clixon">'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table>" "<parameter><name>a</name><value>42</value></parameter>$" --not-- '<table xmlns="urn:example:clixon">'
|
||||||
|
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table parameter a
|
edit table parameter a
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table parameter a; show"
|
new "edit table parameter a; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=a/>" "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=a/>" "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
|
||||||
|
|
@ -131,14 +131,14 @@ expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/par
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table
|
edit table
|
||||||
edit parameter a
|
edit parameter a
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table; edit parameter a; show"
|
new "edit table; edit parameter a; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
|
||||||
|
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table parameter a value 42
|
edit table parameter a value 42
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table parameter a value 42; show"
|
new "edit table parameter a value 42; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 --not-- '<table xmlns="urn:example:clixon">' "<parameter>" "<name>a</name>" "<value>42</value>"
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 --not-- '<table xmlns="urn:example:clixon">' "<parameter>" "<name>a</name>" "<value>42</value>"
|
||||||
|
|
@ -147,7 +147,7 @@ expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 --not-- '<table xmlns="urn
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table parameter a value 42
|
edit table parameter a value 42
|
||||||
top
|
top
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table parameter a value 42; top; show"
|
new "edit table parameter a value 42; top; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
||||||
|
|
@ -155,7 +155,7 @@ expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table parameter a
|
edit table parameter a
|
||||||
top
|
top
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table parameter a; top; show"
|
new "edit table parameter a; top; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
||||||
|
|
@ -165,7 +165,7 @@ expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table
|
edit table
|
||||||
up
|
up
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table; up; show"
|
new "edit table; up; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
||||||
|
|
@ -173,7 +173,7 @@ expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table parameter a
|
edit table parameter a
|
||||||
up
|
up
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table parameter a; up; show"
|
new "edit table parameter a; up; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table>" "<parameter><name>a</name><value>42</value></parameter>$" --not-- '<table xmlns="urn:example:clixon">'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table>" "<parameter><name>a</name><value>42</value></parameter>$" --not-- '<table xmlns="urn:example:clixon">'
|
||||||
|
|
@ -182,7 +182,7 @@ cat <<EOF > $fin
|
||||||
edit table parameter a
|
edit table parameter a
|
||||||
up
|
up
|
||||||
up
|
up
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table parameter a; up up; show"
|
new "edit table parameter a; up up; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
||||||
|
|
@ -191,7 +191,7 @@ cat <<EOF > $fin
|
||||||
edit table parameter a
|
edit table parameter a
|
||||||
up
|
up
|
||||||
edit parameter a
|
edit parameter a
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table parameter a; up; edit parameter a; show"
|
new "edit table parameter a; up; edit parameter a; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=a/>" "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=a/>" "<name>a</name><value>42</value>" --not-- '<table xmlns="urn:example:clixon">' "<parameter>"
|
||||||
|
|
@ -199,7 +199,7 @@ expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/par
|
||||||
# Create new field b, and remove it
|
# Create new field b, and remove it
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table parameter b
|
edit table parameter b
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit table parameter b; show"
|
new "edit table parameter b; show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=b/>" --not-- "<name>a</name><value>42</value>" '<table xmlns="urn:example:clixon">' "<parameter>"
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=b/>" --not-- "<name>a</name><value>42</value>" '<table xmlns="urn:example:clixon">' "<parameter>"
|
||||||
|
|
@ -208,7 +208,7 @@ cat <<EOF > $fin
|
||||||
edit table parameter b
|
edit table parameter b
|
||||||
set value 71
|
set value 71
|
||||||
up
|
up
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "set value 71"
|
new "set value 71"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table>" "<parameter><name>a</name><value>42</value></parameter><parameter><name>b</name><value>71</value></parameter>"
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table>" "<parameter><name>a</name><value>42</value></parameter><parameter><name>b</name><value>71</value></parameter>"
|
||||||
|
|
@ -217,7 +217,7 @@ cat <<EOF > $fin
|
||||||
edit table parameter a
|
edit table parameter a
|
||||||
top
|
top
|
||||||
edit table parameter b
|
edit table parameter b
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "edit parameter b show"
|
new "edit parameter b show"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=b/>" "<name>b</name><value>71</value>" --not-- "<parameter>"
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/parameter=b/>" "<name>b</name><value>71</value>" --not-- "<parameter>"
|
||||||
|
|
@ -225,7 +225,7 @@ expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "/clixon-example:table/par
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
edit table parameter b
|
edit table parameter b
|
||||||
delete value 17
|
delete value 17
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "delete value 71"
|
new "delete value 71"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "<name>b</name>" --not-- "<value>71</value>"
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 "<name>b</name>" --not-- "<value>71</value>"
|
||||||
|
|
@ -234,7 +234,7 @@ cat <<EOF > $fin
|
||||||
edit table
|
edit table
|
||||||
delete parameter b
|
delete parameter b
|
||||||
up
|
up
|
||||||
show config
|
show config xml
|
||||||
EOF
|
EOF
|
||||||
new "delete parameter b"
|
new "delete parameter b"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>a</name><value>42</value></parameter></table>$'
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ fi
|
||||||
cat <<EOF > $cfg
|
cat <<EOF > $cfg
|
||||||
<clixon-config xmlns="http://clicon.org/config">
|
<clixon-config xmlns="http://clicon.org/config">
|
||||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||||
|
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||||
|
|
@ -35,7 +36,7 @@ cat <<EOF > $cfg
|
||||||
<CLICON_CLI_GENMODEL_TYPE>VARS</CLICON_CLI_GENMODEL_TYPE>
|
<CLICON_CLI_GENMODEL_TYPE>VARS</CLICON_CLI_GENMODEL_TYPE>
|
||||||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||||
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
|
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
|
||||||
</clixon-config>
|
</clixon-config>
|
||||||
EOF
|
EOF
|
||||||
|
|
@ -58,6 +59,9 @@ module $APPNAME {
|
||||||
leaf i{
|
leaf i{
|
||||||
type string;
|
type string;
|
||||||
}
|
}
|
||||||
|
leaf iv{
|
||||||
|
type string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -66,13 +70,14 @@ EOF
|
||||||
|
|
||||||
cat <<EOF > $clidir/ex.cli
|
cat <<EOF > $clidir/ex.cli
|
||||||
CLICON_MODE="example";
|
CLICON_MODE="example";
|
||||||
CLICON_PROMPT="%U@%H> ";
|
CLICON_PROMPT="%U@%H %W> ";
|
||||||
|
|
||||||
# Manual command form where a sub-mode is created from @datamodel
|
# Manual command form where a sub-mode is created from @datamodel
|
||||||
# It gives: cvv eg:
|
# It gives: cvv eg:
|
||||||
# 0 : cmd = parameter 123
|
# 0 : cmd = parameter 123
|
||||||
# 1 : string = "123"
|
# 1 : string = "123"
|
||||||
enter <string>, cli_auto_sub_enter("datamodel", "/example:table/parameter=%s/index=%s/", "x");
|
enter0 <string>, cli_auto_sub_enter("datamodel", "/example:table/parameter=%s/");
|
||||||
|
enter1 <string>, cli_auto_sub_enter("datamodel", "/example:table/parameter=%s/index=%s/", "p1");
|
||||||
leave, cli_auto_top("datamodel", "candidate");
|
leave, cli_auto_top("datamodel", "candidate");
|
||||||
|
|
||||||
# Autocli syntax tree operations
|
# Autocli syntax tree operations
|
||||||
|
|
@ -87,8 +92,25 @@ delete("Delete a configuration item") {
|
||||||
all("Delete whole candidate configuration"), delete_all("candidate");
|
all("Delete whole candidate configuration"), delete_all("candidate");
|
||||||
}
|
}
|
||||||
show("Show a particular state of the system"){
|
show("Show a particular state of the system"){
|
||||||
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);
|
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", true, false);{
|
||||||
|
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF > $dir/startup_db
|
||||||
|
<config>
|
||||||
|
<table xmlns="urn:example:clixon">
|
||||||
|
<parameter>
|
||||||
|
<name>p1</name>
|
||||||
|
<value>42</value>
|
||||||
|
<index>
|
||||||
|
<i>i1</i>
|
||||||
|
<iv>abc</iv>
|
||||||
|
</index>
|
||||||
|
</parameter>
|
||||||
|
</table>
|
||||||
|
</config>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
new "test params: -f $cfg"
|
new "test params: -f $cfg"
|
||||||
|
|
@ -98,21 +120,37 @@ if [ $BE -ne 0 ]; then
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err
|
err
|
||||||
fi
|
fi
|
||||||
new "start backend -s init -f $cfg"
|
new "start backend -s startup -f $cfg"
|
||||||
start_backend -s init -f $cfg
|
start_backend -s startup -f $cfg
|
||||||
|
|
||||||
new "waiting"
|
new "waiting"
|
||||||
wait_backend
|
wait_backend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat <<EOF > $fin
|
cat <<EOF > $fin
|
||||||
enter a
|
enter0 p1 # table/parameter=p1
|
||||||
|
show config xml
|
||||||
leave
|
leave
|
||||||
EOF
|
EOF
|
||||||
new "enter leave"
|
new "enter; show config; leave"
|
||||||
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 'enter a' 'leave'
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 'enter0 p1' 'leave' '<name>p1</name><value>42</value><index><i>i1</i><iv>abc</iv></index>' --not-- '<table>' '<parameter>'
|
||||||
|
|
||||||
# XXX much more
|
cat <<EOF > $fin
|
||||||
|
enter0 p1 # table/parameter=p1
|
||||||
|
leave
|
||||||
|
show config xml
|
||||||
|
EOF
|
||||||
|
new "enter; leave; show config"
|
||||||
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 'enter0 p1' 'leave' '<table xmlns="urn:example:clixon"><parameter><name>p1</name><value>42</value><index><i>i1</i><iv>abc</iv></index></parameter></table>'
|
||||||
|
|
||||||
|
cat <<EOF > $fin
|
||||||
|
enter0 p1 # table/parameter=p1
|
||||||
|
set set index i2 iv def
|
||||||
|
leave
|
||||||
|
show config xml
|
||||||
|
EOF
|
||||||
|
new "set p1 i2"
|
||||||
|
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>p1</name><value>42</value><index><i>i1</i><iv>abc</iv></index></parameter></table>'
|
||||||
|
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
# Check if premature kill
|
# Check if premature kill
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue