The Clixon example has changed name from routing to example affecting all config files, plugins, tests, etc.

This commit is contained in:
Olof hagsand 2018-04-02 13:18:47 +02:00
parent 0e52e86c0f
commit 6ed769e082
29 changed files with 187 additions and 182 deletions

View file

@ -38,7 +38,7 @@ bindir = @bindir@
includedir = @includedir@
datarootdir = @datarootdir@
APPNAME = routing
APPNAME = example
CC = @CC@
CFLAGS = @CFLAGS@ -rdynamic -fPIC
@ -53,13 +53,12 @@ PLUGINS = $(BE_PLUGIN) $(CLI_PLUGIN) $(NETCONF_PLUGIN) $(RESTCONF_PLUGIN)
all: $(PLUGINS)
# Note: clixon.mk has a rule for:
# $(APPNAME.conf)
# Note: clixon.mk has rules for clixon_DBSPECDIR, clixon_SYSCONFDIR, etc used below
-include $(DESTDIR)$(datarootdir)/clixon/clixon.mk
CLISPECS = routing_cli.cli
CLISPECS = $(APPNAME)_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
@ -68,28 +67,27 @@ YANGSPECS += ietf-routing@2014-10-26.yang
YANGSPECS += ietf-ipv4-unicast-routing@2014-10-26.yang
YANGSPECS += ietf-ipv6-unicast-routing@2014-10-26.yang
YANGSPECS += ietf-ipsec@2016-03-09.yang
YANGSPECS += example.yang
# Backend plugin
BE_SRC = routing_backend.c
BE_SRC = $(APPNAME)_backend.c
BE_OBJ = $(BE_SRC:%.c=%.o)
$(BE_PLUGIN): $(BE_OBJ)
$(CC) -Wall -shared -o $@ -lc $<
# CLI frontend plugin
CLI_SRC = routing_cli.c
CLI_SRC = $(APPNAME)_cli.c
CLI_OBJ = $(CLI_SRC:%.c=%.o)
$(CLI_PLUGIN): $(CLI_OBJ)
$(CC) -Wall -shared -o $@ -lc $^
# NETCONF frontend plugin
NETCONF_SRC = routing_netconf.c
NETCONF_SRC = $(APPNAME)_netconf.c
NETCONF_OBJ = $(NETCONF_SRC:%.c=%.o)
$(NETCONF_PLUGIN): $(NETCONF_OBJ)
$(CC) -Wall -shared -o $@ -lc $^
# RESTCONF frontend plugin
RESTCONF_SRC = routing_restconf.c
RESTCONF_SRC = $(APPNAME)_restconf.c
RESTCONF_OBJ = $(RESTCONF_SRC:%.c=%.o)
$(RESTCONF_PLUGIN): $(RESTCONF_OBJ)
$(CC) -Wall -shared -o $@ -lc $^

View file

@ -1,4 +1,19 @@
# Clixon yang routing example
# Clixon example
This directory contains a Clixon example which includes a simple
routing example. It contains the following files:
* example.xml The configuration file. See yang/clixon-config@<date>.yang for all available fields.
* example.yang The yang spec of the example. It mainly includes ietf routing and IP modules.
* example_cli.cli CLIgen specification.
* example_cli.c CLI callback plugin containing functions called in the cli file above: a generic callback (`mycallback`) and an RPC (`fib_route_rpc`).
* example_backend.c Backend callback plugin including example of:
* transaction callbacks (validate/commit),
* notification,
* rpc handler
* state-data handler, ie non-config data
* example_restconf.c Restconf callback plugin containing an HTTP basic authentication callback
* example_netconf.c Netconf callback plugin
* Makefile.in Example makefile where plugins are built and installed
## Compile and run
```
@ -7,15 +22,23 @@
```
Start backend:
```
clixon_backend -f /usr/local/etc/routing.xml -I
clixon_backend -f /usr/local/etc/example.xml -I
```
Edit cli:
```
clixon_cli -f /usr/local/etc/routing.xml
clixon_cli -f /usr/local/etc/example.xml
```
Send netconf command:
```
clixon_netconf -f /usr/local/etc/routing.xml
clixon_netconf -f /usr/local/etc/example.xml
```
Start clixon restconf daemon
```
> sudo su -c "/www-data/clixon_restconf -f /usr/local/etc/example.xml " -s /bin/sh www-data
```
Send restconf command
```
curl -G http://127.0.0.1/restconf/data
```
## Setting data example using netconf
@ -114,7 +137,7 @@ plugin_init(clicon_handle h)
Netconf <get> and restconf GET also returns state data, in contrast to
config data.
p
In YANG state data is specified with "config false;". In the example, interface-state is state data.
To return state data, you need to write a backend state data callback

18
example/example.xml Normal file
View file

@ -0,0 +1,18 @@
<config>
<CLICON_CONFIGFILE>/usr/local/etc/example.xml</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>/usr/local/share/example/yang</CLICON_YANG_DIR>
<CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
<CLICON_CLI_MODE>example</CLICON_CLI_MODE>
<CLICON_BACKEND_DIR>/usr/local/lib/example/backend</CLICON_BACKEND_DIR>
<CLICON_NETCONF_DIR>/usr/local/lib/example/netconf</CLICON_NETCONF_DIR>
<CLICON_RESTCONF_DIR>/usr/local/lib/example/restconf</CLICON_RESTCONF_DIR>
<CLICON_CLI_DIR>/usr/local/lib/example/cli</CLICON_CLI_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
<CLICON_SOCK>/usr/local/var/example/example.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/example/example.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/example</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
</config>

View file

@ -6,9 +6,6 @@ module example {
import ietf-routing {
prefix rt;
}
import ietf-netconf-acm {
prefix nacm; /* See RFC 6536 */
}
description
"Example code that includes ietf-ip and ietf-routing";
leaf basic_auth{

View file

@ -1,7 +1,7 @@
# Common CLI syntax for both server and PMNode operatio mode
CLICON_MODE="routing";
CLICON_MODE="example";
CLICON_PROMPT="%U@%H> ";
CLICON_PLUGIN="routing_cli";
CLICON_PLUGIN="example_cli";
# Note, when switching to PT, change datamodel to only @datamodel
set @datamodel:example, cli_set();

View file

@ -1,17 +0,0 @@
# Main YANG module first parsed by parser (in CLICON_YANG_DIR). eg clicon.yang.
# Startup CLI mode. This should match the CLICON_MODE in your startup clispec file
CLICON_CLI_MODE routing
# Option used to construct initial yang file:
# <module>[@<revision>]
#CLICON_YANG_MODULE_MAIN ietf-ip
CLICON_YANG_MODULE_MAIN example
# Option used to construct initial yang file:
# <module>[@<revision>]
#CLICON_YANG_MODULE_REVISION 2014-06-16
# Set to 0 if you want CLI to wrap to next line.
# Set to 1 if you want CLI to scroll sideways when approaching right margin
CLICON_CLI_LINESCROLLING 0

View file

@ -1,18 +0,0 @@
<config>
<CLICON_CONFIGFILE>/usr/local/etc/routing.xml</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>/usr/local/share/routing/yang</CLICON_YANG_DIR>
<CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
<CLICON_CLI_MODE>routing</CLICON_CLI_MODE>
<CLICON_BACKEND_DIR>/usr/local/lib/routing/backend</CLICON_BACKEND_DIR>
<CLICON_NETCONF_DIR>/usr/local/lib/routing/netconf</CLICON_NETCONF_DIR>
<CLICON_RESTCONF_DIR>/usr/local/lib/routing/restconf</CLICON_RESTCONF_DIR>
<CLICON_CLI_DIR>/usr/local/lib/routing/cli</CLICON_CLI_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/routing/clispec</CLICON_CLISPEC_DIR>
<CLICON_SOCK>/usr/local/var/routing/routing.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/routing/routing.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/routing</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
</config>