Overview of Model-Driven SAL and Creating an Application based on - - PowerPoint PPT Presentation

overview of model driven sal and
SMART_READER_LITE
LIVE PREVIEW

Overview of Model-Driven SAL and Creating an Application based on - - PowerPoint PPT Presentation

Overview of Model-Driven SAL and Creating an Application based on MD-SAL Radhika Hirannaiah, OpenDaylight Project Open Networking Summit 2016 1 Goal Overviewing MD-SAL internals for application development 2 OpenDaylight SDN Controller


slide-1
SLIDE 1

Overview of Model-Driven SAL and Creating an Application based on MD-SAL

Radhika Hirannaiah, OpenDaylight Project

Open Networking Summit 2016

1

slide-2
SLIDE 2

Goal

  • Overviewing MD-SAL internals for application development

2

slide-3
SLIDE 3

OpenDaylight SDN Controller

  • Java-based, model-driven controller using YANG modeling language
  • Relies on the following technologies:
  • OSGI - Back-end framework of OpenDaylight that allows dynamically loading of

bundles and packages JAR files, and binding bundles together for exchanging information

  • Karaf - Application container built on top of OSGI, which simplifies operational

aspects of packaging and installing applications

  • YANG - a data modeling language used to model configuration and state data

manipulated by the applications, remote procedure calls, and notifications

  • Tools
  • IDE - IntelliJ IDEA or Eclipse
  • Java 1.7 or 1.8
  • Maven 3.2.3/3.3.x
  • Postman REST Client

3

slide-4
SLIDE 4

What is Model-Driven SAL(MD-SAL)?

  • OpenDaylight kernel, that interfaces

between different layers and modules

  • Uses APIs to connect and bind requests

and services

  • Service Abstraction Layer (SAL) introduces

an extra layer containing all the necessary logic to receive and delegate requests

  • Forwards incoming requests to Service

Providers (SPs) that returns service results through API to the Clients (Consumers)

4

slide-5
SLIDE 5

OpenDaylight Software Architecture

Controller

Model-Driven SAL (MD-SAL)

Protocol Plugin

RESTCONF

NETCONF SERVER

Network Devices Applications

App/Service Plugin App/Service Plugin

... ...

Protocol Plugin Config Subsystem

Messaging Data Store Remote Controller Instance Remote Controller Instance

Network Applications Orchestration & Services Controller Platform Plugins & Applications Clustering

Network Devices Network Devices Applications Applications

5

slide-6
SLIDE 6

Why MD-SAL?

  • Evolutionary step forward from object-oriented design of network

management systems

  • Agnostic model that supports any device and/or service models
  • Designed to stitch together the modules horizontally by allowing the

developer to use generic interfaces for service discovery and consumption

  • Provides “common” REST API to access data and functions defined in

models

6

slide-7
SLIDE 7

YANG (RFC 6020)

  • Modeling language that models

semantics and data organization

  • Models can be ‘augmented’
  • Can model:
  • Config/Operational data as a tree
  • RPCs
  • Notifications

7

slide-8
SLIDE 8

Remote Procedure Calls (RPCs)

  • Used for any call or invocation that crosses the plugin or module boundaries
  • Triggered by consumers
  • Communication is Unicast between consumer and provider
  • Consumer sends request message to provider responding with reply message
  • Models any procedure call implemented by a Provider (Server) exposing

functionality to Consumers (Clients)

  • Two types of RPCs –
  • Global – one service instance per controller container
  • Routed – multiple service instance per controller container

8

slide-9
SLIDE 9

RPCs – Sending a Message E.g:HelloWorld application

HelloService helloService= session.getRpcService(HelloService.class ); Future<RpcResult<HelloWorldOutput>> future; future= helloService .helloWorld(helloWorldInput); HelloWorldOutput helloWorldOutput = future.get().getResult();

9

consumer MD-SAL getRpcService() return: helloService helloService future helloWorld(helloWorldInput) return: future get() return: RpcResult<HelloWorldOutput> set(helloOutput)

slide-10
SLIDE 10

Global RPCs – processing a message – Sync HelloWorld application

public class HelloWorldImpl implements HelloService { public HelloWorldImpl(ProviderContext session){ session.addRpcImplementation( HelloService.class, this); } @Override public Future<RpcResult<HelloWorldOutput>> helloWorld(HelloWorldInput input) { /* construct output */ return RpcResultBuilder .success(helloWorldOutput) .buildFuture(); } }

10

MD-SAL addRpcImplementation(this) helloWorldImpl helloWorld(helloWorldInput) return: future

slide-11
SLIDE 11

Routed RPCs – E.g:HelloWorld application

public class HelloWorldImpl1 implements HelloService { public HelloWorldImpl(ProviderContext session){ RoutedRpcRegistration<HelloService> reg1 = session.addRoutedRpcImplementation( HelloService.class, this); reg1.registerPath(MyContext.class,iid1); } /* helloWorld() implementation works as before */ } public class HelloWorldImpl2 implements HelloService { public HelloWorldImpl(ProviderContext session){ RoutedRpcRegistration<HelloService> reg2 = session.addRoutedRpcImplementation( HelloService.class, this); reg2.registerPath(MyContext.class,iid2); } /* helloWorld() implementation works as before */ }

MD-SAL addRoutedRpcImplementation(this) helloWorldImpl1 helloWorld(helloWorldInput1) return: future reg1 return: reg2 registerPath(…) helloWorldImpl2 reg2 registerPath(…) addRoutedRpcImplementation(this) helloWorld(helloWorldInput2) return: future return: reg1

slide-12
SLIDE 12

RPC – OpenFlow application

  • Openflowplugdin/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java

import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; @Override public void setRpcProviderRegistry(final RpcProviderRegistry rpcProviderRegistry) { this.rpcProviderRegistry = rpcProviderRegistry; }

  • penflowplugin/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java

RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx .<SalFlowService> addRoutedRpcImplementation( SalFlowService.class, this); public RoutedRpcRegistration<SalFlowService> getFlowRegistration() { return flowRegistration; }

12

slide-13
SLIDE 13

OpenDaylight Platform

NETCONF

MD-SAL

...

Flow-Capable Node Inventory Manager Model

Statistics Manager

Model OpenFlow Topology

Exporter

Model BGP-LS Topology Exporter Model

Data Store

  • Yang data is a tree- all state-

related data are modeled and represented as data tree to address any element / subtree

  • Two Logical Data Stores
  • config
  • operational
  • Unified View
  • InstanceIdentifier:
  • Pointer to a node

13

p1 p2 BGP-LS BGPv4 BGPv6 nodes links prefixes n1 n2 nx l2 l1

... ...

lx

...

px OpenFlow Groups Table/1 nc:1 nc:2 /operational /config network-topo nodes Flow/2

  • f:1
  • f:2

Of:n

...

Tables Meters Table/2 Table/n Flow/1 Flow/n

...

Ports Table-stats Flow-stats Flow-stats

slide-14
SLIDE 14

Data Store Transactions

  • Multicast asynchronous communications, sent by Data Broker if there is change in conceptual data tree, and

is delivered to subscribed consumers

  • Data Stores:
  • Operational Data Tree - published by the providers using MD-SAL, represents a feedback loop for applications to observe

state of the network / system.

  • Configuration Data Tree - populated by consumers, represents intended state of the system / network
  • Transaction Types
  • Transactional modification to conceptual data tree - write transactions newWriteOnlyTransaction()
  • Transactional reads from current data tree and not affected by any subsequent write - read-only transactions

newReadOnlyTransaction()

  • Transaction provides both read and write capabilities – read-write transactions newReadWriteTransaction()

Modifications on Data tree:

  • Put – stores a piece of data on specified path, act as add/replace
  • void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
  • Merge – merges a piece of data on the existing data on specified path
  • void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
  • Delete – removes the whole subtree from the specified path
  • void delete(LogicalDatastoreType store, InstanceIdentifier<?> path);

14

slide-15
SLIDE 15

Simple Data Transaction Steps

Let assume initial state of data tree for PATH is A 1. Allocates new ReadWriteTransaction

ReadWriteTransaction rwTx = broker.newReadWriteTransaction();

2. Read from rwTx will return value A for PATH

rwRx.read(OPERATIONAL,PATH).get();

3. Writes value B to PATH using rwTx

rwRx.put(OPERATIONAL,PATH,B);

4. Read will return value B for PATH, since previous write occurred in same transaction

rwRx.read(OPERATIONAL,PATH).get();

5. Writes value C to PATH using rwTx

rwRx.put(OPERATIONAL,PATH,C);

6. Read will return value C for PATH, since previous write occurred in same transaction

rwRx.read(OPERATIONAL,PATH).get();

15

slide-16
SLIDE 16

Data Store – Transactions – Reading and Writing

16

ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); Optional<Node> nodeOptional; nodeOptional = transaction.read( LogicalDataStore.OPERATIONAL, n1InstanceIdentifier); transaction.put( LogicalDataStore.CONFIG, n2InstanceIdentifier, topologyNodeBuilder.build()); transaction.delete( LogicalDataStore.CONFIG, n3InstanceIdentifier); CheckedFuture future; future = transaction.submit();

n1 /operational /config network-topo BGPv4

  • verlay1

nodes nodes

Datastore

n3 n1

transaction

n2 n3

slide-17
SLIDE 17

E.g: HelloWorld & OpenFlow applications

public HelloWorldImpl(DataBroker db) { this.db = db; initializeDataTree(this.db); } WriteOnlyTransaction transaction = dataBroker.newWriteOnlyTransaction(); InstanceIdentifier<Node> path = InstanceIdentifier .create(NetworkTopology.class) .child(Topology.class, new TopologyKey(“overlay1”)); transaction.put( LogicalDataStore.CONFIG, path, topologyBuilder.build()); CheckedFuture future; future = transaction.submit();

  • penflowplugin/openflowplugin-

impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProvi derImpl.java @Override public void setDataBroker(final DataBroker dataBroker) { this.dataBroker = dataBroker; } ReadWriteTransaction modification = dataBroker.newReadWriteTransaction(); InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class) .child(Node.class, testNode12.getKey()).augmentation(FlowCapableNode.class) .child(Group.class, new GroupKey(group.getGroupId())); modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true); modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true); CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();

17

slide-18
SLIDE 18

Notifications

  • Represent asynchronous events with multicast communication, published by

providers for consumers

  • Used to model events originating in network devices or southbound plugins

that are exposed to consumers for listening

  • Defined with the notification statement:

notification { …. }

  • NotificationService – is a notification broker that allows clients to subscribe

and publish YANG-modeled notifications

  • NotificationPublishService.java - interface to publish any YANG-modeled

notification which will be delivered to all subscribed listeners

18

slide-19
SLIDE 19

E.g. OpenFlow application

import

  • rg.opendaylight.controller.md.sal.binding.api

.NotificationPublishService; import

  • rg.opendaylight.controller.md.sal.binding.api

.NotificationService; @Override public void setNotificationProviderService(final NotificationService notificationProviderService) { this.notificationProviderService = notificationProviderService; } @Override public void setNotificationPublishService(final NotificationPublishService notificationPublishProviderService) { this.notificationPublishService = notificationPublishProviderService; } Openflowplugin/test- provider/src/main/java/org/opendaylight/openflowplugin/test/Open flowpluginTestCommandProvider.java public void onSessionInitiated(final ProviderContext session) { notificationService = session.getSALService(NotificationService.clas s); // For switch events notificationService.registerNotificationListen er(flowEventListener); notificationService.registerNotificationListen er(nodeErrorListener); dataBroker = session.getSALService(DataBroker.class); ctx.registerService(CommandProvider.class.getN ame(), this, null); createTestFlow(createTestNode(null), null, null); }

19

slide-20
SLIDE 20

E.g. OpenFlow Pipeline Processing

20

Controller SAL/Core

OF Inventory (Operational) Forwarding Rules Manager OpenFlow Java OF Plugin

Data Change Notification Data Store Write

OF Switch OF Switch OF Switch

OF Topology Topology Manager OF Inventory (Configuration) NETCONF RESTCONF

OF Switch OF Switch Apps

RPCs/Notifications

OpenFlow 1.0/1.3 Inventory

slide-21
SLIDE 21

Using Futures for Logging

E.g. HelloWorld application - hello- world/impl/src/main/java/org/opendaylight/hel lo/impl/LoggingFuturesCallBack.java

public class LoggingFuturesCallBack<V> implements FutureCallback<V> { private Logger LOG; private String message; public LoggingFuturesCallBack(String message,Logger LOG) { this.message = message; this.LOG = LOG; } @Override public void onFailure(Throwable e) { LOG.warn(message,e); }

E.g. In OpenFlow application -

  • penflowplugin/test-

provider/src/main/java/org/opendaylight/openf lowplugin/test/OpenflowPluginBulkGroupTrans actionProvider.java

Futures.addCallback(commitFuture, new FutureCallback<Void>() { @Override public void

  • nSuccess(Void aVoid) {

ci.println("Status of Group Data Loaded Transaction: success.");

21

slide-22
SLIDE 22

Take-away: 3 Brokers

Notification Broker

publish notify

Data Broker

notify put store

RPC Broker

call

22

slide-23
SLIDE 23

Take-away: for Application Development

  • RPCs:

registerToHandle( RPC, implementation ) call( RPC, input ) => output

  • Data Store:

put( key, value ) get( key ) => value

  • Notifications:

subscribe( notification, callback ) create( notification, data )

23

slide-24
SLIDE 24

References

1. Controller Core Functionality Tutorials : Application Development Tutorial - https://wiki.opendaylight.org/view/Controller_Core_Functionality_Tutorials:Ap plication_Development_Tutorial 2. Open Daylight Controller: MD-SAL - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL 3. Developer Guide - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD- SAL:Developer_Guide 4. YANG - RFC 6020 - https://tools.ietf.org/html/rfc6020#section-4.2.10 5. GitHub - https://github.com/opendaylight/openflowplugin

24

slide-25
SLIDE 25

?

controller-dev@lists.opendaylight.org https://lists.opendaylight.org/mailman/listinfo radhikamh at gmail dot com

25