Remove deprecated RestProviderConfig
Change-Id: Icd30ef5802ecd60f03ea1c3cf9cf3dc9e224edab
diff --git a/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestDeviceProvider.java b/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestDeviceProvider.java
index 7f6d9e8..51f82ef 100644
--- a/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestDeviceProvider.java
+++ b/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestDeviceProvider.java
@@ -38,7 +38,6 @@
import org.onosproject.net.behaviour.DevicesDiscovery;
import org.onosproject.net.behaviour.PortAdmin;
import org.onosproject.net.behaviour.PortDiscovery;
-import org.onosproject.net.config.ConfigException;
import org.onosproject.net.config.ConfigFactory;
import org.onosproject.net.config.NetworkConfigEvent;
import org.onosproject.net.config.NetworkConfigListener;
@@ -87,7 +86,6 @@
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_ADDED;
import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UPDATED;
-import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -133,15 +131,6 @@
SharedScheduledExecutors.getPoolThreadExecutor();
private final List<ConfigFactory> factories = ImmutableList.of(
- new ConfigFactory<ApplicationId, RestProviderConfig>(APP_SUBJECT_FACTORY,
- RestProviderConfig.class,
- "rest_devices",
- true) {
- @Override
- public RestProviderConfig createConfig() {
- return new RestProviderConfig();
- }
- },
new ConfigFactory<DeviceId, RestDeviceConfig>(SubjectFactories.DEVICE_SUBJECT_FACTORY,
RestDeviceConfig.class,
REST) {
@@ -166,7 +155,6 @@
);
cfgService.addListener(configListener);
executor.execute(RestDeviceProvider.this::createAndConnectDevices);
- executor.execute(RestDeviceProvider.this::createDevices);
scheduledTask = schedulePolling();
log.info("Started");
}
@@ -375,20 +363,6 @@
}).collect(Collectors.toSet()));
}
- //Old method to register devices provided via net-cfg under apps/rest/ tree
- private void createDevices() {
- RestProviderConfig cfg = cfgService.getConfig(appId, RestProviderConfig.class);
- try {
- if (cfg != null && cfg.getDevicesAddresses() != null) {
- connectDevices(cfg.getDevicesAddresses());
-
- }
- } catch (ConfigException e) {
- log.error("Configuration error {}", e);
- }
- log.debug("REST Devices {}", controller.getDevices());
- }
-
private void connectDevices(Set<RestSBDevice> devices) {
//Precomputing the devices to be removed
Set<RestSBDevice> toBeRemoved = new HashSet<>(controller.getDevices().values());
@@ -479,19 +453,12 @@
private class InternalNetworkConfigListener implements NetworkConfigListener {
@Override
public void event(NetworkConfigEvent event) {
- if (event.configClass().equals(RestDeviceConfig.class)) {
- executor.execute(RestDeviceProvider.this::createAndConnectDevices);
- } else {
- log.warn("Injecting device via this Json is deprecated, " +
- "please put configuration under devices/");
- executor.execute(RestDeviceProvider.this::createDevices);
- }
+ executor.execute(RestDeviceProvider.this::createAndConnectDevices);
}
@Override
public boolean isRelevant(NetworkConfigEvent event) {
- return (event.configClass().equals(RestDeviceConfig.class) ||
- event.configClass().equals(RestProviderConfig.class)) &&
+ return event.configClass().equals(RestDeviceConfig.class) &&
(event.type() == CONFIG_ADDED ||
event.type() == CONFIG_UPDATED);
}
diff --git a/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestProviderConfig.java b/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestProviderConfig.java
deleted file mode 100644
index 21d9774..0000000
--- a/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestProviderConfig.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2016-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.rest.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.Config;
-import org.onosproject.net.config.ConfigException;
-import org.onosproject.protocol.rest.DefaultRestSBDevice;
-import org.onosproject.protocol.rest.RestSBDevice;
-import org.onosproject.protocol.rest.RestSBDevice.AuthenticationScheme;
-
-import java.util.Set;
-
-/**
- * Configuration for RestSB provider.
- *
- * @deprecated 1.10.0 Kingfisher. Please Use RestDeviceConfig
- */
-@Deprecated
-@Beta
-public class RestProviderConfig 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_HTTP_PORT = 80;
- private static final String PORT = "port";
- private static final String USERNAME = "username";
- private static final String PASSWORD = "password";
- private static final String PROTOCOL = "protocol";
- private static final String URL = "url";
- private static final String TESTURL = "testUrl";
- private static final String MANUFACTURER = "manufacturer";
- private static final String HWVERSION = "hwVersion";
- private static final String SWVERSION = "swVersion";
- private static final String AUTHENTICATION_SCHEME = "authenticationScheme";
- private static final String TOKEN = "token";
-
- public Set<RestSBDevice> getDevicesAddresses() throws ConfigException {
- Set<RestSBDevice> 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_HTTP_PORT);
- String username = node.path(USERNAME).asText();
- String password = node.path(PASSWORD).asText();
- String protocol = node.path(PROTOCOL).asText();
- String url = node.path(URL).asText();
- String testUrl = node.path(TESTURL).asText();
- String manufacturer = node.path(MANUFACTURER).asText();
- String hwVersion = node.path(HWVERSION).asText();
- String swVersion = node.path(SWVERSION).asText();
- AuthenticationScheme authenticationScheme = AuthenticationScheme.valueOf(node.path(
- AUTHENTICATION_SCHEME).asText().toUpperCase());
- String token = node.path(TOKEN).asText();
-
- devicesAddresses.add(new DefaultRestSBDevice(ipAddr, port, username,
- password, protocol,
- url, false, testUrl, manufacturer,
- hwVersion, swVersion, authenticationScheme, token));
- }
- } catch (IllegalArgumentException e) {
- throw new ConfigException(CONFIG_VALUE_ERROR, e);
- }
-
- return devicesAddresses;
- }
-
-}