1 / 56
ODL
OpenDaylight
Eueung Mulyana
https://telematika.org/remark/odl
CodeLabs | Attribution-ShareAlike CC BY-SA
Outline
Introduction
ODL + Mininet
REST Interface
Developing ODL Apps
2 / 56
OpenDaylight Nitrogen 0.7.1 | Mininet 2.2.2 on RPI3 with Ubuntu
16.04.3 LTS | OVS (Open vSwitch) 2.5.2
VirtualBox 5.2.6 on Ubuntu Xenial 16.04.3.
3 / 56
Introduction
4 / 56
5 / 56
ODL
OpenDaylight
OpenDaylight (ODL) is a modular open platform for customizing
and automating networks of any size and scale. The
OpenDaylight Project arose out of the SDN movement, with a
clear focus on network programmability. It was designed from
the outset as a foundation for commercial solutions that
address a variety of use cases in existing network environments.
ODL is driven by a global, collaborative community of vendor and user organizations that
continuously adapts to support the industry's broadest set of SDN and NFV use cases.
With over 1000 developers, 50 member organizations and supporting approximately 1
billion subscribers around the world, OpenDaylight is quickly evolving integrated
toolchains for leading use cases.
Ref: Platform Overview - OpenDaylight
6 / 56
ODL
Community
Founded in February 2013
Run by the Linux Foundation
Eclipse Public License
15 founding companies provided
software and developers
1000+ contributors
2.5M+ lines of code
Mostly Java
OpenDaylight Model/Components 7 / 56
OpenDaylight Releases - as of 02/2018
Carbon 0.6.2 | Nitrogen 0.7.1 8 / 56
9 / 56
ODL
Architecture
Model-Driven
The core of the OpenDaylight platform is the Model-Driven
Service Abstraction Layer (MD-SAL). In OpenDaylight,
underlying network devices and network applications are all
represented as objects, or models, whose interactions are
processed within the SAL.
The SAL is a data exchange and adaptation mechanism between YANG models
representing network devices and applications. The YANG models provide generalized
descriptions of a device or application's capabilities without requiring either to know the
speci c implementation details of the other. Within the SAL, models are simply de ned
by their respective roles in a given interaction. A "producer" model implements an API
and provides the API's data; a "consumer" model uses the API and consumes the API's
data. While 'northbound' and 'southbound' provide a network engineer's view of the
SAL, 'consumer' and 'producer' are more accurate descriptions of interactions within the
SAL. For example, protocol plugin and its associated model can either be a producer of
information about the underlying network, or a consumer of application instructions it
receives via the SAL.
10 / 56
ODL
Architecture
Modular & Multiprotocol
ODL includes support for the broadest set of protocols in any
SDN platform - OpenFlow, OVSDB, NETCONF, BGP and many
more - that improve programmability of modern networks and
solve a range of user needs.
Southbound protocols and control plane services, anchored by the MD-SAL, can be
individually selected or written, and packaged together according to the requirements of
a given use case. A controller package is built around four key components (odlparent,
controller, MD-SAL and yangtools). To this, the solution developer adds a relevant group
of southbound protocols plugins, most or all of the standard control plane functions, and
some select number of embedded and external controller applications, managed by
policy.
Each of these components is isolated as a Karaf feature, to ensure that new work doesn't
interfere with mature, tested code. OpenDaylight uses OSGi (Equinox) and Maven to
build a package that manages these Karaf features and their interactions.
11 / 56
ODL
Architecture
Modular & Multiprotocol
The ODL platform is designed to allow downstream users and
solution providers maximum exibility in building a controller
to t their needs. This modular framework allows developers
and users to:
Only install the protocols and services they need
Combine multiple services and protocols to solve more
complex problems as needs arise
Incrementally and collaboratively evolve the capabilities of
the open source platform
Quickly develop custom, value-added features for highly
specialized use cases, leveraging a common platform
shared across the industry
Getting Started
ODL + Mininet
12 / 56
13 / 56
Getting Started
Install Java JDK + Env Adjustment
Download ODL + Unzip/Untar
Run Karaf
Install Features
Run Mininet (Remote Controller Pointed
to the ODL instance)
14 / 56
Installation
Java Dependency
$ sudo apt-get install unzip zip tree
$ sudo apt-get install software-properties-common -y && 
sudo add-apt-repository ppa:webupd8team/java -y && 
sudo apt-get update && 
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-s
sudo apt-get install oracle-java8-installer oracle-java8-set-default -y
$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
$ which java
/usr/bin/java
$ echo $JAVA_HOME
$ nano .profile
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/
$ source .profile
15 / 56
Installation
Download +
Unzip/Untar
# direct download
$ wget https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/k
# indirect: download first + sftp
$ sftp -oPort=22 em@192.168.56.70
sftp> put karaf-0.7.1.zip
$ ssh em@192.168.56.70
$ unzip karaf-0.7.1.zip
$ cd karaf-0.7.1
$ ./bin/karaf
~/karaf-0.7.1$ ./bin/karaf
Apache Karaf starting up. Press Enter to open the shell now...
100% [========================================================================]
Karaf started in 2s. Bundle stats: 52 active, 53 total
________ ________ .__ .__ .__ __
_____  ______ ____ ____ ______  _____ ___.__.| | |__| ____ | |___/ |_
/ | ____ _/ __  /  | | __ < | || | | |/ ___| |  __
/ |  |_> > ___/| | | ` / __ ___ || |_| / /_/ > Y  |
_______ / __/ ___ >___| /_______ (____ / ____||____/_____ /|___| /__|
/|__| / / / // /_____/ /
Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight.
opendaylight-user@root>feature
feature feature:export-bundles feature:info feat
feature:repo-add feature:repo-list feature:repo-refresh feat
feature:requirement-remove feature:start feature:stop feat
opendaylight-user@root>feature:list --installed
Name | Version | Required | State | Repository | Description
----------------------------------------------------------------------------------------------
aries-proxy | 4.0.10 | | Started | standard-4.0.10 | Aries Proxy
aries-blueprint | 4.0.10 | | Started | standard-4.0.10 | Aries Blueprint
feature | 4.0.10 | | Started | standard-4.0.10 | Features Support
shell | 4.0.10 | | Started | standard-4.0.10 | Karaf Shell
shell-compat | 4.0.10 | | Started | standard-4.0.10 | Karaf Shell Compatibility
deployer | 4.0.10 | | Started | standard-4.0.10 | Karaf Deployer
bundle | 4.0.10 | | Started | standard-4.0.10 | Provide Bundle support
config | 4.0.10 | | Started | standard-4.0.10 | Provide OSGi ConfigAdmin su
diagnostic | 4.0.10 | | Started | standard-4.0.10 | Provide Diagnostic support
instance | 4.0.10 | | Started | standard-4.0.10 | Provide Instance support
jaas | 4.0.10 | | Started | standard-4.0.10 | Provide JAAS support
log | 4.0.10 | | Started | standard-4.0.10 | Provide Log support
package | 4.0.10 | | Started | standard-4.0.10 | Package commands and mbeans
service | 4.0.10 | | Started | standard-4.0.10 | Provide Service support
system | 4.0.10 | | Started | standard-4.0.10 | Provide System support
kar | 4.0.10 | | Started | standard-4.0.10 | Provide KAR (KARaf archive)
ssh | 4.0.10 | | Started | standard-4.0.10 | Provide a SSHd server on Ka
16 / 56
Run Karaf
opendaylight-user@root>feature:install odl-restconf odl-l2switch-switch odl-mdsal-apidocs
opendaylight-user@root>feature:install odl-dlux-core odl-dluxapps-nodes odl-dluxapps-topology
opendaylight-user@root>feature:list -i | grep dlux
odl-dluxapps-yangui | 0.6.1 | x | Started | odl-
odl-dluxapps-yangvisualizer | 0.6.1 | x | Started | odl-
odl-dluxapps-yangman | 0.6.1 | x | Started | odl-
odl-dluxapps-topology | 0.6.1 | x | Started | odl-
odl-dluxapps-nodes | 0.6.1 | x | Started | odl-
odl-dlux-core | 0.6.1 | x | Started | odl-
opendaylight-user@root>feature:list | grep dlux
features-dluxapps | 0.6.1 | | Uninstalled |
features-dlux | 0.6.1 | | Uninstalled |
odl-dluxapps-applications | 0.6.1 | | Uninstalled |
odl-dluxapps-yangui | 0.6.1 | x | Started |
odl-dluxapps-yangvisualizer | 0.6.1 | x | Started |
odl-unimgr-dlux | 0.3.1 | | Uninstalled |
odl-dluxapps-yangman | 0.6.1 | x | Started |
odl-dluxapps-topology | 0.6.1 | x | Started |
odl-dluxapps-nodes | 0.6.1 | x | Started |
odl-dluxapps-yangutils | 0.6.1 | | Uninstalled |
odl-dlux-core | 0.6.1 | x | Started |
opendaylight-user@root>feature:info odl-dluxapps-applications
Feature odl-dluxapps-applications 0.6.1
Description:
ODL :: dluxapps :: odl-dluxapps-applications
Details:
OpenDaylight is leading the transformation to Open Software Defined Networking (SDN). For mo
Feature has no configuration
Feature has no configuration files
Feature depends on:
odl-dluxapps-nodes 0.6.1
odl-dluxapps-topology 0.6.1
odl-dluxapps-yangui 0.6.1
odl-dluxapps-yangvisualizer 0.6.1
odl-dluxapps-yangman 0.6.1
Feature has no bundles.
Feature has no conditionals.
17 / 56
Install
Features
18 / 56
Mininet
Connect to ODL
$ ssh -X ubuntu@192.168.0.155
$ ubuntu@pi:~$ sudo mn --topo linear,3 --mac --controller=remote,ip=192.168.0.156,port=6633 --sw
+++ Creating network
+++ Adding controller
+++ Adding hosts:
h1 h2 h3
+++ Adding switches:
s1 s2 s3
+++ Adding links:
(h1, s1) (h2, s2) (h3, s3) (s2, s1) (s3, s2)
+++ Configuring hosts
h1 h2 h3
+++ Starting controller
c0
+++ Starting 3 switches
s1 s2 s3 ...
+++ Starting CLI:
mininet>
# access (note: index.html | cred: admin/admin)
# http://192.168.0.156:8181/index.html
DLUX - Topology 19 / 56
DLUX - Node 20 / 56
DLUX - Node - Node Connectors 21 / 56
DLUX - Node - Statistics Node Connectors 22 / 56
23 / 56
Mininet
pings
mininet> h1 ping -c1 h3
PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.
64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=33.1 ms
--- 10.0.0.3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 33.188/33.188/33.188/0.000 ms
mininet> pingall
+++ Ping: testing ping reachability
h1 -> h2 h3
h2 -> h1 h3
h3 -> h1 h2
+++ Results: 0% dropped (6/6 received)
Topology - h1 ping -c1 h3 24 / 56
Topology - pingall 25 / 56
REST Interface
26 / 56
27 / 56
REST Interface
RESTconf
OpenDaylight applications expose
con guration and state in the
datastore. The REST interface has
direct access to the controller
datastore.
RFC 8040
Restful API for YANG data models and provides lighter-
weight interface to network datastores leveraging well
known combination of REST and JSON.
Con guration data and state data exposed as resources
HTTP instead of SSH for transport; JSON in addition to XML
for data encoding
Ref: OpenDaylight as a Platform for Network Programmability
High Level Manageability Architecture - (Eckel/Cisco) 28 / 56
29 / 56
RESTconf
http://<IP>:8181/restconf/*
# This is where users create/read/update/delete (POST, GET, PUT, DELETE) application configurati
http://<IP>:8181/restconf/restconf/config/*
# This is where applications write state and users read it (GET).
http://<IP>:8181/restconf/restconf/operational/*
# Most popular databases are topology and inventory:
GET http://<IP>:8181/restconf/operational/network-topology:network-topology/
GET http://<IP>:8181/restconf/operational/opendaylight-inventory:nodes/
# Access via curl
curl --user "admin":"admin" -H "Accept: application/json" -H "Content-type: application/json" -X
# Header:
# Authorization (basic): admin/admin
# Accept (answer body): application/xml or application/json
# Content-Type (request body): application/xml or application/json
Yang UI - network-topology | Send 30 / 56
Yang UI - network-topology | Display Topology 31 / 56
Yang UI - odl-inventory | Send + Preview 32 / 56
Yangman - network-topology 33 / 56
External via Postman - network-topology 34 / 56
External via Postman - odl-inventory 35 / 56
APIdoc 36 / 56
APIdoc 37 / 56
APIdoc - network-topology 38 / 56
Introduction
Developing ODL Apps
39 / 56
40 / 56
Maven
$ apt-cache policy maven
maven:
Installed: (none)
Candidate: 3.3.9-3
Version table:
3.3.9-3 500
500 http://kambing.ui.ac.id/ubuntu xenial/universe amd64 Packages
500 http://kambing.ui.ac.id/ubuntu xenial/universe i386 Packages
$ sudo apt install maven
$ mvn -v
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_161, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "4.4.0-112-generic", arch: "amd64", family: "unix"
$ mkdir .m2
$ wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/stable/boron/settings.xm
$ mkdir devfolder && cd devfolder
# cp -n ~/.m2/settings.xml{,.orig} ; wget -q -O - https://raw.githubusercontent.com/opendayligh
mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=op
-DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.release/
-DarchetypeCatalog=remote -DarchetypeVersion=1.3.0-Carbon
Define value for property 'groupId': org.opendaylight.hallo
Define value for property 'artifactId': hallo
[INFO] Using property: version = 0.1.0-SNAPSHOT
Define value for property 'package' org.opendaylight.hallo: :
Define value for property 'classPrefix' Hallo: :
Define value for property 'copyright': hallo inc.
[INFO] Using property: copyrightYear = 2017
Confirm properties configuration:
groupId: org.opendaylight.hallo
artifactId: hallo
version: 0.1.0-SNAPSHOT
package: org.opendaylight.hallo
classPrefix: Hallo
copyright: hallo inc.
copyrightYear: 2017
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: opendaylight-startup-ar
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.opendaylight.hallo
[INFO] Parameter: artifactId, Value: hallo
[INFO] Parameter: version, Value: 0.1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.opendaylight.hallo
[INFO] Parameter: packageInPathFormat, Value: org/opendaylight/hallo
[INFO] Parameter: classPrefix, Value: Hallo
[INFO] Parameter: package, Value: org.opendaylight.hallo
[INFO] Parameter: version, Value: 0.1.0-SNAPSHOT
[INFO] Parameter: copyright, Value: hallo inc.
[INFO] Parameter: groupId, Value: org.opendaylight.hallo
[INFO] Parameter: artifactId, Value: hallo
[INFO] Parameter: copyrightYear, Value: 2017
[WARNING] Don't override file /home/em/devfolder/hallo/pom.xml
[INFO] Project created from Archetype in dir: /home/em/devfolder/hallo
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:27 min
41 / 56
ODL
Archetype
~/devfolder/hallo$ tree
.
|-- api
| |-- pom.xml
| |-- src
| |-- main
| |-- yang
| |-- hallo.yang
|-- artifacts
| |-- pom.xml
|-- cli
| |-- pom.xml
| |-- src
| |-- main
| |-- java
| | |-- org
| | |-- opendaylight
| | |-- hallo
| | |-- cli
| | |-- api
| | |-- HalloCliCommands.java
| | |-- commands
| | |-- HalloCliTestCommand.java
| | |-- impl
| | |-- HalloCliCommandsImpl.java
| |-- resources
| |-- org
| |-- opendaylight
| |-- blueprint
| |-- cli-blueprint.xml
|-- deploy-site.xml
|-- features
| |-- pom.xml
| |-- src
| |-- main
| |-- features
| |-- features.xml
|-- impl
| |-- pom.xml
| |-- src
| |-- main
| | |-- java
42 / 56
Files &
Folders
~/devfolder/hallo$ mvn clean install -DskipTests
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] ODL :: org.opendaylight.hallo :: hallo-api ......... SUCCESS [03:04 min]
[INFO] ODL :: org.opendaylight.hallo :: hallo-impl ........ SUCCESS [ 52.270 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-cli ......... SUCCESS [ 18.734 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-features .... SUCCESS [12:12 min]
[INFO] ODL :: org.opendaylight.hallo :: hallo-karaf ....... SUCCESS [11:21 min]
[INFO] ODL :: org.opendaylight.hallo :: hallo-artifacts ... SUCCESS [ 1.753 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-it .......... SUCCESS [ 48.589 s]
[INFO] hallo .............................................. SUCCESS [ 32.835 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31:49 min
[INFO] Finished at: 2018-02-05T03:36:20+07:00
[INFO] Final Memory: 223M/718M
[INFO] ------------------------------------------------------------------------
~/devfolder/hallo$
$ karaf/target/assembly/bin/karaf
~/devfolder/hallo$ karaf/target/assembly/bin/karaf
Apache Karaf starting up. Press Enter to open the shell now...
100% [========================================================================]
Karaf started in 37s. Bundle stats: 294 active, 294 total
________ ________ .__ .__ .__ __
_____  ______ ____ ____ ______  _____ ___.__.| | |__| ____ | |___/ |_
/ | ____ _/ __  /  | | __ < | || | | |/ ___| |  __
/ |  |_> > ___/| | | ` / __ ___ || |_| / /_/ > Y  |
_______ / __/ ___ >___| /_______ (____ / ____||____/_____ /|___| /__|
/|__| / / / // /_____/ /
Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight.
opendaylight-user@root>log:display | grep Hallo
43 / 56
Build
$ cat api/src/main/yang/hallo.yang
module hallo {
yang-version 1;
namespace "urn:opendaylight:params:xml:ns:yang:hallo";
prefix "hallo";
revision "2015-01-05" {
description "Initial revision of hallo model";
}
}
$ rm api/src/main/yang/hallo.yang && nano api/src/main/yang/hallo.yang
# new hallo.yang
module hallo {
yang-version 1;
namespace "urn:opendaylight:params:xml:ns:yang:hallo";
prefix "hallo";
revision "2015-01-05" {
description "Initial revision of hallo model";
}
rpc hallo-world {
input {
leaf name {
type string;
}
}
output {
leaf greeting {
type string;
}
}
}
}
$ cd api && mvn clean install -DskipTests
...
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.155 s
[INFO] Finished at: 2018-02-05T05:10:55+07:00
[INFO] Final Memory: 55M/580M
[INFO] ------------------------------------------------------------------------ 44 / 56
A Simple RPC
API
$ nano impl/src/main/java/org/opendaylight/hallo/impl/HalloWorldImpl.java
/*
* Copyright (c) 2016 ODL and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.hallo.impl;
import java.util.concurrent.Future;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloS
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloW
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloW
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloW
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
public class HalloWorldImpl implements HalloService {
@Override
public Future<RpcResult<HalloWorldOutput>> halloWorld(HalloWorldInput input) {
HalloWorldOutputBuilder halloBuilder = new HalloWorldOutputBuilder();
halloBuilder.setGreeting("Hallo " + input.getName());
return RpcResultBuilder.success(halloBuilder.build()).buildFuture();
}
}
~/devfolder/hallo$ ll impl/src/main/java/org/opendaylight/hallo/impl/
total 16
drwxrwxr-x 2 em em 4096 Feb 5 05:20 ./
drwxrwxr-x 3 em em 4096 Feb 5 03:02 ../
-rw-rw-r-- 1 em em 1036 Feb 5 03:02 HalloProvider.java
-rw-rw-r-- 1 em em 1302 Feb 5 05:20 HalloWorldImpl.java
45 / 56
HalloService
$ cat impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=4 tabstop=4: -->
<!--
Copyright (c) 2017 hallo inc. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
<reference id="dataBroker"
interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
odl:type="default" />
<reference id="rpcRegistry"
interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
<bean id="provider"
class="org.opendaylight.hallo.impl.HalloProvider"
init-method="init" destroy-method="close">
<argument ref="dataBroker" />
<argument ref="rpcRegistry" />
</bean>
</blueprint>
46 / 56
RPC Registry
Reference
$ cat impl/src/main/java/org/opendaylight/hallo/impl/HalloProvider.java
/*
* Copyright (c) 2017 hallo inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.hallo.impl;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloS
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HalloProvider {
private static final Logger LOG = LoggerFactory.getLogger(HalloProvider.class);
private final DataBroker dataBroker;
private final RpcProviderRegistry rpcProviderRegistry;
private RpcRegistration<HalloService> serviceRegistration;
public HalloProvider(final DataBroker dataBroker,RpcProviderRegistry rpcProviderRegistry)
this.dataBroker = dataBroker;
this.rpcProviderRegistry = rpcProviderRegistry;
}
/**
* Method called when the blueprint container is created.
*/
public void init() {
serviceRegistration = rpcProviderRegistry.addRpcImplementation(HalloService.class, new
LOG.info("HalloProvider Session Initiated");
}
/**
* Method called when the blueprint container is destroyed.
*/
public void close() {
47 / 56
HalloProvider
$ cd impl && mvn clean install -DskipTests
...
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.266 s
[INFO] Finished at: 2018-02-05T05:31:13+07:00
[INFO] Final Memory: 56M/500M
[INFO] ------------------------------------------------------------------------
$ cd .. && mvn clean install -DskipTests
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] ODL :: org.opendaylight.hallo :: hallo-api ......... SUCCESS [ 28.781 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-impl ........ SUCCESS [ 14.900 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-cli ......... SUCCESS [ 13.989 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-features .... SUCCESS [ 12.178 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-karaf ....... SUCCESS [ 50.341 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-artifacts ... SUCCESS [ 1.773 s]
[INFO] ODL :: org.opendaylight.hallo :: hallo-it .......... SUCCESS [ 27.518 s]
[INFO] hallo .............................................. SUCCESS [ 28.513 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:02 min
[INFO] Finished at: 2018-02-05T05:34:43+07:00
[INFO] Final Memory: 221M/673M
[INFO] ------------------------------------------------------------------------
$ karaf/target/assembly/bin/karaf
...
opendaylight-user@root>bundle:list | grep hallo
207 | Active | 80 | 0.1.0.SNAPSHOT | ODL :: org.opendaylight.hallo :: h
208 | Active | 80 | 0.1.0.SNAPSHOT | ODL :: org.opendaylight.hallo :: h
opendaylight-user@root>feature:list | grep hallo
odl-hallo-api | 0.1.0-SNAPSHOT | x | odl-hallo-0.1.0-SNAPSHOT
odl-hallo | 0.1.0-SNAPSHOT | x | odl-hallo-0.1.0-SNAPSHOT
odl-hallo-rest | 0.1.0-SNAPSHOT | x | odl-hallo-0.1.0-SNAPSHOT
odl-hallo-ui | 0.1.0-SNAPSHOT | x | odl-hallo-0.1.0-SNAPSHOT
odl hallo cli | 0 1 0 SNAPSHOT | | odl hallo 0 1 0 SNAPSHOT
48 / 56
Build
Test via RestConf/Swagger 49 / 56
Test via RestConf/Swagger 50 / 56
Test via RestConf/Swagger 51 / 56
Test via Postman 52 / 56
Test via Postman 53 / 56
Refs/Resources
54 / 56
Refs/Resources
1. Platform Overview - OpenDaylight
2. Using the OpenDaylight SDN Controller with the Mininet Network Emulator
3. ODL_Summit_OpenFlow_Tutorial
4. OpenDaylight User Guide - OpenDaylight Documentation Nitrogen documentation
5. Getting Started Guide - OpenDaylight Documentation Nitrogen documentation
6. OpenDaylight Application Developer's tutorial | SDN Hub
7. CiscoDevNet/yangman: YANGMAN o ers dynamically generated UI forms and native JSON
representation based on RESTCONF APIs
8. OpenDaylight as a Platform for Network Programmability
9. OpenDaylight Controller:MD-SAL:Startup Project Archetype
10. Developing Apps on the OpenDaylight controller - Nitrogen
11. RFC 8040 - RESTCONF Protocol
55 / 56
56 / 56
ENDEueung Mulyana
https://telematika.org/remark/odl
CodeLabs | Attribution-ShareAlike CC BY-SA

OpenDaylight SDN Controller - Introduction

  • 1.
    1 / 56 ODL OpenDaylight EueungMulyana https://telematika.org/remark/odl CodeLabs | Attribution-ShareAlike CC BY-SA
  • 2.
    Outline Introduction ODL + Mininet RESTInterface Developing ODL Apps 2 / 56
  • 3.
    OpenDaylight Nitrogen 0.7.1| Mininet 2.2.2 on RPI3 with Ubuntu 16.04.3 LTS | OVS (Open vSwitch) 2.5.2 VirtualBox 5.2.6 on Ubuntu Xenial 16.04.3. 3 / 56
  • 4.
  • 5.
    5 / 56 ODL OpenDaylight OpenDaylight(ODL) is a modular open platform for customizing and automating networks of any size and scale. The OpenDaylight Project arose out of the SDN movement, with a clear focus on network programmability. It was designed from the outset as a foundation for commercial solutions that address a variety of use cases in existing network environments. ODL is driven by a global, collaborative community of vendor and user organizations that continuously adapts to support the industry's broadest set of SDN and NFV use cases. With over 1000 developers, 50 member organizations and supporting approximately 1 billion subscribers around the world, OpenDaylight is quickly evolving integrated toolchains for leading use cases. Ref: Platform Overview - OpenDaylight
  • 6.
    6 / 56 ODL Community Foundedin February 2013 Run by the Linux Foundation Eclipse Public License 15 founding companies provided software and developers 1000+ contributors 2.5M+ lines of code Mostly Java
  • 7.
  • 8.
    OpenDaylight Releases -as of 02/2018 Carbon 0.6.2 | Nitrogen 0.7.1 8 / 56
  • 9.
    9 / 56 ODL Architecture Model-Driven Thecore of the OpenDaylight platform is the Model-Driven Service Abstraction Layer (MD-SAL). In OpenDaylight, underlying network devices and network applications are all represented as objects, or models, whose interactions are processed within the SAL. The SAL is a data exchange and adaptation mechanism between YANG models representing network devices and applications. The YANG models provide generalized descriptions of a device or application's capabilities without requiring either to know the speci c implementation details of the other. Within the SAL, models are simply de ned by their respective roles in a given interaction. A "producer" model implements an API and provides the API's data; a "consumer" model uses the API and consumes the API's data. While 'northbound' and 'southbound' provide a network engineer's view of the SAL, 'consumer' and 'producer' are more accurate descriptions of interactions within the SAL. For example, protocol plugin and its associated model can either be a producer of information about the underlying network, or a consumer of application instructions it receives via the SAL.
  • 10.
    10 / 56 ODL Architecture Modular& Multiprotocol ODL includes support for the broadest set of protocols in any SDN platform - OpenFlow, OVSDB, NETCONF, BGP and many more - that improve programmability of modern networks and solve a range of user needs. Southbound protocols and control plane services, anchored by the MD-SAL, can be individually selected or written, and packaged together according to the requirements of a given use case. A controller package is built around four key components (odlparent, controller, MD-SAL and yangtools). To this, the solution developer adds a relevant group of southbound protocols plugins, most or all of the standard control plane functions, and some select number of embedded and external controller applications, managed by policy. Each of these components is isolated as a Karaf feature, to ensure that new work doesn't interfere with mature, tested code. OpenDaylight uses OSGi (Equinox) and Maven to build a package that manages these Karaf features and their interactions.
  • 11.
    11 / 56 ODL Architecture Modular& Multiprotocol The ODL platform is designed to allow downstream users and solution providers maximum exibility in building a controller to t their needs. This modular framework allows developers and users to: Only install the protocols and services they need Combine multiple services and protocols to solve more complex problems as needs arise Incrementally and collaboratively evolve the capabilities of the open source platform Quickly develop custom, value-added features for highly specialized use cases, leveraging a common platform shared across the industry
  • 12.
    Getting Started ODL +Mininet 12 / 56
  • 13.
    13 / 56 GettingStarted Install Java JDK + Env Adjustment Download ODL + Unzip/Untar Run Karaf Install Features Run Mininet (Remote Controller Pointed to the ODL instance)
  • 14.
    14 / 56 Installation JavaDependency $ sudo apt-get install unzip zip tree $ sudo apt-get install software-properties-common -y && sudo add-apt-repository ppa:webupd8team/java -y && sudo apt-get update && echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-s sudo apt-get install oracle-java8-installer oracle-java8-set-default -y $ java -version java version "1.8.0_161" Java(TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode) $ which java /usr/bin/java $ echo $JAVA_HOME $ nano .profile export JAVA_HOME=/usr/lib/jvm/java-8-oracle/ $ source .profile
  • 15.
    15 / 56 Installation Download+ Unzip/Untar # direct download $ wget https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/k # indirect: download first + sftp $ sftp -oPort=22 em@192.168.56.70 sftp> put karaf-0.7.1.zip $ ssh em@192.168.56.70 $ unzip karaf-0.7.1.zip $ cd karaf-0.7.1 $ ./bin/karaf
  • 16.
    ~/karaf-0.7.1$ ./bin/karaf Apache Karafstarting up. Press Enter to open the shell now... 100% [========================================================================] Karaf started in 2s. Bundle stats: 52 active, 53 total ________ ________ .__ .__ .__ __ _____ ______ ____ ____ ______ _____ ___.__.| | |__| ____ | |___/ |_ / | ____ _/ __ / | | __ < | || | | |/ ___| | __ / | |_> > ___/| | | ` / __ ___ || |_| / /_/ > Y | _______ / __/ ___ >___| /_______ (____ / ____||____/_____ /|___| /__| /|__| / / / // /_____/ / Hit '<tab>' for a list of available commands and '[cmd] --help' for help on a specific command. Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight. opendaylight-user@root>feature feature feature:export-bundles feature:info feat feature:repo-add feature:repo-list feature:repo-refresh feat feature:requirement-remove feature:start feature:stop feat opendaylight-user@root>feature:list --installed Name | Version | Required | State | Repository | Description ---------------------------------------------------------------------------------------------- aries-proxy | 4.0.10 | | Started | standard-4.0.10 | Aries Proxy aries-blueprint | 4.0.10 | | Started | standard-4.0.10 | Aries Blueprint feature | 4.0.10 | | Started | standard-4.0.10 | Features Support shell | 4.0.10 | | Started | standard-4.0.10 | Karaf Shell shell-compat | 4.0.10 | | Started | standard-4.0.10 | Karaf Shell Compatibility deployer | 4.0.10 | | Started | standard-4.0.10 | Karaf Deployer bundle | 4.0.10 | | Started | standard-4.0.10 | Provide Bundle support config | 4.0.10 | | Started | standard-4.0.10 | Provide OSGi ConfigAdmin su diagnostic | 4.0.10 | | Started | standard-4.0.10 | Provide Diagnostic support instance | 4.0.10 | | Started | standard-4.0.10 | Provide Instance support jaas | 4.0.10 | | Started | standard-4.0.10 | Provide JAAS support log | 4.0.10 | | Started | standard-4.0.10 | Provide Log support package | 4.0.10 | | Started | standard-4.0.10 | Package commands and mbeans service | 4.0.10 | | Started | standard-4.0.10 | Provide Service support system | 4.0.10 | | Started | standard-4.0.10 | Provide System support kar | 4.0.10 | | Started | standard-4.0.10 | Provide KAR (KARaf archive) ssh | 4.0.10 | | Started | standard-4.0.10 | Provide a SSHd server on Ka 16 / 56 Run Karaf
  • 17.
    opendaylight-user@root>feature:install odl-restconf odl-l2switch-switchodl-mdsal-apidocs opendaylight-user@root>feature:install odl-dlux-core odl-dluxapps-nodes odl-dluxapps-topology opendaylight-user@root>feature:list -i | grep dlux odl-dluxapps-yangui | 0.6.1 | x | Started | odl- odl-dluxapps-yangvisualizer | 0.6.1 | x | Started | odl- odl-dluxapps-yangman | 0.6.1 | x | Started | odl- odl-dluxapps-topology | 0.6.1 | x | Started | odl- odl-dluxapps-nodes | 0.6.1 | x | Started | odl- odl-dlux-core | 0.6.1 | x | Started | odl- opendaylight-user@root>feature:list | grep dlux features-dluxapps | 0.6.1 | | Uninstalled | features-dlux | 0.6.1 | | Uninstalled | odl-dluxapps-applications | 0.6.1 | | Uninstalled | odl-dluxapps-yangui | 0.6.1 | x | Started | odl-dluxapps-yangvisualizer | 0.6.1 | x | Started | odl-unimgr-dlux | 0.3.1 | | Uninstalled | odl-dluxapps-yangman | 0.6.1 | x | Started | odl-dluxapps-topology | 0.6.1 | x | Started | odl-dluxapps-nodes | 0.6.1 | x | Started | odl-dluxapps-yangutils | 0.6.1 | | Uninstalled | odl-dlux-core | 0.6.1 | x | Started | opendaylight-user@root>feature:info odl-dluxapps-applications Feature odl-dluxapps-applications 0.6.1 Description: ODL :: dluxapps :: odl-dluxapps-applications Details: OpenDaylight is leading the transformation to Open Software Defined Networking (SDN). For mo Feature has no configuration Feature has no configuration files Feature depends on: odl-dluxapps-nodes 0.6.1 odl-dluxapps-topology 0.6.1 odl-dluxapps-yangui 0.6.1 odl-dluxapps-yangvisualizer 0.6.1 odl-dluxapps-yangman 0.6.1 Feature has no bundles. Feature has no conditionals. 17 / 56 Install Features
  • 18.
    18 / 56 Mininet Connectto ODL $ ssh -X ubuntu@192.168.0.155 $ ubuntu@pi:~$ sudo mn --topo linear,3 --mac --controller=remote,ip=192.168.0.156,port=6633 --sw +++ Creating network +++ Adding controller +++ Adding hosts: h1 h2 h3 +++ Adding switches: s1 s2 s3 +++ Adding links: (h1, s1) (h2, s2) (h3, s3) (s2, s1) (s3, s2) +++ Configuring hosts h1 h2 h3 +++ Starting controller c0 +++ Starting 3 switches s1 s2 s3 ... +++ Starting CLI: mininet> # access (note: index.html | cred: admin/admin) # http://192.168.0.156:8181/index.html
  • 19.
  • 20.
    DLUX - Node20 / 56
  • 21.
    DLUX - Node- Node Connectors 21 / 56
  • 22.
    DLUX - Node- Statistics Node Connectors 22 / 56
  • 23.
    23 / 56 Mininet pings mininet>h1 ping -c1 h3 PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data. 64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=33.1 ms --- 10.0.0.3 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 33.188/33.188/33.188/0.000 ms mininet> pingall +++ Ping: testing ping reachability h1 -> h2 h3 h2 -> h1 h3 h3 -> h1 h2 +++ Results: 0% dropped (6/6 received)
  • 24.
    Topology - h1ping -c1 h3 24 / 56
  • 25.
  • 26.
  • 27.
    27 / 56 RESTInterface RESTconf OpenDaylight applications expose con guration and state in the datastore. The REST interface has direct access to the controller datastore. RFC 8040 Restful API for YANG data models and provides lighter- weight interface to network datastores leveraging well known combination of REST and JSON. Con guration data and state data exposed as resources HTTP instead of SSH for transport; JSON in addition to XML for data encoding Ref: OpenDaylight as a Platform for Network Programmability
  • 28.
    High Level ManageabilityArchitecture - (Eckel/Cisco) 28 / 56
  • 29.
    29 / 56 RESTconf http://<IP>:8181/restconf/* #This is where users create/read/update/delete (POST, GET, PUT, DELETE) application configurati http://<IP>:8181/restconf/restconf/config/* # This is where applications write state and users read it (GET). http://<IP>:8181/restconf/restconf/operational/* # Most popular databases are topology and inventory: GET http://<IP>:8181/restconf/operational/network-topology:network-topology/ GET http://<IP>:8181/restconf/operational/opendaylight-inventory:nodes/ # Access via curl curl --user "admin":"admin" -H "Accept: application/json" -H "Content-type: application/json" -X # Header: # Authorization (basic): admin/admin # Accept (answer body): application/xml or application/json # Content-Type (request body): application/xml or application/json
  • 30.
    Yang UI -network-topology | Send 30 / 56
  • 31.
    Yang UI -network-topology | Display Topology 31 / 56
  • 32.
    Yang UI -odl-inventory | Send + Preview 32 / 56
  • 33.
  • 34.
    External via Postman- network-topology 34 / 56
  • 35.
    External via Postman- odl-inventory 35 / 56
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
    40 / 56 Maven $apt-cache policy maven maven: Installed: (none) Candidate: 3.3.9-3 Version table: 3.3.9-3 500 500 http://kambing.ui.ac.id/ubuntu xenial/universe amd64 Packages 500 http://kambing.ui.ac.id/ubuntu xenial/universe i386 Packages $ sudo apt install maven $ mvn -v Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_161, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-oracle/jre Default locale: en_US, platform encoding: ANSI_X3.4-1968 OS name: "linux", version: "4.4.0-112-generic", arch: "amd64", family: "unix" $ mkdir .m2 $ wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/stable/boron/settings.xm $ mkdir devfolder && cd devfolder # cp -n ~/.m2/settings.xml{,.orig} ; wget -q -O - https://raw.githubusercontent.com/opendayligh
  • 41.
    mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller-DarchetypeArtifactId=op -DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.release/ -DarchetypeCatalog=remote -DarchetypeVersion=1.3.0-Carbon Define value for property 'groupId': org.opendaylight.hallo Define value for property 'artifactId': hallo [INFO] Using property: version = 0.1.0-SNAPSHOT Define value for property 'package' org.opendaylight.hallo: : Define value for property 'classPrefix' Hallo: : Define value for property 'copyright': hallo inc. [INFO] Using property: copyrightYear = 2017 Confirm properties configuration: groupId: org.opendaylight.hallo artifactId: hallo version: 0.1.0-SNAPSHOT package: org.opendaylight.hallo classPrefix: Hallo copyright: hallo inc. copyrightYear: 2017 Y: : [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating project from Archetype: opendaylight-startup-ar [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: groupId, Value: org.opendaylight.hallo [INFO] Parameter: artifactId, Value: hallo [INFO] Parameter: version, Value: 0.1.0-SNAPSHOT [INFO] Parameter: package, Value: org.opendaylight.hallo [INFO] Parameter: packageInPathFormat, Value: org/opendaylight/hallo [INFO] Parameter: classPrefix, Value: Hallo [INFO] Parameter: package, Value: org.opendaylight.hallo [INFO] Parameter: version, Value: 0.1.0-SNAPSHOT [INFO] Parameter: copyright, Value: hallo inc. [INFO] Parameter: groupId, Value: org.opendaylight.hallo [INFO] Parameter: artifactId, Value: hallo [INFO] Parameter: copyrightYear, Value: 2017 [WARNING] Don't override file /home/em/devfolder/hallo/pom.xml [INFO] Project created from Archetype in dir: /home/em/devfolder/hallo [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:27 min 41 / 56 ODL Archetype
  • 42.
    ~/devfolder/hallo$ tree . |-- api ||-- pom.xml | |-- src | |-- main | |-- yang | |-- hallo.yang |-- artifacts | |-- pom.xml |-- cli | |-- pom.xml | |-- src | |-- main | |-- java | | |-- org | | |-- opendaylight | | |-- hallo | | |-- cli | | |-- api | | |-- HalloCliCommands.java | | |-- commands | | |-- HalloCliTestCommand.java | | |-- impl | | |-- HalloCliCommandsImpl.java | |-- resources | |-- org | |-- opendaylight | |-- blueprint | |-- cli-blueprint.xml |-- deploy-site.xml |-- features | |-- pom.xml | |-- src | |-- main | |-- features | |-- features.xml |-- impl | |-- pom.xml | |-- src | |-- main | | |-- java 42 / 56 Files & Folders
  • 43.
    ~/devfolder/hallo$ mvn cleaninstall -DskipTests ... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] ODL :: org.opendaylight.hallo :: hallo-api ......... SUCCESS [03:04 min] [INFO] ODL :: org.opendaylight.hallo :: hallo-impl ........ SUCCESS [ 52.270 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-cli ......... SUCCESS [ 18.734 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-features .... SUCCESS [12:12 min] [INFO] ODL :: org.opendaylight.hallo :: hallo-karaf ....... SUCCESS [11:21 min] [INFO] ODL :: org.opendaylight.hallo :: hallo-artifacts ... SUCCESS [ 1.753 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-it .......... SUCCESS [ 48.589 s] [INFO] hallo .............................................. SUCCESS [ 32.835 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 31:49 min [INFO] Finished at: 2018-02-05T03:36:20+07:00 [INFO] Final Memory: 223M/718M [INFO] ------------------------------------------------------------------------ ~/devfolder/hallo$ $ karaf/target/assembly/bin/karaf ~/devfolder/hallo$ karaf/target/assembly/bin/karaf Apache Karaf starting up. Press Enter to open the shell now... 100% [========================================================================] Karaf started in 37s. Bundle stats: 294 active, 294 total ________ ________ .__ .__ .__ __ _____ ______ ____ ____ ______ _____ ___.__.| | |__| ____ | |___/ |_ / | ____ _/ __ / | | __ < | || | | |/ ___| | __ / | |_> > ___/| | | ` / __ ___ || |_| / /_/ > Y | _______ / __/ ___ >___| /_______ (____ / ____||____/_____ /|___| /__| /|__| / / / // /_____/ / Hit '<tab>' for a list of available commands and '[cmd] --help' for help on a specific command. Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight. opendaylight-user@root>log:display | grep Hallo 43 / 56 Build
  • 44.
    $ cat api/src/main/yang/hallo.yang modulehallo { yang-version 1; namespace "urn:opendaylight:params:xml:ns:yang:hallo"; prefix "hallo"; revision "2015-01-05" { description "Initial revision of hallo model"; } } $ rm api/src/main/yang/hallo.yang && nano api/src/main/yang/hallo.yang # new hallo.yang module hallo { yang-version 1; namespace "urn:opendaylight:params:xml:ns:yang:hallo"; prefix "hallo"; revision "2015-01-05" { description "Initial revision of hallo model"; } rpc hallo-world { input { leaf name { type string; } } output { leaf greeting { type string; } } } } $ cd api && mvn clean install -DskipTests ... [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 16.155 s [INFO] Finished at: 2018-02-05T05:10:55+07:00 [INFO] Final Memory: 55M/580M [INFO] ------------------------------------------------------------------------ 44 / 56 A Simple RPC API
  • 45.
    $ nano impl/src/main/java/org/opendaylight/hallo/impl/HalloWorldImpl.java /* *Copyright (c) 2016 ODL and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.hallo.impl; import java.util.concurrent.Future; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloS import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloW import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloW import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloW import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; public class HalloWorldImpl implements HalloService { @Override public Future<RpcResult<HalloWorldOutput>> halloWorld(HalloWorldInput input) { HalloWorldOutputBuilder halloBuilder = new HalloWorldOutputBuilder(); halloBuilder.setGreeting("Hallo " + input.getName()); return RpcResultBuilder.success(halloBuilder.build()).buildFuture(); } } ~/devfolder/hallo$ ll impl/src/main/java/org/opendaylight/hallo/impl/ total 16 drwxrwxr-x 2 em em 4096 Feb 5 05:20 ./ drwxrwxr-x 3 em em 4096 Feb 5 03:02 ../ -rw-rw-r-- 1 em em 1036 Feb 5 03:02 HalloProvider.java -rw-rw-r-- 1 em em 1302 Feb 5 05:20 HalloWorldImpl.java 45 / 56 HalloService
  • 46.
    $ cat impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml <?xmlversion="1.0" encoding="UTF-8"?> <!-- vi: set et smarttab sw=4 tabstop=4: --> <!-- Copyright (c) 2017 hallo inc. and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html --> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="default" /> <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/> <bean id="provider" class="org.opendaylight.hallo.impl.HalloProvider" init-method="init" destroy-method="close"> <argument ref="dataBroker" /> <argument ref="rpcRegistry" /> </bean> </blueprint> 46 / 56 RPC Registry Reference
  • 47.
    $ cat impl/src/main/java/org/opendaylight/hallo/impl/HalloProvider.java /* *Copyright (c) 2017 hallo inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.hallo.impl; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hallo.rev150105.HalloS import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HalloProvider { private static final Logger LOG = LoggerFactory.getLogger(HalloProvider.class); private final DataBroker dataBroker; private final RpcProviderRegistry rpcProviderRegistry; private RpcRegistration<HalloService> serviceRegistration; public HalloProvider(final DataBroker dataBroker,RpcProviderRegistry rpcProviderRegistry) this.dataBroker = dataBroker; this.rpcProviderRegistry = rpcProviderRegistry; } /** * Method called when the blueprint container is created. */ public void init() { serviceRegistration = rpcProviderRegistry.addRpcImplementation(HalloService.class, new LOG.info("HalloProvider Session Initiated"); } /** * Method called when the blueprint container is destroyed. */ public void close() { 47 / 56 HalloProvider
  • 48.
    $ cd impl&& mvn clean install -DskipTests ... [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 13.266 s [INFO] Finished at: 2018-02-05T05:31:13+07:00 [INFO] Final Memory: 56M/500M [INFO] ------------------------------------------------------------------------ $ cd .. && mvn clean install -DskipTests ... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] ODL :: org.opendaylight.hallo :: hallo-api ......... SUCCESS [ 28.781 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-impl ........ SUCCESS [ 14.900 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-cli ......... SUCCESS [ 13.989 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-features .... SUCCESS [ 12.178 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-karaf ....... SUCCESS [ 50.341 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-artifacts ... SUCCESS [ 1.773 s] [INFO] ODL :: org.opendaylight.hallo :: hallo-it .......... SUCCESS [ 27.518 s] [INFO] hallo .............................................. SUCCESS [ 28.513 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 03:02 min [INFO] Finished at: 2018-02-05T05:34:43+07:00 [INFO] Final Memory: 221M/673M [INFO] ------------------------------------------------------------------------ $ karaf/target/assembly/bin/karaf ... opendaylight-user@root>bundle:list | grep hallo 207 | Active | 80 | 0.1.0.SNAPSHOT | ODL :: org.opendaylight.hallo :: h 208 | Active | 80 | 0.1.0.SNAPSHOT | ODL :: org.opendaylight.hallo :: h opendaylight-user@root>feature:list | grep hallo odl-hallo-api | 0.1.0-SNAPSHOT | x | odl-hallo-0.1.0-SNAPSHOT odl-hallo | 0.1.0-SNAPSHOT | x | odl-hallo-0.1.0-SNAPSHOT odl-hallo-rest | 0.1.0-SNAPSHOT | x | odl-hallo-0.1.0-SNAPSHOT odl-hallo-ui | 0.1.0-SNAPSHOT | x | odl-hallo-0.1.0-SNAPSHOT odl hallo cli | 0 1 0 SNAPSHOT | | odl hallo 0 1 0 SNAPSHOT 48 / 56 Build
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
    Refs/Resources 1. Platform Overview- OpenDaylight 2. Using the OpenDaylight SDN Controller with the Mininet Network Emulator 3. ODL_Summit_OpenFlow_Tutorial 4. OpenDaylight User Guide - OpenDaylight Documentation Nitrogen documentation 5. Getting Started Guide - OpenDaylight Documentation Nitrogen documentation 6. OpenDaylight Application Developer's tutorial | SDN Hub 7. CiscoDevNet/yangman: YANGMAN o ers dynamically generated UI forms and native JSON representation based on RESTCONF APIs 8. OpenDaylight as a Platform for Network Programmability 9. OpenDaylight Controller:MD-SAL:Startup Project Archetype 10. Developing Apps on the OpenDaylight controller - Nitrogen 11. RFC 8040 - RESTCONF Protocol 55 / 56
  • 56.
    56 / 56 ENDEueungMulyana https://telematika.org/remark/odl CodeLabs | Attribution-ShareAlike CC BY-SA