Netconf Device Notification
[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             XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_NOTIFICATION_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@2010-10-04.yang"),
43             new YangResource("odl-netconf-monitoring", "2022-07-18",
44                     "/META-INF/yang/odl-netconf-monitoring@2022-07-18.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 = (username, key, session) -> {
57         LOG.info("Auth with public key: {}", key);
58         return true;
59     };
60
61     private int generateConfigsTimeout = (int) TimeUnit.MINUTES.toMillis(30);
62     private int threadPoolSize = 8;
63     private int startingPort = 17830;
64     private int deviceCount = 1;
65     private boolean ssh = true;
66     private String ip = "0.0.0.0";
67     private Set<YangResource> defaultYangResources = DEFAULT_YANG_RESOURCES;
68
69     private Set<YangModuleInfo> models;
70     private Set<String> capabilities = DEFAULT_BASE_CAPABILITIES_EXI;
71     private RpcHandler rpcHandler = new RpcHandlerDefault();
72     private OperationsCreator operationsCreator;
73     private AuthProvider authProvider = DEFAULT_AUTH_PROVIDER;
74     private PublickeyAuthenticator publickeyAuthenticator = DEFAULT_PUBLIC_KEY_AUTHENTICATOR;
75
76     @Deprecated
77     private boolean mdSal = false;
78
79     @Deprecated
80     private File rpcConfigFile;
81
82     @Deprecated
83     private File notificationFile;
84
85     @Deprecated
86     private File initialConfigXMLFile;
87
88     @Deprecated
89     private File schemasDir;
90
91     public Configuration() {
92     }
93
94     public PublickeyAuthenticator getPublickeyAuthenticator() {
95         return publickeyAuthenticator;
96     }
97
98     public void setPublickeyAuthenticator(final PublickeyAuthenticator publickeyAuthenticator) {
99         this.publickeyAuthenticator = publickeyAuthenticator;
100     }
101
102     public AuthProvider getAuthProvider() {
103         return authProvider;
104     }
105
106     public void setAuthProvider(final AuthProvider authProvider) {
107         this.authProvider = authProvider;
108     }
109
110     public Set<YangResource> getDefaultYangResources() {
111         return defaultYangResources;
112     }
113
114     public void setDefaultYangResources(final Set<YangResource> defaultYangResources) {
115         this.defaultYangResources = defaultYangResources;
116     }
117
118     public int getThreadPoolSize() {
119         return threadPoolSize;
120     }
121
122     public void setThreadPoolSize(final int threadPoolSize) {
123         this.threadPoolSize = threadPoolSize;
124     }
125
126     public int getStartingPort() {
127         return startingPort;
128     }
129
130     public void setStartingPort(final int startingPort) {
131         this.startingPort = startingPort;
132     }
133
134     public int getDeviceCount() {
135         return deviceCount;
136     }
137
138     public void setDeviceCount(final int deviceCount) {
139         this.deviceCount = deviceCount;
140     }
141
142     public int getGenerateConfigsTimeout() {
143         return generateConfigsTimeout;
144     }
145
146     public void setGenerateConfigsTimeout(final int generateConfigsTimeout) {
147         this.generateConfigsTimeout = generateConfigsTimeout;
148     }
149
150     public boolean isSsh() {
151         return ssh;
152     }
153
154     public void setSsh(final boolean ssh) {
155         this.ssh = ssh;
156     }
157
158     public String getIp() {
159         return ip;
160     }
161
162     public void setIp(final String ip) {
163         this.ip = ip;
164     }
165
166     public Set<YangModuleInfo> getModels() {
167         return models;
168     }
169
170     public void setModels(final Set<YangModuleInfo> models) {
171         this.models = models;
172     }
173
174     public Set<String> getCapabilities() {
175         return capabilities;
176     }
177
178     public void setCapabilities(final Set<String> capabilities) {
179         this.capabilities = capabilities;
180     }
181
182     public RpcHandler getRpcHandler() {
183         return rpcHandler;
184     }
185
186     public void setRpcHandler(final RpcHandler rpcHandler) {
187         this.rpcHandler = rpcHandler;
188     }
189
190     public OperationsCreator getOperationsCreator() {
191         return operationsCreator;
192     }
193
194     public void setOperationsCreator(final OperationsCreator operationsCreator) {
195         this.operationsCreator = operationsCreator;
196     }
197
198     @Deprecated
199     public boolean isMdSal() {
200         return mdSal;
201     }
202
203     @Deprecated
204     public void setMdSal(final boolean mdSal) {
205         this.mdSal = mdSal;
206     }
207
208     @Deprecated
209     public File getRpcConfigFile() {
210         return rpcConfigFile;
211     }
212
213     @Deprecated
214     public void setRpcConfigFile(final File rpcConfigFile) {
215         this.rpcConfigFile = rpcConfigFile;
216     }
217
218     @Deprecated
219     public File getNotificationFile() {
220         return notificationFile;
221     }
222
223     @Deprecated
224     public void setNotificationFile(final File notificationFile) {
225         this.notificationFile = notificationFile;
226     }
227
228     @Deprecated
229     public File getInitialConfigXMLFile() {
230         return initialConfigXMLFile;
231     }
232
233     @Deprecated
234     public void setInitialConfigXMLFile(final File initialConfigXMLFile) {
235         this.initialConfigXMLFile = initialConfigXMLFile;
236     }
237
238     @Deprecated
239     public boolean isXmlConfigurationProvided() {
240         return initialConfigXMLFile != null;
241     }
242
243     @Deprecated
244     public boolean isNotificationsSupported() {
245         return notificationFile != null;
246     }
247
248     @Deprecated
249     public File getSchemasDir() {
250         return schemasDir;
251     }
252
253     @Deprecated
254     public void setSchemasDir(final File schemasDir) {
255         this.schemasDir = schemasDir;
256     }
257 }