...
Loading Network Configurations
REST API
The NetworkConfigWebResource
implements the REST calls for the network configuration subsystem. Its functionalities will eventually replace that of ConfigWebResource
.
The following example uses the REST API to upload a configuration file:
Code Block | ||
---|---|---|
| ||
curl --user onos:rocks -X POST -H "Content-Type: application/json" http://192.168.56.111:8181/onos/v1/network/configuration/ -d @/tmp/cfg.json |
The above assumes a running instance at 192.168.56.111, and a configuration file at /tmp/cfg.json. These should be replaced with appropriate values.
Likewise, the user:password combination might differ with your setup; Other common values are karaf:karaf and onos:onos.
onos-netcfg shell script
There is a shell script that wraps the REST API to provide a more convenient mechanism to upload configuration from the command line (i.e. from outside ONOS).
For example, the same configuration above can be uploaded using:
Code Block |
---|
onos-netcfg 192.168.56.111 /tmp/cfg.json |
The script also accepts a third argument that allows you to upload smaller chunks of config identified by subject_key/subject/config_key:
Code Block |
---|
onos-netcfg $OC1 /tmp/basic.json /devices/of:0000000000000001/basic |
Here the /tmp/basic.json script would just contain the payload of the basic config key, for example:
Code Block |
---|
{
"driver" : "softrouter"
} |
Network Configuration Loader
The NetworkConfigLoader
reads JSON files from a known location and attempts to load them as network configurations at system startup.
Currently, a file named network-cfg.json is picked up from ${ONOS_ROOT}/tools/package/config/ and placed in ${KARAF_ROOT}../config/ at deployment. The filename and paths are currently fixed. When the remote instance boots, its network configuration loader runtime will read this file.
The Network Configuration Loader is implemented as a listener for Network Configuration events (NetworkConfigEvent
s). It attempts to use the known Config
s in order to generate or update entities in the network model once it is notified that the Config
s are available.