Remove netconf-topology-singleton's NetconfConnectorDTO
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / utils / NetconfTopologyUtils.java
index 0968ddbebd4ec86b57c072341afcb9ca072ca099..aa8ed9bd665c25207a820dbd96bd88961b731865 100644 (file)
@@ -5,12 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.topology.singleton.impl.utils;
 
-import java.io.File;
 import java.math.BigDecimal;
 import java.net.InetSocketAddress;
+import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
@@ -24,56 +23,27 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
-import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
-
-public class NetconfTopologyUtils {
-
-    private static final String DEFAULT_SCHEMA_REPOSITORY_NAME = "sal-netconf-connector";
 
+public final class NetconfTopologyUtils {
     public static final long DEFAULT_REQUEST_TIMEOUT_MILLIS = 60000L;
     public static final int DEFAULT_KEEPALIVE_DELAY = 0;
     public static final boolean DEFAULT_RECONNECT_ON_CHANGED_SCHEMA = false;
+    public static final boolean DEFAULT_IS_TCP_ONLY = false;
     public static final int DEFAULT_CONCURRENT_RPC_LIMIT = 0;
     public static final int DEFAULT_MAX_CONNECTION_ATTEMPTS = 0;
     public static final int DEFAULT_BETWEEN_ATTEMPTS_TIMEOUT_MILLIS = 2000;
     public static final long DEFAULT_CONNECTION_TIMEOUT_MILLIS = 20000L;
     public static final BigDecimal DEFAULT_SLEEP_FACTOR = new BigDecimal(1.5);
 
+    private NetconfTopologyUtils() {
 
-    // The default cache directory relative to <code>CACHE_DIRECTORY</code>
-
-    public static final String DEFAULT_CACHE_DIRECTORY = "schema";
-
-    // Filesystem based caches are stored relative to the cache directory.
-    public static final String CACHE_DIRECTORY = "cache";
-
-    // The qualified schema cache directory <code>cache/schema</code>
-    public static final String QUALIFIED_DEFAULT_CACHE_DIRECTORY =
-            CACHE_DIRECTORY + File.separator + DEFAULT_CACHE_DIRECTORY;
-
-    // The default schema repository in the case that one is not specified.
-    public static final SharedSchemaRepository DEFAULT_SCHEMA_REPOSITORY =
-            new SharedSchemaRepository(DEFAULT_SCHEMA_REPOSITORY_NAME);
-
-
-     // The default <code>FilesystemSchemaSourceCache</code>, which stores cached files in <code>cache/schema</code>.
-    public static final FilesystemSchemaSourceCache<YangTextSchemaSource> DEFAULT_CACHE =
-            new FilesystemSchemaSourceCache<>(DEFAULT_SCHEMA_REPOSITORY, YangTextSchemaSource.class,
-                    new File(QUALIFIED_DEFAULT_CACHE_DIRECTORY));
-
-    // The default factory for creating <code>SchemaContext</code> instances.
-    public static final SchemaContextFactory DEFAULT_SCHEMA_CONTEXT_FACTORY =
-            DEFAULT_SCHEMA_REPOSITORY.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
+    }
 
     public static RemoteDeviceId createRemoteDeviceId(final NodeId nodeId, final NetconfNode node) {
         final IpAddress ipAddress = node.getHost().getIpAddress();
         final InetSocketAddress address = new InetSocketAddress(ipAddress.getIpv4Address() != null
                 ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue(),
-                node.getPort().getValue());
+                node.getPort().getValue().toJava());
         return new RemoteDeviceId(nodeId.getValue(), address);
     }
 
@@ -86,9 +56,8 @@ public class NetconfTopologyUtils {
     }
 
     public static NodeId getNodeId(final InstanceIdentifier.PathArgument pathArgument) {
-        if (pathArgument instanceof InstanceIdentifier.IdentifiableItem<?, ?>) {
-
-            final Identifier key = ((InstanceIdentifier.IdentifiableItem) pathArgument).getKey();
+        if (pathArgument instanceof InstanceIdentifier.IdentifiableItem) {
+            final Identifier<?> key = ((InstanceIdentifier.IdentifiableItem<?, ?>) pathArgument).getKey();
             if (key instanceof NodeKey) {
                 return ((NodeKey) key).getNodeId();
             }
@@ -109,4 +78,10 @@ public class NetconfTopologyUtils {
     public static InstanceIdentifier<Node> createTopologyNodePath(final String topologyId) {
         return createTopologyListPath(topologyId).child(Node.class);
     }
+
+    public static DocumentedException createMasterIsDownException(final RemoteDeviceId id, final Exception cause) {
+        return new DocumentedException(id + ":Master is down. Please try again.", cause,
+                DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED,
+                DocumentedException.ErrorSeverity.WARNING);
+    }
 }