Stores and gets IP address of a flow capable node
[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.inventory.rev130819.FlowNodeInventoryService;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
29 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
30 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
31 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
32
33 /**
34  * RPC abstract for MD-switch
35  */
36 public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
37
38     private final InstanceIdentifier<Node> identifier;
39
40     private RoutedRpcRegistration<SalFlowService> flowRegistration;
41
42     private RoutedRpcRegistration<SalGroupService> groupRegistration;
43     
44     private RoutedRpcRegistration<SalTableService> tableRegistration;
45
46     private RoutedRpcRegistration<SalMeterService> meterRegistration;
47     
48     private RoutedRpcRegistration<SalPortService> portRegistration;
49
50     private RoutedRpcRegistration<PacketProcessingService> packetRegistration;
51
52     private RoutedRpcRegistration<OpendaylightFlowStatisticsService> flowStatisticsRegistration;
53
54     private RoutedRpcRegistration<OpendaylightGroupStatisticsService> groupStatisticsRegistration;
55
56     private RoutedRpcRegistration<OpendaylightMeterStatisticsService> meterStatisticsRegistration;
57
58     private RoutedRpcRegistration<OpendaylightPortStatisticsService> portStatisticsRegistration;
59
60     private RoutedRpcRegistration<OpendaylightFlowTableStatisticsService> flowTableStatisticsRegistration;
61
62     private RoutedRpcRegistration<OpendaylightQueueStatisticsService> queueStatisticsRegistration;
63
64     private RoutedRpcRegistration<FlowNodeInventoryService> flowNodeInventoryRegistration;
65
66     protected final SessionContext sessionContext;
67
68     protected AbstractModelDrivenSwitch(InstanceIdentifier<Node> identifier,SessionContext conductor) {
69         this.identifier = identifier;
70         this.sessionContext = conductor;
71     }
72
73     @Override
74     public final InstanceIdentifier<Node> getIdentifier() {
75         return this.identifier;
76     }
77
78     @Override
79     public CompositeObjectRegistration<ModelDrivenSwitch> register(ProviderContext ctx) {
80         CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
81                 .<ModelDrivenSwitch> builderFor(this);
82
83         flowRegistration = ctx.addRoutedRpcImplementation(SalFlowService.class, this);
84         flowRegistration.registerPath(NodeContext.class, getIdentifier());
85         builder.add(flowRegistration);
86         
87         portRegistration = ctx.addRoutedRpcImplementation(SalPortService.class, this);
88         portRegistration.registerPath(NodeContext.class, getIdentifier());
89         builder.add(portRegistration);
90
91         meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService.class, this);
92         meterRegistration.registerPath(NodeContext.class, getIdentifier());
93         builder.add(meterRegistration);
94
95         groupRegistration = ctx.addRoutedRpcImplementation(SalGroupService.class, this);
96         groupRegistration.registerPath(NodeContext.class, getIdentifier());
97         builder.add(groupRegistration);
98         
99         tableRegistration = ctx.addRoutedRpcImplementation(SalTableService.class, this);
100         tableRegistration.registerPath(NodeContext.class, getIdentifier());
101         builder.add(tableRegistration);
102
103         packetRegistration = ctx.addRoutedRpcImplementation(PacketProcessingService.class, this);
104         packetRegistration.registerPath(NodeContext.class, getIdentifier());
105         builder.add(packetRegistration);
106
107         flowStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowStatisticsService.class, this);
108         flowStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
109         builder.add(flowStatisticsRegistration);
110
111         groupStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightGroupStatisticsService.class, this);
112         groupStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
113         builder.add(groupStatisticsRegistration);
114
115         meterStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightMeterStatisticsService.class, this);
116         meterStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
117         builder.add(meterStatisticsRegistration);
118
119         portStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightPortStatisticsService.class, this);
120         portStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
121         builder.add(portStatisticsRegistration);
122
123         flowTableStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightFlowTableStatisticsService.class, this);
124         flowTableStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
125         builder.add(flowTableStatisticsRegistration);
126         
127         queueStatisticsRegistration = ctx.addRoutedRpcImplementation(OpendaylightQueueStatisticsService.class, this);
128         queueStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
129         builder.add(queueStatisticsRegistration);
130
131         flowNodeInventoryRegistration = ctx.addRoutedRpcImplementation(FlowNodeInventoryService.class, this);
132         flowNodeInventoryRegistration.registerPath(NodeContext.class, getIdentifier());
133         builder.add(flowNodeInventoryRegistration);
134
135         return builder.toInstance();
136     }
137
138     /**
139      * @return session context 
140      */
141     public SessionContext getSessionContext() {
142         return sessionContext;
143     }
144
145 }