FAQ and example

This commit is contained in:
Olof hagsand 2016-02-23 22:49:22 +01:00
parent 33fac8a4c6
commit 554c1cb9de
7 changed files with 124 additions and 6 deletions

View file

@ -48,7 +48,7 @@ all: $(PLUGINS) $(APPNAME).conf
CLISPECS = routing_cli.cli
YANGSPECS = $(APPNAME).yang
#YANGSPECS = $(APPNAME).yang
YANGSPECS += ietf-yang-types@2013-07-15.yang
YANGSPECS += ietf-inet-types@2013-07-15.yang
YANGSPECS += ietf-interfaces@2014-05-08.yang

View file

@ -55,3 +55,31 @@ plugin_init(clicon_handle h)
return 0;
}
/*! Example cli function */
int
mycallback(clicon_handle h, cvec *cvv, cg_var *arg)
{
int retval = -1;
cxobj *xt = NULL;
yang_spec *yspec;
cg_var *myvar;
/* Access cligen callback variables */
myvar = cvec_find(cvv, "var"); /* get a cligen variable from vector */
cli_output(stderr, "%s: %d\n", __FUNCTION__, cv_int32_get(myvar)); /* get int value */
cli_output(stderr, "arg = %s\n", cv_string_get(arg)); /* get string value */
/* Show eth0 interfaces config using XPATH */
yspec = clicon_dbspec_yang(h);
if (xmldb_get(clicon_candidate_db(h),
"/interfaces/interface[name=eth0]",
yspec,
&xt) < 0)
goto done;
clicon_xml2file(stdout, xt, 0, 1);
retval = 0;
done:
if (xt)
xml_free(xt);
return retval;
}

View file

@ -2,6 +2,7 @@
# Common CLI syntax for both server and PMNode operatio mode
CLICON_MODE="routing";
CLICON_PROMPT="%U@%H> ";
CLICON_PLUGIN="routing_cli";
# Note, when switching to PT, change datamodel to only @datamodel
#set @datamodel:ietf-routing, cli_merge();
@ -43,3 +44,4 @@ load("Load configuration from XML file") <filename:string>("Filename (local file
replace("Replace candidate with file contents"), load_config_file("filename replace");
merge("Merge file with existent candidate"), load_config_file("filename merge");
}
example("This is a comment") <var:int32>("Just a random number"), mycallback("myarg");