clixon/apps/restconf
Olof hagsand ea77e7f02d * YANG Features
* Yang 1.1 feature and if-feature according to RFC 7950 7.20.1 and 7.20.2.
  * See https://github.com/clicon/clixon/issues/41
  * Features are declared via CLICON_FEATURE in the configuration file.
  * logical combination of features not implemented, eg if-feature "not foo or
* Identity without any identityref:s caused SEGV
2018-10-10 20:11:20 +02:00
..
clixon_restconf.h mv api_return_err to restconf_lib.c 2018-04-08 16:07:24 +00:00
Makefile.in Event stream discovery support 2018-09-23 17:45:22 +02:00
README.md div edits 2018-10-03 20:20:26 +02:00
restconf_lib.c * Experimental NACM RFC8341 Network Configuration Access Control Model. 2018-04-19 22:44:15 +02:00
restconf_lib.h * Major rewrite of event streams 2018-09-30 14:51:30 +02:00
restconf_main.c * YANG Features 2018-10-10 20:11:20 +02:00
restconf_methods.c * clixon_restconf and clixon_netconf now take -D <level> as command-line option\ 2018-08-03 13:24:41 +02:00
restconf_methods.h * Restructure and more generic plugin API (cli,backend,restconf,netconf) 2018-04-02 10:38:53 +02:00
restconf_stream.c * Major rewrite of event streams 2018-09-30 14:51:30 +02:00
restconf_stream.h Event stream discovery support 2018-09-23 17:45:22 +02:00

Clixon Restconf

Installation using Nginx

Ensure www-data is member of the CLICON_SOCK_GROUP (default clicon). If not, add it:

  sudo usermod -a -G clicon www-data

This implementation uses FastCGI, see http://www.mit.edu/~yandros/doc/specs/fcgi-spec.html.

Download and start nginx. For example on ubuntu:

  sudo apt install ngnix

Define nginx config file: /etc/nginx/sites-available/default

server {
  ...
  location /restconf {
     fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
     include fastcgi_params;
  }
  location /stream { # for restconf notifications
     fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
     include fastcgi_params;
     proxy_http_version 1.1;
     proxy_set_header Connection "";
  }
}

Start nginx daemon

sudo /etc/init.d nginx start

Alternatively, start it via systemd:

sudo /etc/init.d/nginx start
sudo systemctl start start.service

Start clixon restconf daemon

olof@vandal> sudo su -c "/www-data/clixon_restconf -f /usr/local/etc/example.xml " -s /bin/sh www-data

Make restconf calls with curl

olof@vandal> curl -G http://127.0.0.1/restconf/data/interfaces
[
  {
    "interfaces": {
      "interface":[
        {
          "name": "eth0",
          "type": "eth",
          "enabled": "true",
          "name": "eth9",
          "type": "eth",
          "enabled": "true"
         }
      ]
    }
  }
]
olof@vandal> curl -G http://127.0.0.1/restconf/data/interfaces/interface/name=eth9/type
[
  {
    "type": "eth" 
  }
]

curl -sX POST -d '{"interfaces":{"interface":{"name":"eth1","type":"eth","enabled":"true"}}}' http://localhost/restconf/data

Nginx Nchan for streams

Restconf notification event streams needs a server-side push package. Clixon has used Nchan (nchan.io) for this

Download and install nchan, see nchan.io, Install section.

Debugging

Start the restconf fastcgi program with debug flag:

sudo su -c "/www-data/clixon_restconf -D 1 -f /usr/local/etc/example.xml" -s /bin/sh www-data

Look at syslog:

tail -f /var/log/syslog | grep clixon_restconf

Send command:

curl -G http://127.0.0.1/restconf/data/*

You can also run restconf in a debugger.

sudo gdb /www-data/clixon_restconf
(gdb) run -D 1 -f /usr/local/etc/example.xml

but you need to ensure /www-data/fastcgi_restconf.sock has the following access:

rwxr-xr-x 1 www-data www-data 0 sep 22 11:46 /www-data/fastcgi_restconf.sock