a26a8b589790b37eeea01f7578316bb3773c9a34
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / config / Configuration.java
1 /*
2  * Copyright (c) 2014 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.test.tool.config;
9
10 import com.google.common.collect.ImmutableSet;
11 import java.io.File;
12 import java.util.Set;
13 import java.util.concurrent.TimeUnit;
14 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
15 import org.opendaylight.netconf.auth.AuthProvider;
16 import org.opendaylight.netconf.shaded.sshd.server.auth.pubkey.PublickeyAuthenticator;
17 import org.opendaylight.netconf.test.tool.operations.OperationsCreator;
18 import org.opendaylight.netconf.test.tool.rpchandler.RpcHandler;
19 import org.opendaylight.netconf.test.tool.rpchandler.RpcHandlerDefault;
20 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 public class Configuration {
25
26     private static final Logger LOG = LoggerFactory.getLogger(Configuration.class);
27
28     public static final Set<String> DEFAULT_BASE_CAPABILITIES_EXI = ImmutableSet.of(
29             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
30             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1,
31             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_EXI_1_0
32     );
33
34     public static final Set<String> DEFAULT_BASE_CAPABILITIES = ImmutableSet.of(
35             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0,
36             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1
37     );
38
39     public static final Set<YangResource> DEFAULT_YANG_RESOURCES = ImmutableSet.of(
40             new YangResource("ietf-netconf-monitoring", "2010-10-04",
41                     "/META-INF/yang/ietf-netconf-monitoring@2010-10-04.yang"),
42             new YangResource("ietf-netconf-monitoring-extension", "2013-12-10",
43                     "/META-INF/yang/ietf-netconf-monitoring-extension@2013-12-10.yang"),
44             new YangResource("ietf-yang-types", "2013-07-15",
45                     "/META-INF/yang/ietf-yang-types@2013-07-15.yang"),
46             new YangResource("ietf-inet-types", "2013-07-15",
47                     "/META-INF/yang/ietf-inet-types@2013-07-15.yang")
48     );
49
50     public static final AuthProvider DEFAULT_AUTH_PROVIDER = (username, password) -> {
51         LOG.info("Auth with username and password: {}", username);
52         return true;
53     };
54
55     public static final PublickeyAuthenticator DEFAULT_PUBLIC_KEY_AUTHENTICATOR = (username, key, session) -> {
56         LOG.info("Auth with public key: {}", key);
57         return true;
58     };
59
60     private int generateConfigsTimeout = (int) TimeUnit.MINUTES.toMillis(30);
61     private int threadPoolSize = 8;
62     private int startingPort = 17830;
63     private int deviceCount = 1;
64     private boolean ssh = true;
65     private String ip = "0.0.0.0";
66     private Set<YangResource> defaultYangResources = DEFAULT_YANG_RESOURCES;
67
68     private Set<YangModuleInfo> models;
69     private Set<String> capabilities = DEFAULT_BASE_CAPABILITIES_EXI;
70     private RpcHandler rpcHandler = new RpcHandlerDefault();
71     private OperationsCreator operationsCreator;
72     private AuthProvider authProvider = DEFAULT_AUTH_PROVIDER;
73     private PublickeyAuthenticator publickeyAuthenticator = DEFAULT_PUBLIC_KEY_AUTHENTICATOR;
74
75     @Deprecated
76     private boolean mdSal = false;
77
78     @Deprecated
79     private File rpcConfigFile;
80
81     @Deprecated
82     private File notificationFile;
83
84     @Deprecated
85     private File initialConfigXMLFile;
86
87     @Deprecated
88     private File schemasDir;
89
90     public Configuration() {
91     }
92
93     public PublickeyAuthenticator getPublickeyAuthenticator() {
94         return publickeyAuthenticator;
95     }
96
97     public void setPublickeyAuthenticator(final PublickeyAuthenticator publickeyAuthenticator) {
98         this.publickeyAuthenticator = publickeyAuthenticator;
99     }
100
101     public AuthProvider getAuthProvider() {
102         return authProvider;
103     }
104
105     public void setAuthProvider(final AuthProvider authProvider) {
106         this.authProvider = authProvider;
107     }
108
109     public Set<YangResource> getDefaultYangResources() {
110         return defaultYangResources;
111     }
112
113     public void setDefaultYangResources(final Set<YangResource> defaultYangResources) {
114         this.defaultYangResources = defaultYangResources;
115     }
116
117     public int getThreadPoolSize() {
118         return threadPoolSize;
119     }
120
121     public void setThreadPoolSize(final int threadPoolSize) {
122         this.threadPoolSize = threadPoolSize;
123     }
124
125     public int getStartingPort() {
126         return startingPort;
127     }
128
129     public void setStartingPort(final int startingPort) {
130         this.startingPort = startingPort;
131     }
132
133     public int getDeviceCount() {
134         return deviceCount;
135     }
136
137     public void setDeviceCount(final int deviceCount) {
138         this.deviceCount = deviceCount;
139     }
140
141     public int getGenerateConfigsTimeout() {
142         return generateConfigsTimeout;
143     }
144
145     public void setGenerateConfigsTimeout(final int generateConfigsTimeout) {
146         this.generateConfigsTimeout = generateConfigsTimeout;
147     }
148
149     public boolean isSsh() {
150         return ssh;
151     }
152
153     public void setSsh(final boolean ssh) {
154         this.ssh = ssh;
155     }
156
157     public String getIp() {
158         return ip;
159     }
160
161     public void setIp(final String ip) {
162         this.ip = ip;
163     }
164
165     public Set<YangModuleInfo> getModels() {
166         return models;
167     }
168
169     public void setModels(final Set<YangModuleInfo> models) {
170         this.models = models;
171     }
172
173     public Set<String> getCapabilities() {
174         return capabilities;
175     }
176
177     public void setCapabilities(final Set<String> capabilities) {
178         this.capabilities = capabilities;
179     }
180
181     public RpcHandler getRpcHandler() {
182         return rpcHandler;
183     }
184
185     public void setRpcHandler(final RpcHandler rpcHandler) {
186         this.rpcHandler = rpcHandler;
187     }
188
189     public OperationsCreator getOperationsCreator() {
190         return operationsCreator;
191     }
192
193     public void setOperationsCreator(final OperationsCreator operationsCreator) {
194         this.operationsCreator = operationsCreator;
195     }
196
197     @Deprecated
198     public boolean isMdSal() {
199         return mdSal;
200     }
201
202     @Deprecated
203     public void setMdSal(final boolean mdSal) {
204         this.mdSal = mdSal;
205     }
206
207     @Deprecated
208     public File getRpcConfigFile() {
209         return rpcConfigFile;
210     }
211
212     @Deprecated
213     public void setRpcConfigFile(final File rpcConfigFile) {
214         this.rpcConfigFile = rpcConfigFile;
215     }
216
217     @Deprecated
218     public File getNotificationFile() {
219         return notificationFile;
220     }
221
222     @Deprecated
223     public void setNotificationFile(final File notificationFile) {
224         this.notificationFile = notificationFile;
225     }
226
227     @Deprecated
228     public File getInitialConfigXMLFile() {
229         return initialConfigXMLFile;
230     }
231
232     @Deprecated
233     public void setInitialConfigXMLFile(final File initialConfigXMLFile) {
234         this.initialConfigXMLFile = initialConfigXMLFile;
235     }
236
237     @Deprecated
238     public boolean isXmlConfigurationProvided() {
239         return initialConfigXMLFile != null && notificationFile != null;
240     }
241
242     @Deprecated
243     public File getSchemasDir() {
244         return schemasDir;
245     }
246
247     @Deprecated
248     public void setSchemasDir(final File schemasDir) {
249         this.schemasDir = schemasDir;
250     }
251 }