updated to tp_src, nw_tos match issue and setting actionslist for OF1.0,
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / AbstractModelDrivenSwitch.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.openflow.md.core.sal;
9
10 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
11 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
12 import org.opendaylight.openflowplugin.openflow.md.ModelDrivenSwitch;
13 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
26 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
27 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
28 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29
30 /**
31  * RPC abstract for MD-switch
32  */
33 public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
34
35     private final InstanceIdentifier<Node> identifier;
36
37     private RoutedRpcRegistration<SalFlowService> flowRegistration;
38
39     private RoutedRpcRegistration<SalGroupService> groupRegistration;
40
41     private RoutedRpcRegistration<SalMeterService> meterRegistration;
42
43     private RoutedRpcRegistration<PacketProcessingService> packetRegistration;
44     
45     private RoutedRpcRegistration<OpendaylightFlowStatisticsService> flowStatisticsRegistration;
46
47     private RoutedRpcRegistration<OpendaylightGroupStatisticsService> groupStatisticsRegistration;
48
49     private RoutedRpcRegistration<OpendaylightMeterStatisticsService> meterStatisticsRegistration;
50
51     private RoutedRpcRegistration<OpendaylightPortStatisticsService> portStatisticsRegistration;
52
53     private RoutedRpcRegistration<OpendaylightFlowTableStatisticsService> flowTableStatisticsRegistration;
54
55     private RoutedRpcRegistration<OpendaylightQueueStatisticsService> queueStatisticsRegistration;
56
57     protected final SessionContext sessionContext;
58
59     protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
60         this.identifier = identifier;
61         this.sessionContext = conductor;
62     }
63
64     @Override
65     public final InstanceIdentifier<Node> getIdentifier() {
66         return this.identifier;
67     }
68
69     @Override
70     public CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx) {
71         CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
72                 .<ModelDrivenSwitch> builderFor(this);
73
74         flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this);
75         flowRegistration.registerPath(NodeContext.class, getIdentifier());
76         builder.add(flowRegistration);
77
78         meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this);
79         meterRegistration.registerPath(NodeContext.class, getIdentifier());
80         builder.add(meterRegistration);
81
82         groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this);
83         groupRegistration.registerPath(NodeContext.class, getIdentifier());
84         builder.add(groupRegistration);
85
86         packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
87         packetRegistration.registerPath(NodeContext.class, getIdentifier());
88         builder.add(packetRegistration);
89
90         flowStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowStatisticsService.class, this);
91         flowStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
92         builder.add(flowStatisticsRegistration);
93
94         groupStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this);
95         groupStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
96         builder.add(groupStatisticsRegistration);
97
98         meterStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightMeterStatisticsService.class, this);
99         meterStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
100         builder.add(meterStatisticsRegistration);
101
102         portStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightPortStatisticsService.class, this);
103         portStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
104         builder.add(portStatisticsRegistration);
105
106         flowTableStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowTableStatisticsService.class, this);
107         flowTableStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
108         builder.add(flowTableStatisticsRegistration);
109         
110         queueStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightQueueStatisticsService.class, this);
111         queueStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
112         builder.add(queueStatisticsRegistration);
113
114         return builder.toInstance();
115     }
116
117     /**
118      * @return session context 
119      */
120     public SessionContext getSessionContext() {
121         return sessionContext;
122     }
123
124 }