Teach NETCONF about YANG 1.1 actions in cluster topology
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / utils / NetconfTopologySetup.java
1 /*
2  * Copyright (c) 2017 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.netconf.topology.singleton.impl.utils;
9
10 import akka.actor.ActorSystem;
11 import com.google.common.util.concurrent.ListeningExecutorService;
12 import io.netty.util.concurrent.EventExecutor;
13 import java.util.concurrent.ScheduledExecutorService;
14 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
15 import org.opendaylight.mdsal.binding.api.DataBroker;
16 import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
17 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
18 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
19 import org.opendaylight.netconf.client.NetconfClientDispatcher;
20 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import scala.concurrent.duration.Duration;
24
25 public class NetconfTopologySetup {
26
27     private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
28     private final DOMRpcProviderService rpcProviderRegistry;
29     private final DOMActionProviderService actionProviderRegistry;
30     private final DataBroker dataBroker;
31     private final InstanceIdentifier<Node> instanceIdentifier;
32     private final Node node;
33     private final ScheduledExecutorService keepaliveExecutor;
34     private final ListeningExecutorService processingExecutor;
35     private final ActorSystem actorSystem;
36     private final EventExecutor eventExecutor;
37     private final NetconfClientDispatcher netconfClientDispatcher;
38     private final String topologyId;
39     private final NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
40     private final Duration idleTimeout;
41     private final String privateKeyPath;
42     private final String privateKeyPassphrase;
43     private final AAAEncryptionService encryptionService;
44
45     NetconfTopologySetup(final NetconfTopologySetupBuilder builder) {
46         this.clusterSingletonServiceProvider = builder.getClusterSingletonServiceProvider();
47         this.rpcProviderRegistry = builder.getRpcProviderRegistry();
48         this.actionProviderRegistry = builder.getActionProviderRegistry();
49         this.dataBroker = builder.getDataBroker();
50         this.instanceIdentifier = builder.getInstanceIdentifier();
51         this.node = builder.getNode();
52         this.keepaliveExecutor = builder.getKeepaliveExecutor();
53         this.processingExecutor = builder.getProcessingExecutor();
54         this.actorSystem = builder.getActorSystem();
55         this.eventExecutor = builder.getEventExecutor();
56         this.netconfClientDispatcher = builder.getNetconfClientDispatcher();
57         this.topologyId = builder.getTopologyId();
58         this.schemaResourceDTO = builder.getSchemaResourceDTO();
59         this.idleTimeout = builder.getIdleTimeout();
60         this.privateKeyPath = builder.getPrivateKeyPath();
61         this.privateKeyPassphrase = builder.getPrivateKeyPassphrase();
62         this.encryptionService = builder.getEncryptionService();
63     }
64
65     public ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
66         return clusterSingletonServiceProvider;
67     }
68
69     public DOMRpcProviderService getRpcProviderRegistry() {
70         return rpcProviderRegistry;
71     }
72
73     public DOMActionProviderService getActionProviderRegistry() {
74         return actionProviderRegistry;
75     }
76
77     public DataBroker getDataBroker() {
78         return dataBroker;
79     }
80
81     public InstanceIdentifier<Node> getInstanceIdentifier() {
82         return instanceIdentifier;
83     }
84
85     public Node getNode() {
86         return node;
87     }
88
89     public ListeningExecutorService getProcessingExecutor() {
90         return processingExecutor;
91     }
92
93     public ScheduledExecutorService getKeepaliveExecutor() {
94         return keepaliveExecutor;
95     }
96
97     public ActorSystem getActorSystem() {
98         return actorSystem;
99     }
100
101     public EventExecutor getEventExecutor() {
102         return eventExecutor;
103     }
104
105     public String getTopologyId() {
106         return topologyId;
107     }
108
109     public NetconfClientDispatcher getNetconfClientDispatcher() {
110         return netconfClientDispatcher;
111     }
112
113     public NetconfDevice.SchemaResourcesDTO getSchemaResourcesDTO() {
114         return schemaResourceDTO;
115     }
116
117     public Duration getIdleTimeout() {
118         return idleTimeout;
119     }
120
121     public String getPrivateKeyPath() {
122         return privateKeyPath;
123     }
124
125     public String getPrivateKeyPassphrase() {
126         return privateKeyPassphrase;
127     }
128
129     public AAAEncryptionService getEncryptionService() {
130         return encryptionService;
131     }
132
133     public static class NetconfTopologySetupBuilder {
134
135         private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
136         private DOMRpcProviderService rpcProviderRegistry;
137         private DOMActionProviderService actionProviderRegistry;
138         private DataBroker dataBroker;
139         private InstanceIdentifier<Node> instanceIdentifier;
140         private Node node;
141         private ScheduledExecutorService keepaliveExecutor;
142         private ListeningExecutorService processingExecutor;
143         private ActorSystem actorSystem;
144         private EventExecutor eventExecutor;
145         private String topologyId;
146         private NetconfClientDispatcher netconfClientDispatcher;
147         private NetconfDevice.SchemaResourcesDTO schemaResourceDTO;
148         private Duration idleTimeout;
149         private String privateKeyPath;
150         private String privateKeyPassphrase;
151         private AAAEncryptionService encryptionService;
152
153         public NetconfTopologySetupBuilder() {
154         }
155
156         private ClusterSingletonServiceProvider getClusterSingletonServiceProvider() {
157             return clusterSingletonServiceProvider;
158         }
159
160         public NetconfTopologySetupBuilder setClusterSingletonServiceProvider(
161                 final ClusterSingletonServiceProvider clusterSingletonServiceProvider) {
162             this.clusterSingletonServiceProvider = clusterSingletonServiceProvider;
163             return this;
164         }
165
166         private DOMRpcProviderService getRpcProviderRegistry() {
167             return rpcProviderRegistry;
168         }
169
170         public NetconfTopologySetupBuilder setRpcProviderRegistry(final DOMRpcProviderService rpcProviderRegistry) {
171             this.rpcProviderRegistry = rpcProviderRegistry;
172             return this;
173         }
174
175         private DOMActionProviderService getActionProviderRegistry() {
176             return actionProviderRegistry;
177         }
178
179         public NetconfTopologySetupBuilder setActionProviderRegistry(
180             final DOMActionProviderService actionProviderRegistry) {
181             this.actionProviderRegistry = actionProviderRegistry;
182             return this;
183         }
184
185         private DataBroker getDataBroker() {
186             return dataBroker;
187         }
188
189         public NetconfTopologySetupBuilder setDataBroker(final DataBroker dataBroker) {
190             this.dataBroker = dataBroker;
191             return this;
192         }
193
194         private InstanceIdentifier<Node> getInstanceIdentifier() {
195             return instanceIdentifier;
196         }
197
198         public NetconfTopologySetupBuilder setInstanceIdentifier(final InstanceIdentifier<Node> instanceIdentifier) {
199             this.instanceIdentifier = instanceIdentifier;
200             return this;
201         }
202
203         public Node getNode() {
204             return node;
205         }
206
207         public NetconfTopologySetupBuilder setNode(final Node node) {
208             this.node = node;
209             return this;
210         }
211
212         public NetconfTopologySetup build() {
213             return new NetconfTopologySetup(this);
214         }
215
216         private ScheduledExecutorService getKeepaliveExecutor() {
217             return keepaliveExecutor;
218         }
219
220         public NetconfTopologySetupBuilder setKeepaliveExecutor(final ScheduledExecutorService keepaliveExecutor) {
221             this.keepaliveExecutor = keepaliveExecutor;
222             return this;
223         }
224
225         private ListeningExecutorService getProcessingExecutor() {
226             return processingExecutor;
227         }
228
229         public NetconfTopologySetupBuilder setProcessingExecutor(final ListeningExecutorService processingExecutor) {
230             this.processingExecutor = processingExecutor;
231             return this;
232         }
233
234         private ActorSystem getActorSystem() {
235             return actorSystem;
236         }
237
238         public NetconfTopologySetupBuilder setActorSystem(final ActorSystem actorSystem) {
239             this.actorSystem = actorSystem;
240             return this;
241         }
242
243         private EventExecutor getEventExecutor() {
244             return eventExecutor;
245         }
246
247         public NetconfTopologySetupBuilder setEventExecutor(final EventExecutor eventExecutor) {
248             this.eventExecutor = eventExecutor;
249             return this;
250         }
251
252         private String getTopologyId() {
253             return topologyId;
254         }
255
256         public NetconfTopologySetupBuilder setTopologyId(final String topologyId) {
257             this.topologyId = topologyId;
258             return this;
259         }
260
261         private NetconfClientDispatcher getNetconfClientDispatcher() {
262             return netconfClientDispatcher;
263         }
264
265         public NetconfTopologySetupBuilder setNetconfClientDispatcher(final NetconfClientDispatcher clientDispatcher) {
266             this.netconfClientDispatcher = clientDispatcher;
267             return this;
268         }
269
270         public NetconfTopologySetupBuilder setSchemaResourceDTO(
271                 final NetconfDevice.SchemaResourcesDTO schemaResourceDTO) {
272             this.schemaResourceDTO = schemaResourceDTO;
273             return this;
274         }
275
276         private NetconfDevice.SchemaResourcesDTO getSchemaResourceDTO() {
277             return schemaResourceDTO;
278         }
279
280         public NetconfTopologySetupBuilder setIdleTimeout(final Duration idleTimeout) {
281             this.idleTimeout = idleTimeout;
282             return this;
283         }
284
285         private Duration getIdleTimeout() {
286             return idleTimeout;
287         }
288
289         public NetconfTopologySetupBuilder setPrivateKeyPath(final String privateKeyPath) {
290             this.privateKeyPath = privateKeyPath;
291             return this;
292         }
293
294         public String getPrivateKeyPath() {
295             return this.privateKeyPath;
296         }
297
298         public NetconfTopologySetupBuilder setPrivateKeyPassphrase(final String privateKeyPassphrase) {
299             this.privateKeyPassphrase = privateKeyPassphrase;
300             return this;
301         }
302
303         public String getPrivateKeyPassphrase() {
304             return this.privateKeyPassphrase;
305         }
306
307         private AAAEncryptionService getEncryptionService() {
308             return this.encryptionService;
309         }
310
311         public NetconfTopologySetupBuilder setEncryptionService(final AAAEncryptionService encryptionService) {
312             this.encryptionService = encryptionService;
313             return this;
314         }
315
316         public static NetconfTopologySetupBuilder create() {
317             return new NetconfTopologySetupBuilder();
318         }
319     }
320
321
322 }