io.lighty.modules.northbound.restconf.community.impl.CommunityRestConf
provides northbound interface to
running Opendaylight services via HTTP and WebSocket protocol. CommunityRestConf requires initialized services
from LightyController. CommunityRestConf starts it's own servlet container and WebsSocket end-point, using
two ports.
This plugin requires LightyController instance in order to run. To use RESTCONF in your project:
- Add dependency in your pom.xml file.
<dependency>
<groupId>io.lighty.modules</groupId>
<artifactId>lighty-restconf-nb-community</artifactId>
<version>10.0.1</version>
</dependency>
- Initialize and start an instance of CommunityRestConf in your code:
RestConfConfiguration restConfConfig
= RestConfConfigUtils.getDefaultRestConfConfiguration();
CommunityRestConf communityRestConf = CommunityRestConfBuilder
.from(restConfConfig)
.build();
communityRestConf.start();
- Use RestConfConfigUtils to get default configuration.
RestConfConfiguration restConfConfig
= RestConfConfigUtils.getDefaultRestConfConfiguration();
- Load configuration from JSON file.
Path configPath = Paths.get("/path/to/lightyControllerConfig.json");
InputStream is = Files.newInputStream(configPath);
RestConfConfiguration restConfConfig
= RestConfConfigUtils.getRestConfConfiguration(is);
- Load configuration from classpath JSON resource.
InputStream is = this.getClass().getClassLoader().getResourceAsStream("/resoures/restConfConfig.json");
RestConfConfiguration restConfConfig
= RestConfConfigUtils.getRestConfConfiguration(is);
- Create configuration programmatically.
RestConfConfiguration restConfConfig = new RestConfConfiguration();
restConfConfiguration.setHttpPort(8888);
restConfConfiguration.setInetAddress(InetAddress.getLoopbackAddress());
...
- Last step before using RestConfConfiguration is to inject LightyServices into configuration instance loaded previously.
...
RestConfConfiguration restConfConfiguration = getRestConfConfiguration(restConfConfig, lightyServices);
...
Example configuration file is located here
CommunityRestConf requires following models to be loaded by LightyController.
"org.opendaylight.mdsal.model:rfc7895:1.0.1-SNAPSHOT",
"org.opendaylight.netconf:ietf-restconf-monitoring:1.8.1-SNAPSHOT"
As RESTCONF provides northbound interface, clustering has no effect on this component.