Overview of Model-Driven SAL and Creating an Application based on MD-SAL
Radhika Hirannaiah, OpenDaylight Project
Open Networking Summit 2016
1
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
1
2
bundles and packages JAR files, and binding bundles together for exchanging information
aspects of packaging and installing applications
manipulated by the applications, remote procedure calls, and notifications
3
4
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
6
7
8
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)
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
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
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; @Override public void setRpcProviderRegistry(final RpcProviderRegistry rpcProviderRegistry) { this.rpcProviderRegistry = rpcProviderRegistry; }
RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx .<SalFlowService> addRoutedRpcImplementation( SalFlowService.class, this); public RoutedRpcRegistration<SalFlowService> getFlowRegistration() { return flowRegistration; }
12
OpenDaylight Platform
NETCONF
MD-SAL
Flow-Capable Node Inventory Manager Model
Statistics Manager
Model OpenFlow Topology
Exporter
Model BGP-LS Topology Exporter Model
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
Of:n
...
Tables Meters Table/2 Table/n Flow/1 Flow/n
...
Ports Table-stats Flow-stats Flow-stats
is delivered to subscribed consumers
state of the network / system.
newReadOnlyTransaction()
Modifications on Data tree:
14
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
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
nodes nodes
Datastore
n3 n1
transaction
n2 n3
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();
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
18
import
.NotificationPublishService; import
.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
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
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 -
provider/src/main/java/org/opendaylight/openf lowplugin/test/OpenflowPluginBulkGroupTrans actionProvider.java
Futures.addCallback(commitFuture, new FutureCallback<Void>() { @Override public void
ci.println("Status of Group Data Loaded Transaction: success.");
21
Notification Broker
publish notify
Data Broker
notify put store
RPC Broker
call
22
23
24
25