Reference and comments on doing ping MD-SAL in OpenDayLight.
As part of digging deeper into OpenDayLight, I spent some time looking at the MD-SAL piece. My original plan was to provide tutorials on that, but folks have already been doing a wonderful job on that. See here for links on MD-SAL tutorials.
So what I did instead, was to play with an example that is small and simple: the ping tutorial:
https://wiki.opendaylight.org/view/Ping
Since ping is just a tutorial, the code is not checked into the controller codebase. However, it was made to be embedded in the controller repo. So, in case you feel lazy and don't feel like typing, you can simply pull it off of gerrit, after cloning the controller repo.
# ref link: https://git.opendaylight.org/gerrit/#/c/6991/
cd controller.git
git fetch https://git.opendaylight.org/gerrit/controller refs/changes/91/6991/2 && git checkout FETCH_HEAD
After finished with that tutorial, I played a little more with the use of the Future<> RPC used in MD-SAL. I wanted to make the ping code able to continuously probe multiple destinations. So I enhanced the code to be async by doing this:
# ref link: https://git.opendaylight.org/gerrit/#/c/6992/2/ (Patch set 2)
cd controller.git
git fetch https://git.opendaylight.org/gerrit/controller refs/changes/92/6992/2 && git checkout FETCH_HEAD
# Examples using async ping (based on patch set 2):
for x in 127.0.0.1 128.0.0.1 192.168.1.1 ;
do curl --user "admin":"admin" -X PUT http://localhost:8080/controller/nb/v2/ping/async/start/${x} ; echo ; done
while : ; do for x in 127.0.0.1 128.0.0.1 192.168.1.1 ;
do curl --user "admin":"admin" -X PUT http://localhost:8080/controller/nb/v2/ping/async/get/${x} ; echo ; done ; sleep 2 ; done
for x in 127.0.0.1 128.0.0.1 192.168.1.1 ;
do curl --user "admin":"admin" -X PUT http://localhost:8080/controller/nb/v2/ping/async/stop/${x} ; echo ; done
After a few comments from Devin and Rob, I made my changes simpler by removing the need for the extra thread and the concurrent map. That removed the background capability of the ping implementation. But simpler is always better, especially in a tutorial arena. Those simplifications are stored as the latest patch set:
# ref link: https://git.opendaylight.org/gerrit/#/c/6992/
cd controller.git
git fetch https://git.opendaylight.org/gerrit/controller refs/changes/92/6992/4 && git checkout FETCH_HEAD
A few good links for learning/using MD-SAL in ODL:
https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL#MD-SAL_and_ODL_App_Tutorials
Comments
comments powered by Disqus