state doc
This commit is contained in:
parent
14a98d13a4
commit
96f341d8fc
2 changed files with 23 additions and 29 deletions
30
doc/FAQ.md
30
doc/FAQ.md
|
|
@ -207,32 +207,6 @@ Netconf <get> and restconf GET also returns state data, in contrast to
|
||||||
config data. In YANG state data is specified with "config false;".
|
config data. In YANG state data is specified with "config false;".
|
||||||
|
|
||||||
To return state data, you need to write a backend state data callback
|
To return state data, you need to write a backend state data callback
|
||||||
with the name "plugin_statedata" where you return an XML tree.
|
with the name "plugin_statedata()" where you return an XML tree.
|
||||||
|
|
||||||
A static example of returning state data is as follows, although a real example would poll or get the interface counters via a system call, as well as use the "xpath" argument to identify the requested state data.
|
Please look at the example for an example on how to write a state data callback.
|
||||||
|
|
||||||
```
|
|
||||||
int
|
|
||||||
plugin_statedata(clicon_handle h,
|
|
||||||
char *xpath,
|
|
||||||
cxobj *xstate)
|
|
||||||
{
|
|
||||||
int retval = -1;
|
|
||||||
cxobj **xvec = NULL;
|
|
||||||
|
|
||||||
if ((xml_parse("<interfaces-state><interface>"
|
|
||||||
"<name>eth0</name>"
|
|
||||||
"<type>eth</type>"
|
|
||||||
"<admin-status>up</admin-status>"
|
|
||||||
"<oper-status>up</oper-status>"
|
|
||||||
"<if-index>42</if-index>"
|
|
||||||
"<speed>1000000000</speed>"
|
|
||||||
"</interface></interfaces-state>", xstate)) < 0)
|
|
||||||
goto done;
|
|
||||||
retval = 0;
|
|
||||||
done:
|
|
||||||
if (xvec)
|
|
||||||
free(xvec);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,28 @@ cli> downcall "This is a string"
|
||||||
This is a string
|
This is a string
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## State data
|
||||||
|
|
||||||
|
Netconf <get> and restconf GET also returns state data, in contrast to
|
||||||
|
config data.
|
||||||
|
|
||||||
|
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
|
||||||
|
with the name "plugin_statedata" where you return an XML tree with
|
||||||
|
state. This is then merged with config data by the system.
|
||||||
|
|
||||||
|
pA static example of returning state data is in the example. Note that
|
||||||
|
a real example would poll or get the interface counters via a system
|
||||||
|
call, as well as use the "xpath" argument to identify the requested
|
||||||
|
state data.
|
||||||
|
|
||||||
|
|
||||||
## Run as docker container
|
## Run as docker container
|
||||||
```
|
```
|
||||||
cd docker
|
cd docker
|
||||||
# look in README
|
# look in README
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue