8000 GitHub - marosmars/kotlin: Kotlin fun
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

marosmars/kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ODL sample application using NETCONF and kotlin JVM language

This is a small SDN sample app, using:

  • ODL
  • NETCONF
  • Kotling

Final app can be found on github. Each step in this guide equals to 1 commit in that repo.

Preparations

Getting familiar with kotlin

https://kotlinlang.org/docs/reference/basic-syntax.html

Dependencies

  • Java 8 - Oracle or Openjdk
  • Maven - version 3.2.5 +

Empty ODL app

Generate app with ODL archetype.

Using 1.1.0-SNAPSHOT version which in translation is Beryllium snapshot version. However this close to formal ODL Beryllium release, that version is pretty stable.

Fill in the blanks and build with:

mvn clean install

to build app stub. You can read more at ODL's wiki or you can just take a look at first commit in this sample

Enable Kotlin

Next step is adding kotlin to the project.

Using RC version of kotlin: 1.0.0-rc-1036 since formal release is not yet out. Pretty straightforward with maven: enable kotlin commit

Now just build:

mvn clean install

After build succeeds, start ODL with sample application:

./karaf/target/assembly/bin/karaf to start and check our app with kotlin

In ODL logs(log:tail), following output should be visible after a few moments, indicating successful kotlin setup:

2016-02-06 14:29:26,941 | INFO | config-pusher | NetconfSampleProvider | 142 - org.mars.kotlin.netconf-odl-sample-impl - 1.0.0.SNAPSHOT | Kotlin works!

Add Netconf features

Now just add ODL NETCONF features. This sample app will use NETCONF to perform SDN stuff and NETCONF features need to be added.

More information can be found in official ODL NETCONF sample app.

After another build, start app and in the logs look for:

2016-02-06 14:59:37,175 | INFO | ult-dispatcher-2 | NetconfSampleProvider | 234 - org.mars.kotlin.netconf-odl-sample-impl - 1.0.0.SNAPSHOT | Kotlin detected data change: org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier@15afd047

2016-02-06 14:59:48,776 | INFO | sing-executor-11 | NetconfDevice | 157 - org.opendaylight.netconf.sal-netconf-connector - 1.3.0.SNAPSHOT | RemoteDevice{controller-config}: Netconf connector initialized successfully

Now kotlin is working as well as ODL NETCONF features.

Trying out kotlin's features

Now, kotlin can be utilized to full extent.

Adding list-nodes RPC

Simple RPC called list-nodes to allow external and internal apps to list mounted netconf devices. It's a copy from official ODL NETCONF sample app.

After performing build and run the app, list-nodes can be invoked with:

curl -u "admin:admin" http://localhost:8181/restconf/operations/netconf-odl-sample:list-nodes -X POST

Unit tests

To make it a bit more interesting, Spock tests are added for the app:

https://github.com/marosmars/kotlin/commit/f74fb20c9927d412839cfe17291174a670e94fd9

About

Kotlin fun

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0