22
Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

  • Upload
    lenhi

  • View
    227

  • Download
    5

Embed Size (px)

Citation preview

Page 1: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Developing OpenDaylight Apps

with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga

Cisco Sample App: M. Rehak, Cisco

February 04, 2014

Page 2: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Controller Architecture

Example:  Service  Provider  Edi2on  

Base  Network  Service  Func3ons      

Management    GUI/CLI  

Controller  Pla?orm  

Southbound  Interfaces  &  Protocol  Plugins  

OpenDaylight  APIs  (REST)  

Data  Plane  Elements  (Virtual  Switches,  

Physical  Device  Interfaces)  

Service  Abstrac3on  Layer  (SAL)  (plug-­‐in  mgr.,  capability  abstrac3ons,  flow  programming,  inventory,  …)  

OpenFlow  

1.0   1.3  LISP  

Topology  Mgr  

Stats  Mgr  

Switch  Mgr  

Affinity  Service  

Network  Applica3ons  Orchestra3on  &  Services  

OpenFlow  Enabled  Devices  

LISP  Service  

NETCONF   BGP  

Addi2onal  Virtual  &  Physical  Devices  

SNMP  

D4A  Protec3on  

Open  vSwitches  

PCEP  OVSDB  

FRM  ARP  

Handler  Host  Tracker  

Page 3: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Hydrogen Implementation

Model-­‐Driven  SAL  (MD-­‐SAL)  API-­‐Driven  SAL  (AD-­‐SAL)  

Base  Network  Service  Func3ons    

Topology  Mgr  

Stats  Mgr  

Switch  Mgr  

FRM   ARP  Handler  

Host  Tracker  

Affinity  Service  

LISP  Service  

Service  Func3ons  Topology  Exporter  

Topology  Exporter  

Topology  Exporter  

Topology  Exporter  

Topology  Exporter  Inventor

y  Manager  

Base  Network  Func3ons    

Config  Subsystem  

NSF  Adapters  NSF  Adapters  NSF  Adapters   PCEP  Stats  Mgr  

FRM  

OpenFlow  1.0   1.3  

OpenFlow  Enabled  Devices  

NETCONF  

Addi2onal  Virtual  &  Physical  Devices  Open  vSwitches  

PCEP  BGP-­‐LS  SNMP  LISP  OVSDB  OpenFlow  

1.0  

RESTCONF  REST  REST  REST  REST  REST  REST  REST  REST  

Management    GUI/CLI   D4A  Protec3on  

Example:  Service  Provider  Edi2on  

NETCONF  

Page 4: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

MD-SAL – Motivation & Requirements •  Flexibility,  but  common  framework  and  programming  model  

•  Support  API  governance  •  Func2onally  equivalent  APIs  for  different  language  bindings  

• Run-­‐2me  Extensibility:  •  Augment  exis2ng  func2onality  •  Load  new  models  (extends  controller’s  func2onality)  

• Avoid  module/sub-­‐system  hotspots  • Performance  &  scale  

Page 5: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

From AD-SAL to MD-SAL

Controller  PlaPorm  

SB  Plugin  1   SB  Plugin  2  

Service  Plugin  1  

Service  Plugin  1  

AD-­‐SAL  

Adapta2on  Request  Rou2ng  

Plugin  NB  Java  API  

REST  API  

Plugin  SB  Java  API  

REST  API  

Service  NB  Java  API  

...  

...  

Controller  PlaPorm  

SB  Plugin  1   SB  Plugin  2  

Service  Plugin  1  

Service  Plugin  1  

MD-­‐SAL  Modeled  SB  Java  API  

RESTCONF  

Modeled  Service  NB  Java  API  

...  

Request    Rou2ng  

SB  Plugin  Model  

“Is  generated  from”  

NB  Service  Model  

“Is  generated  from”  

SB  Model  Data   NB  Model  

Data  Data  Store  

Adapta3on  Plugin  

AD-­‐SAL  key  services:  •  Request  rou2ng  •  Service  Adapta2on  

MD-­‐SAL  key  services:  •  Request  (RPC)  and  no2fica2on  rou2ng  •  Data  Storage  

Page 6: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

MD-SAL – Key Tenets Summary

• Modeling  language:  YANG  (rfc6020)  •  Used  also  as  IDL  •  A  couple  of  minor  extensions  

• Dynamic  late  binding  • Run2me  &  Compile  2me  code  genera2on  

Page 7: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Creating the View of the Network

Controller  PlaPorm  

NETCONF  

MD-­‐SAL  

...  BGP-­‐LS  Topology  

Exporter    

OpenFlow  Topology  Exporter  

 

Flow-­‐Capable  Node  Inventory  Manager  

 Model  

/Opera2onal   /Config  

network-­‐topo  

BGP-­‐LS  BGPv4   BGPv6  

nodes   links   prefixes  

n1   n2   nx   l2  l1  ...   ...   lx   p1   p2   ...   px  

OpenFlow  

nodes  

nc:1   nc:2  

BGP-­‐LS  Protocol  Plugin  

of:1   of:2  Of:n  

...  

Groups   Tables   Meters   Ports  

Table/2  Table/1   Table/n  

Flow/1  Flow/2  

Flow/n  ...  Table-­‐stats  

Flow-­‐stats  Flow-­‐stats  

Sta3s3cs  Manager    

Model  Model  Model  

Page 8: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

MD-SAL: Software Architecture View

Model-­‐Driven  SAL  (MD-­‐SAL)  

Config  Subsystem  

RESTCONF  

App  

NETCONF  

Protocol  Plugin    Model  

Service/App  Plugin  

 Model  

Protocol  Plugin    Model  

Service/App  Plugin  

 Model  ...  ...  

Network  Devices   ...   App  

Controller  Pla?orm  

Southbound  Interfaces  &  Protocol  Plugins  

Network  Applica3ons  Orchestra3on  &  Services  

Data  Plane  Elements  

Clustering  Data  Store  Message  Bus  

Remote  Container  Instance   Remote  Container  Instance  

Page 9: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Building a Plugin/Application

Model  Model  Yang  Model  

Java  API  Defini2on  Java  API  Defini2on  Generated  API  Defini2on  

Module  Implementa2ons  

Yang  Tools  

“Plugin”  OSGI  Bundle  

1  

4  

Generate  APIs  

Create  Plugin  Bundle  Deploy  

Maven  Build  Tools  

Module  Implementa2ons  Plugin  source  code  

“API”    OSGI  Bundle  

Maven  Build  Tools  

2  

3  

Create  API  Bundle  

4  

Deploy  

Controller  

Page 10: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

The Learning Switch Application

•  Inspired  by  ‘OpenDaylight  Applica2on  Developers’  Tutorial:  hdp://sdnhub.org/tutorials/opendaylight/  

• ODL  Wiki:  TBD.  •  Func2onality:  

•  Create  a  HashMap  called  mac_to_port  •  On  packet_in,  Pprse  packet  to  get  src  and  dst  MAC  address    •  Store  in  a  hashmap  mapping  between  src_mac  and  in_port    •  Lookup  dst_mac  in  mac_to_port  map  to  find  next  hop    •  If  next  hop  is  found,  create  flow_mod  and  send  •  Else,  flood  like  hub.  

Page 11: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

N  

Under the Hood: How it Works

Controller  PlaPorm  

The  Learning  Switch  Applica3on  

Openflow  Protocol  Model  (Pkt  in,Pkt  out)   OpenFlow  1.0/1.3  Plugin  

OpenFlow  Java  Library  

MD-­‐SAL  

Switch  

No2fica2on  Delivery  

Request    Rou2ng  

1  

2  

3  

4  

5  

6  

7  

/config  

Flow  

FRM  

Request    Rou2ng  

RESTCONF  

Flow-­‐capable  Node  Model  (Flow  programming)  

8  

9  

10  

11  

12  

13  

NoBficaBon   RPC   RPC  

FlowMod  PktOut  PktIn  

Page 12: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Building the Sample Application •  Prerequisites:    

•  Java  7,  Maven  3.0.5  or  later,  Linux  or  Mac  •  Mininet  2.1  with  OpenFlow  1.3  virtual  switches  or  CPQD  (pointers)  •  OpenDaylight  Base  Edi2on  (download  &  installa2on  instruc2ons)  

•  Download  the  applica2on  code  from  ODL  OpenFlow  Plugin  repo:  >  git  clone  https://git.opendaylight.org/gerrit/p/openflowplugin.git  

•  Build  the  applica2on:  >  cd    openflowplugin/samples/learning-­‐switch/  >  mvn  clean  install  

•  The  build  creates  the  ‘learning-­‐switch-­‐0.0.3-­‐SNAPSHOT.jar’  bundle    in  ‘openflowplugin/samples/learning-­‐switch/target’  

•  Analyzing  code  in  Eclipse:  •  Prerequisites:  Install  maven  plugin  for  Eclipse  

•  More  informa2on:  •  hdps://wiki.opendaylight.org/view/OpenDaylight_Controller:Hydrogen_Developer_Guide:MD-­‐

SAL_App_Tutorial  

Page 13: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Starting the Environment •  Prequisites:    

•  Java  7,  Maven  3.0.5  or  later,  on  Linux  or  Mac  •  Mininet  2.1  with  OpenFlow  1.3  virtual  switches:  or  CPQD  

•  Download  OpenDaylight  Base  Edi2on:  hdps://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integra2on/distribu2ons-­‐base/0.1.1/  

•  Prepare  the  controller  &  applica2on:  •  Unzip  the  downloaded  controller  package  •  Delete  the  ‘Simple  Forwarding  Applica2on’  bundle  from  the  distribu2on:  

>  rm  opendaylight/plugins/org.opendaylight.controller.samples.simpleforwarding-­‐0.4.1.jar  

•  Upload  the  created  bundle:    Put  the  ‘learning-­‐switch-­‐0.0.3-­‐SNAPSHOT.jar’  bundle  into  the  ‘opendaylight/plugins’  folder  

•  Update  logger  configura2on:  Op2onally,  add  the  following  line  to  configura2on/logback.xml  file:  <logger  name="org.opendaylight.openflowplugin.learningswitch"  level="TRACE"/>  

 

Page 14: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Starting the Environment (Continued) •  Run  the  controller:  

>  ./run.sh  -­‐of13  

•  Check  that  the  applica2on  bundle  is  ac2ve.  On  the  controller  console,  type:  osgi  >  lb  learn  

•  You  should  see  something  like:  START  LEVEL  6        ID|State            |Level|Name      103|Active          |        4|learning-­‐switch  (0.0.3.SNAPSHOT)  osgi>    

•  Op2onally,  check  that  the  controller  is  listening  on  Ports  6633  and  6653.    On  a  Linux  console,  type:  >  netstat  -­‐lnp  |  grep  'java’  On  a  Mac  OSX  console,  type:  >  lsof  -­‐i  |  grep  LISTEN  |grep  java  

•  Start  Mininet:  >  sudo  mn  -­‐-­‐topo  single,10    -­‐-­‐controller  'remote,ip=<controller-­‐ip-­‐address>,port=6633'  -­‐-­‐switch  ovsk,protocols=OpenFlow13  

Page 15: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Core Concepts: Instance Identifier

• Unique  iden2fier  of  an  element  (loca2on)  in  the  yang  data  tree;    

•  Basically,  the  path  to  the  node  that  uniquely  iden2fies  all  the  node's  parent  nodes  

•  Examples:    •  Java:  

InstanceIdentifier<Node>  identifier  =  InstanceIdentifier.builder(Nodes.class).child(Node.class,new  NodeKey("foo")).build();  

 •  REST:  

http://localhost:8080/restconf/config/inventory:nodes/node/foo  

Page 16: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Running & Troubleshooting the App

• Use  RESTCONF  to  validate  that  the  app  started  and  installed  the  ini2al  flow  into  the  switch:  On  a  REST  console,  issue:  GET  http://<contr-­‐ip-­‐address>:8080/restconf/operational/opendaylight-­‐inventory:nodes/node/openflow:1/table/0  Accept  Header:  application/xml  

There  should  be  one  flow  on  the  switch  forwarding  all  packets  to  the  controller  

• On  Mininet,  issue  pings  between  each  pair  of  hosts:  mininet>  pingall  

6  more  flows  should  be  installed  in  the  host.  

Page 17: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Other Things to Explore

•  Try  a  network  of  switches;  start  Mininet  with:  sudo  mn  -­‐-­‐topo  tree,3    -­‐-­‐controller  'remote,ip=192.168.4.1:6653'  -­‐-­‐switch  ovsk,protocols=OpenFlow13  

Page 18: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Summary

• OpenDaylight:  •  Controller  PlaPorm  •  Model-­‐Driven  Applica2on  Development  Environment  

Page 19: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

Backup

Page 20: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

N  

BGP-LS Flow

Controller  PlaPorm  

BGP-­‐LS  Topology  Exporter  

Openflow  Protocol  Model  (Pkt  in,Pkt  out)  

BGP-­‐LS  Plugin  

MD-­‐SAL  

1  

2  

3  

4  

5  

6  

/oper  

BGP-­‐LS  Topology  

RESTCONF  

Flow-­‐capable  Node  Model  (Flow  programming)  

MD-­‐SAL  Set  

BGP  PDU  

/oper  

BGP-­‐RIB  

MD-­‐SAL  NoBficaBon   MD-­‐SAL  Set  

Page 21: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

BGP-LS System Flow

Page 22: Developing OpenDaylight Apps with MD-SAL · Developing OpenDaylight Apps with MD-SAL J. Medved, E. Warnicke, A. Tkacik. R. Varga Cisco Sample App: M. Rehak, Cisco February 04, 2014

[Sub-Section Title]