* Restconf top-level operations GET root resource modified to comply with
RFC 8040 Sec 3.1
* non-pretty print remove all spaces, eg `{"operations":{"clixon-example:client-rpc":[null]`
* Replaced JSON `null` with `[null]` as proper empty JSON leaf/leaf-list encoding.
* [Cannot write to config using restconf example #91](https://github.com/clicon/clixon/issues/91)
* Updated restconf documentation (the example was wrong)
* [clixon-lib yang revision file name update #92](https://github.com/clicon/clixon/issues/92)
* Clixon-lib yang file had conflicting filename and internal yang revision.
* This was only detected in the use-case when a whole dir was loaded.
* Inserted sanity check in all yang parse routines.
* Committed updated clixon-lib yang file that triggered the error
This commit is contained in:
parent
a8906fd0bd
commit
6df434093e
12 changed files with 230 additions and 192 deletions
|
|
@ -23,57 +23,62 @@ Download and start nginx. For example on ubuntu:
|
|||
|
||||
Define nginx config file: /etc/nginx/sites-available/default
|
||||
```
|
||||
server {
|
||||
...
|
||||
location /restconf {
|
||||
fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
|
||||
include fastcgi_params;
|
||||
server {
|
||||
...
|
||||
location /restconf {
|
||||
fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Start nginx daemon
|
||||
```
|
||||
sudo /etc/init.d nginx start
|
||||
sudo /etc/init.d nginx start
|
||||
```
|
||||
Alternatively, start it via systemd:
|
||||
```
|
||||
sudo /etc/init.d/nginx start
|
||||
sudo systemctl start start.service
|
||||
sudo systemctl start nginx.service
|
||||
```
|
||||
|
||||
Start clixon backend daemon (if not already started)
|
||||
```
|
||||
sudo clixon_backend -s init -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
|
||||
|
||||
sudo su -c "/www-data/clixon_restconf -f /usr/local/etc/example.xml " -s /bin/sh www-data
|
||||
```
|
||||
|
||||
Make restconf calls with curl
|
||||
Make restconf calls with curl (or other http client). Example of writing a new interface specification:
|
||||
```
|
||||
> curl -G http://127.0.0.1/restconf/data/ietf-interfaces:interfaces
|
||||
[
|
||||
curl -sX PUT http://localhost/restconf/data/ietf-interfaces:interfaces -H 'Content-Type: application/yang-data+json' -d '{"ietf-interfaces:interfaces":{"interface":{"name":"eth1","type":"clixon-example:eth","enabled":true}}}'
|
||||
```
|
||||
|
||||
Get the data
|
||||
```
|
||||
curl -X GET http://127.0.0.1/restconf/data/ietf-interfaces:interfaces
|
||||
{
|
||||
"ietf-interfaces:interfaces": {
|
||||
"interface":[
|
||||
"interface": [
|
||||
{
|
||||
"name": "eth9",
|
||||
"type": "ex:eth",
|
||||
"enabled": true,
|
||||
}
|
||||
"name": "eth1",
|
||||
"type": "clixon-example:eth",
|
||||
"enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
Get the type of a specific interface:
|
||||
```
|
||||
> curl -G http://127.0.0.1/restconf/data/interfaces/interface=eth9/type
|
||||
{
|
||||
"ietf-interfaces:type": "eth"
|
||||
}
|
||||
```
|
||||
Example of writing a new interfaces specification:
|
||||
```
|
||||
curl -sX PUT http://localhost/restconf/data -d '{"ietf-interfaces:interfaces":{"interface":{"name":"eth1","type":"ex:eth","enabled":true}}}'
|
||||
curl -X GET http://127.0.0.1/restconf/data/ietf-interfacesinterfaces/interface=eth1/type
|
||||
{
|
||||
"ietf-interfaces:type": "clixon-example:eth"
|
||||
}
|
||||
```
|
||||
|
||||
## Streams
|
||||
|
|
@ -83,7 +88,7 @@ RFC8040 Section 6 using SSE. One native and one using Nginx
|
|||
nchan. The Nchan alternaitve is described in the
|
||||
next section.
|
||||
|
||||
The (example)[../../example/README.md] creates an EXAMPLE stream.
|
||||
The [example](../../example/main/README.md) creates an EXAMPLE stream.
|
||||
|
||||
Set the Clixon configuration options:
|
||||
```
|
||||
|
|
|
|||
|
|
@ -449,7 +449,10 @@ api_operations_get(clicon_handle h,
|
|||
cprintf(cbx, "<operations>");
|
||||
break;
|
||||
case YANG_DATA_JSON:
|
||||
cprintf(cbx, "{\"operations\": {");
|
||||
if (pretty)
|
||||
cprintf(cbx, "{\"operations\": {\n");
|
||||
else
|
||||
cprintf(cbx, "{\"operations\":{");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -467,14 +470,19 @@ api_operations_get(clicon_handle h,
|
|||
cprintf(cbx, "<%s xmlns=\"%s\"/>", yang_argument_get(yc), namespace);
|
||||
break;
|
||||
case YANG_DATA_JSON:
|
||||
if (i++)
|
||||
if (i++){
|
||||
cprintf(cbx, ",");
|
||||
cprintf(cbx, "\"%s:%s\": null", yang_argument_get(ymod), yang_argument_get(yc));
|
||||
if (pretty)
|
||||
cprintf(cbx, "\n\t");
|
||||
}
|
||||
if (pretty)
|
||||
cprintf(cbx, "\"%s:%s\": [null]", yang_argument_get(ymod), yang_argument_get(yc));
|
||||
else
|
||||
cprintf(cbx, "\"%s:%s\":[null]", yang_argument_get(ymod), yang_argument_get(yc));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
switch (media_out){
|
||||
|
|
@ -482,7 +490,10 @@ api_operations_get(clicon_handle h,
|
|||
cprintf(cbx, "</operations>");
|
||||
break;
|
||||
case YANG_DATA_JSON:
|
||||
cprintf(cbx, "}}");
|
||||
if (pretty)
|
||||
cprintf(cbx, "}\n}");
|
||||
else
|
||||
cprintf(cbx, "}}");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue