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