Remove deprecated netconf provider config class

Change-Id: I057634851dc4f5e348b7acf9e4aa4efe801fd453
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
index 86b27f6..9cf81d0 100644
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
@@ -16,11 +16,8 @@
 
 package org.onosproject.provider.netconf.device.impl;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -33,17 +30,16 @@
 import org.onosproject.cfg.ComponentConfigService;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
-import org.onosproject.net.Port;
-import org.onosproject.net.behaviour.PortAdmin;
-import org.onosproject.net.config.ConfigException;
 import org.onosproject.mastership.MastershipService;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.DefaultAnnotations;
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.MastershipRole;
+import org.onosproject.net.Port;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.behaviour.PortAdmin;
 import org.onosproject.net.config.ConfigFactory;
 import org.onosproject.net.config.NetworkConfigEvent;
 import org.onosproject.net.config.NetworkConfigListener;
@@ -81,7 +77,6 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Dictionary;
-import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
@@ -96,7 +91,6 @@
 
 import static java.util.concurrent.Executors.newScheduledThreadPool;
 import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
 import static org.slf4j.LoggerFactory.getLogger;
 
 /**
@@ -169,7 +163,7 @@
     private final Map<DeviceId, AtomicInteger> retriedPortDiscoveryMap = new ConcurrentHashMap<>();
     protected ScheduledFuture<?> scheduledTask;
 
-    protected final List<ConfigFactory> factories = ImmutableList.of(
+    protected final ConfigFactory factory =
             // TODO consider moving Config registration to NETCONF ctl bundle
             new ConfigFactory<DeviceId, NetconfDeviceConfig>(
                     SubjectFactories.DEVICE_SUBJECT_FACTORY,
@@ -178,16 +172,7 @@
                 public NetconfDeviceConfig createConfig() {
                     return new NetconfDeviceConfig();
                 }
-            },
-            new ConfigFactory<ApplicationId, NetconfProviderConfig>(APP_SUBJECT_FACTORY,
-                                                                    NetconfProviderConfig.class,
-                                                                    "netconf_devices",
-                                                                    true) {
-                @Override
-                public NetconfProviderConfig createConfig() {
-                    return new NetconfProviderConfig();
-                }
-            });
+            };
 
     protected final NetworkConfigListener cfgListener = new InternalNetworkConfigListener();
     private ApplicationId appId;
@@ -200,11 +185,10 @@
         componentConfigService.registerProperties(getClass());
         providerService = providerRegistry.register(this);
         appId = coreService.registerApplication(APP_NAME);
-        factories.forEach(cfgService::registerConfigFactory);
+        cfgService.registerConfigFactory(factory);
         cfgService.addListener(cfgListener);
         controller.addDeviceListener(innerNodeListener);
         deviceService.addListener(deviceListener);
-        translateConfig();
         executor.execute(NetconfDeviceProvider.this::connectDevices);
         modified(context);
         log.info("Started");
@@ -225,7 +209,7 @@
         providerRegistry.unregister(this);
         providerService = null;
         retriedPortDiscoveryMap.clear();
-        factories.forEach(cfgService::unregisterConfigFactory);
+        cfgService.unregisterConfigFactory(factory);
         scheduledTask.cancel(true);
         executor.shutdown();
         log.info("Stopped");
@@ -619,38 +603,6 @@
         }
     }
 
-
-    protected void translateConfig() {
-        NetconfProviderConfig cfg = cfgService.getConfig(appId, NetconfProviderConfig.class);
-        if (cfg != null) {
-            try {
-                cfg.getDevicesAddresses().forEach(addr -> {
-                    DeviceId deviceId = getDeviceId(addr.ip().toString(), addr.port());
-                    log.info("Translating config for device {}", deviceId);
-                    if (cfgService.getConfig(deviceId, NetconfDeviceConfig.class) == null) {
-                        ObjectMapper mapper = new ObjectMapper();
-                        ObjectNode device = mapper.createObjectNode();
-                        device.put("ip", addr.ip().toString());
-                        device.put("port", addr.port());
-                        device.put("username", addr.name());
-                        device.put("password", addr.password());
-                        device.put("sshkey", addr.sshkey());
-                        cfgService.applyConfig(deviceId, NetconfDeviceConfig.class, device);
-                    } else {
-                        // This is a corner case where new updated config is
-                        // pushed with old /app tree after an initial with the
-                        // new device/ tree. Since old method will be deprecated
-                        // it's ok to ignore
-                        log.warn("Config for device {} already exists, ignoring", deviceId);
-                    }
-
-                });
-            } catch (ConfigException e) {
-                log.error("Cannot read config error " + e);
-            }
-        }
-    }
-
     /**
      * Listener for configuration events.
      */
@@ -664,15 +616,13 @@
             } else {
                 log.warn("Injecting device via this Json is deprecated, " +
                                  "please put configuration under devices/ as shown in the wiki");
-                translateConfig();
             }
 
         }
 
         @Override
         public boolean isRelevant(NetworkConfigEvent event) {
-            return (event.configClass().equals(NetconfDeviceConfig.class) ||
-                    event.configClass().equals(NetconfProviderConfig.class)) &&
+            return (event.configClass().equals(NetconfDeviceConfig.class)) &&
                     (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
                             event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED);
         }
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfProviderConfig.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfProviderConfig.java
deleted file mode 100644
index 94190fa..0000000
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfProviderConfig.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.netconf.device.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.annotations.Beta;
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.ConfigException;
-import org.onosproject.net.config.Config;
-
-import java.util.Set;
-
-/**
- * Configuration for Netconf provider.
- * @deprecated 1.10.0 Kingfisher
- */
-@Beta
-@Deprecated
-public class NetconfProviderConfig extends Config<ApplicationId> {
-
-    public static final String CONFIG_VALUE_ERROR = "Error parsing config value";
-    private static final String IP = "ip";
-    private static final int DEFAULT_TCP_PORT = 830;
-    private static final String PORT = "port";
-    private static final String NAME = "username";
-    private static final String PASSWORD = "password";
-    private static final String SSHKEY = "sshkey";
-
-    public Set<NetconfDeviceAddress> getDevicesAddresses() throws ConfigException {
-        Set<NetconfDeviceAddress> devicesAddresses = Sets.newHashSet();
-        try {
-            for (JsonNode node : array) {
-                String ip = node.path(IP).asText();
-                IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
-                int port = node.path(PORT).asInt(DEFAULT_TCP_PORT);
-                String name = node.path(NAME).asText();
-                String password = node.path(PASSWORD).asText();
-                String sshkey = node.path(SSHKEY).asText();
-                devicesAddresses.add(new NetconfDeviceAddress(ipAddr, port, name, password, sshkey));
-
-            }
-        } catch (IllegalArgumentException e) {
-            throw new ConfigException(CONFIG_VALUE_ERROR, e);
-        }
-
-        return devicesAddresses;
-    }
-
-    public class
-    NetconfDeviceAddress {
-        private final IpAddress ip;
-        private final int port;
-        private final String name;
-        private final String password;
-        private final String sshkey;
-
-        public NetconfDeviceAddress(IpAddress ip, int port, String name, String password) {
-            this.ip = ip;
-            this.port = port;
-            this.name = name;
-            this.password = password;
-            this.sshkey = "";
-        }
-
-        public NetconfDeviceAddress(IpAddress ip, int port, String name, String password, String sshkey) {
-            this.ip = ip;
-            this.port = port;
-            this.name = name;
-            this.password = password;
-            this.sshkey = sshkey;
-        }
-
-        public IpAddress ip() {
-            return ip;
-        }
-
-        public int port() {
-            return port;
-        }
-
-        public String name() {
-            return name;
-        }
-
-        public String password() {
-            return password;
-        }
-
-        public String sshkey() {
-            return sshkey;
-        }
-    }
-
-}