2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.netconf.test.tool.config;
10 import com.google.common.collect.ImmutableSet;
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;
24 public class Configuration {
26 private static final Logger LOG = LoggerFactory.getLogger(Configuration.class);
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
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
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("odl-netconf-monitoring", "2022-07-18",
43 "/META-INF/yang/odl-netconf-monitoring@2022-07-18.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")
50 public static final AuthProvider DEFAULT_AUTH_PROVIDER = (username, password) -> {
51 LOG.info("Auth with username and password: {}", username);
55 public static final PublickeyAuthenticator DEFAULT_PUBLIC_KEY_AUTHENTICATOR = (username, key, session) -> {
56 LOG.info("Auth with public key: {}", key);
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;
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;
76 private boolean mdSal = false;
79 private File rpcConfigFile;
82 private File notificationFile;
85 private File initialConfigXMLFile;
88 private File schemasDir;
90 public Configuration() {
93 public PublickeyAuthenticator getPublickeyAuthenticator() {
94 return publickeyAuthenticator;
97 public void setPublickeyAuthenticator(final PublickeyAuthenticator publickeyAuthenticator) {
98 this.publickeyAuthenticator = publickeyAuthenticator;
101 public AuthProvider getAuthProvider() {
105 public void setAuthProvider(final AuthProvider authProvider) {
106 this.authProvider = authProvider;
109 public Set<YangResource> getDefaultYangResources() {
110 return defaultYangResources;
113 public void setDefaultYangResources(final Set<YangResource> defaultYangResources) {
114 this.defaultYangResources = defaultYangResources;
117 public int getThreadPoolSize() {
118 return threadPoolSize;
121 public void setThreadPoolSize(final int threadPoolSize) {
122 this.threadPoolSize = threadPoolSize;
125 public int getStartingPort() {
129 public void setStartingPort(final int startingPort) {
130 this.startingPort = startingPort;
133 public int getDeviceCount() {
137 public void setDeviceCount(final int deviceCount) {
138 this.deviceCount = deviceCount;
141 public int getGenerateConfigsTimeout() {
142 return generateConfigsTimeout;
145 public void setGenerateConfigsTimeout(final int generateConfigsTimeout) {
146 this.generateConfigsTimeout = generateConfigsTimeout;
149 public boolean isSsh() {
153 public void setSsh(final boolean ssh) {
157 public String getIp() {
161 public void setIp(final String ip) {
165 public Set<YangModuleInfo> getModels() {
169 public void setModels(final Set<YangModuleInfo> models) {
170 this.models = models;
173 public Set<String> getCapabilities() {
177 public void setCapabilities(final Set<String> capabilities) {
178 this.capabilities = capabilities;
181 public RpcHandler getRpcHandler() {
185 public void setRpcHandler(final RpcHandler rpcHandler) {
186 this.rpcHandler = rpcHandler;
189 public OperationsCreator getOperationsCreator() {
190 return operationsCreator;
193 public void setOperationsCreator(final OperationsCreator operationsCreator) {
194 this.operationsCreator = operationsCreator;
198 public boolean isMdSal() {
203 public void setMdSal(final boolean mdSal) {
208 public File getRpcConfigFile() {
209 return rpcConfigFile;
213 public void setRpcConfigFile(final File rpcConfigFile) {
214 this.rpcConfigFile = rpcConfigFile;
218 public File getNotificationFile() {
219 return notificationFile;
223 public void setNotificationFile(final File notificationFile) {
224 this.notificationFile = notificationFile;
228 public File getInitialConfigXMLFile() {
229 return initialConfigXMLFile;
233 public void setInitialConfigXMLFile(final File initialConfigXMLFile) {
234 this.initialConfigXMLFile = initialConfigXMLFile;
238 public boolean isXmlConfigurationProvided() {
239 return initialConfigXMLFile != null && notificationFile != null;
243 public File getSchemasDir() {
248 public void setSchemasDir(final File schemasDir) {
249 this.schemasDir = schemasDir;