...
Config
subclasses implement the tunables for a subject as a set of getters and setters (attribute accessors) to JSON object constructs (ObjectNodes
). Example: AnOpticalPortConfig
is defined as:Code Block language java public class OpticalPortConfig extends Config<ConnectPoint>
meaning that it manipulates the configurations associated with
ConnectPoint
subjects (optical ports). Some of its attribute accessors include the port’s string and numeric names, and the number of channels that the port supports.
SubjectFactory
ties a subject to its subject key, and generates objects that represent the subject. Example: the factory that generatesConnectPoints
is instantiated as:Code Block language java public static final SubjectFactory<ConnectPoint> CONNECT_POINT_SUBJECT_FACTORY = new SubjectFactory<ConnectPoint>(ConnectPoint.class, "ports") { @Override public ConnectPoint createSubject(String key) { return ConnectPoint.deviceConnectPoint(key); } };
meaning that the key for the JSON field containing port information is keyed on string “ports”, and the factory can create
ConnectPoint
s from a “deviceId:port” string (the argument tocreateSubject
).
...
Using Network Configuration Services
- Via CLI or REST API
- By loading a file from a fixed location using the
- ConfigFactory required for what needs to be parsed
- ConfigFactory registered with
NetworkConfigManager
, either by adding it toBasicNetworkConfigs
which will load it when it starts up, or by manually invokingNetworkConfigManager.registerConfigFactory()
from the application - Register application as a
NetworkConfigListener
- Via CLI or REST API By loading a file from a fixed location using the Network Configuration Loader
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. They should be replaced with appropriate values.
Likewise, the user:password vaues may differ with your setup; Other common values are karaf:karaf and onos:onos.
Network Configuration Loader
The NetworkConfigLoader
reads JSON files from a known location and attempts to load them as network configurations.
Currently, a file named network-cfg.json is picked up from ${ONOS_ROOT}/tools/package/config/ and placed in ${KARAF_ROOT}../config/ (currently fixed) at deployment. 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 knwon Config
s in order to generate or update entities in the network model once it is notified that the Config
s are available.