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