Main examples uses new auto-mode
This commit is contained in:
parent
a77cd27abb
commit
f07f291bdd
3 changed files with 28 additions and 35 deletions
|
|
@ -303,7 +303,7 @@ cli_auto_show(clicon_handle h,
|
||||||
cvec *cvv,
|
cvec *cvv,
|
||||||
cvec *argv)
|
cvec *argv)
|
||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = -1;
|
||||||
char *treename;
|
char *treename;
|
||||||
char *db;
|
char *db;
|
||||||
char *api_path = NULL;
|
char *api_path = NULL;
|
||||||
|
|
@ -318,7 +318,7 @@ cli_auto_show(clicon_handle h,
|
||||||
yang_stmt *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *xerr;
|
cxobj *xerr;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
cxobj **vec;
|
cxobj **vec = NULL;
|
||||||
size_t veclen;
|
size_t veclen;
|
||||||
int i;
|
int i;
|
||||||
int isroot;
|
int isroot;
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,24 @@
|
||||||
|
|
||||||
# Clixon example specification
|
# Clixon example specification
|
||||||
CLICON_MODE="example";
|
CLICON_MODE="example";
|
||||||
CLICON_PROMPT="%U@%H> ";
|
CLICON_PROMPT="%U@%H %W> ";
|
||||||
CLICON_PLUGIN="example_cli";
|
CLICON_PLUGIN="example_cli";
|
||||||
|
|
||||||
# Note, when switching to PT, change datamodel to only @datamodel
|
# Autocli syntax tree operations
|
||||||
set @datamodel, cli_set();
|
edit @datamodel, cli_auto_edit("datamodel", "candidate");
|
||||||
merge @datamodel, cli_merge();
|
up, cli_auto_up("datamodel", "candidate");
|
||||||
create @datamodel, cli_create();
|
top, cli_auto_top("datamodel", "candidate");
|
||||||
delete("Delete a configuration item") @datamodel, cli_del();
|
set @datamodel, cli_auto_set();
|
||||||
|
merge @datamodel, cli_auto_merge();
|
||||||
|
create @datamodel, cli_auto_create();
|
||||||
|
delete("Delete a configuration item") {
|
||||||
|
@datamodel, cli_auto_del();
|
||||||
|
all("Delete whole candidate configuration"), delete_all("candidate");
|
||||||
|
}
|
||||||
|
|
||||||
validate("Validate changes"), cli_validate();
|
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();
|
||||||
delete("Delete a configuration item") all("Delete whole candidate configuration"), delete_all("candidate");
|
|
||||||
|
|
||||||
no("Negate or remove") debug("Debugging parts of the system"), cli_debug_cli((int32)0);
|
no("Negate or remove") debug("Debugging parts of the system"), cli_debug_cli((int32)0);
|
||||||
debug("Debugging parts of the system"), cli_debug_cli((int32)1);{
|
debug("Debugging parts of the system"), cli_debug_cli((int32)1);{
|
||||||
|
|
@ -67,27 +72,15 @@ show("Show a particular state of the system"){
|
||||||
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);
|
||||||
}
|
}
|
||||||
state("Show configuration and state"), cli_show_config_state("running", "text", "/");{
|
configuration("Show configuration"), cli_auto_show("datamodel", "candidate", "text", false, false);{
|
||||||
xml("Show configuration and state as XML"), cli_show_config_state("running", "xml", "/");{
|
xml("Show configuration as XML"), cli_auto_show("datamodel", "candidate", "xml", false, false);
|
||||||
@datamodel, cli_show_auto_state("running", "xml");
|
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);
|
||||||
|
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_config("candidate", "text", "/");{
|
state("Show configuration and state"), cli_auto_show("datamodel", "running", "text", false, true); {
|
||||||
xml("Show configuration as XML"), cli_show_config("candidate", "xml", "/");{
|
xml("Show configuration and state as XML"), cli_auto_show("datamodel", "running", "xml", false, true);
|
||||||
@datamodel, cli_show_auto("candidate", "xml");
|
|
||||||
}
|
|
||||||
cli("Show configuration as CLI commands"), cli_show_config("candidate", "cli", "/", 0, "set ");{
|
|
||||||
@datamodel, cli_show_auto("candidate", "cli", "set ");
|
|
||||||
}
|
|
||||||
netconf("Show configuration as netconf edit-config operation"), cli_show_config("candidate", "netconf", "/");{
|
|
||||||
@datamodel, cli_show_auto("candidate", "netconf");
|
|
||||||
}
|
|
||||||
text("Show configuration as text"), cli_show_config("candidate","text","/");{
|
|
||||||
@datamodel, cli_show_auto("candidate", "text");
|
|
||||||
}
|
|
||||||
json("Show configuration as JSON"), cli_show_config("candidate", "json", "/");{
|
|
||||||
@datamodel, cli_show_auto("candidate", "json");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
# Magic line must be first in script (see README.md)
|
# Magic line must be first in script (see README.md)
|
||||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
|
fin=$dir/fin
|
||||||
|
|
||||||
# Which format to use as datastore format internally
|
# Which format to use as datastore format internally
|
||||||
: ${format:=xml}
|
: ${format:=xml}
|
||||||
|
|
@ -160,13 +161,12 @@ new "restconf get $perfreq single reqs"
|
||||||
done } 2>&1 | awk '/real/ {print $2}'
|
done } 2>&1 | awk '/real/ {print $2}'
|
||||||
|
|
||||||
# CLI get
|
# CLI get
|
||||||
|
cat <<EOF >> $fin
|
||||||
|
edit interfaces a foo b interface e1
|
||||||
|
show state xml
|
||||||
|
EOF
|
||||||
new "cli get test single req"
|
new "cli get test single req"
|
||||||
expectfn "$clixon_cli -1 -1f $cfg -l o show state xml interfaces a foo b interface e1" 0 '^<interface>
|
expectpart "$($clixon_cli -F $fin -f $cfg)" 0 "<name>e1</name><type>ex:eth</type><enabled>true</enabled><status>up</status>$"
|
||||||
<name>e1</name>
|
|
||||||
<type>eth</type>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<status>up</status>
|
|
||||||
</interface>$'
|
|
||||||
|
|
||||||
new "cli get $perfreq single reqs"
|
new "cli get $perfreq single reqs"
|
||||||
{ time -p for (( i=0; i<$perfreq; i++ )); do
|
{ time -p for (( i=0; i<$perfreq; i++ )); do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue