Remove deprecated TL1 provider config
Change-Id: I09c88d016eb792c6c76730c42a3f925df12cc04a
diff --git a/providers/tl1/device/src/main/java/org/onosproject/provider/tl1/device/impl/Tl1DeviceProvider.java b/providers/tl1/device/src/main/java/org/onosproject/provider/tl1/device/impl/Tl1DeviceProvider.java
index 1dceeb5..04c3120 100644
--- a/providers/tl1/device/src/main/java/org/onosproject/provider/tl1/device/impl/Tl1DeviceProvider.java
+++ b/providers/tl1/device/src/main/java/org/onosproject/provider/tl1/device/impl/Tl1DeviceProvider.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.provider.tl1.device.impl;
-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;
@@ -24,7 +23,6 @@
import org.onlab.packet.ChassisId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.net.config.ConfigException;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device;
@@ -59,11 +57,9 @@
import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
-import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -109,16 +105,7 @@
private Tl1Listener tl1Listener = new InnerTl1Listener();
private DeviceProviderService providerService;
- private final List<ConfigFactory> factories = ImmutableList.of(
- new ConfigFactory<ApplicationId, Tl1ProviderConfig>(APP_SUBJECT_FACTORY,
- Tl1ProviderConfig.class,
- "tl1_devices",
- true) {
- @Override
- public Tl1ProviderConfig createConfig() {
- return new Tl1ProviderConfig();
- }
- },
+ private final ConfigFactory factory =
new ConfigFactory<DeviceId, Tl1DeviceConfig>(SubjectFactories.DEVICE_SUBJECT_FACTORY,
Tl1DeviceConfig.class,
Tl1DeviceConfig.TL1) {
@@ -126,7 +113,7 @@
public Tl1DeviceConfig createConfig() {
return new Tl1DeviceConfig();
}
- });
+ };
@Activate
public void activate() {
@@ -134,8 +121,7 @@
providerService = providerRegistry.register(this);
cfgRegistry.addListener(cfgListener);
controller.addListener(tl1Listener);
- factories.forEach(cfgRegistry::registerConfigFactory);
- registerDevices();
+ cfgRegistry.registerConfigFactory(factory);
connectDevices();
log.info("Started");
}
@@ -149,7 +135,7 @@
deviceAdminService.removeDevice(deviceId);
});
providerRegistry.unregister(this);
- factories.forEach(cfgRegistry::unregisterConfigFactory);
+ cfgRegistry.unregisterConfigFactory(factory);
providerService = null;
log.info("Stopped");
}
@@ -210,21 +196,6 @@
// TODO
}
- //Old method to register devices provided via net-cfg under apps/tl1/ tree
- void registerDevices() {
- Tl1ProviderConfig cfg = cfgRegistry.getConfig(appId, Tl1ProviderConfig.class);
-
- if (cfg == null) {
- return;
- }
-
- try {
- cfg.readDevices().forEach(this::connectDevice);
- } catch (ConfigException e) {
- log.error("Cannot parse network configuration", e);
- }
- }
-
//Method to register devices provided via net-cfg under devices/ tree
private void connectDevices() {
Set<DeviceId> deviceSubjects =
@@ -302,7 +273,6 @@
} else {
log.warn("Injecting device via this Json is deprecated, " +
"please put configuration under devices/");
- registerDevices();
}
} else if (event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) {
// TODO: calculate delta
@@ -311,7 +281,6 @@
} else {
log.warn("Injecting device via this Json is deprecated, " +
"please put configuration under devices/");
- registerDevices();
}
} else if (event.type() == NetworkConfigEvent.Type.CONFIG_REMOVED) {
controller.getDeviceIds().forEach(deviceId -> {
@@ -323,8 +292,7 @@
@Override
public boolean isRelevant(NetworkConfigEvent event) {
- return (event.configClass().equals(Tl1DeviceConfig.class) ||
- event.configClass().equals(Tl1ProviderConfig.class)) &&
+ return (event.configClass().equals(Tl1DeviceConfig.class)) &&
(event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED ||
event.type() == NetworkConfigEvent.Type.CONFIG_REMOVED);
diff --git a/providers/tl1/device/src/main/java/org/onosproject/provider/tl1/device/impl/Tl1ProviderConfig.java b/providers/tl1/device/src/main/java/org/onosproject/provider/tl1/device/impl/Tl1ProviderConfig.java
deleted file mode 100644
index a2dc587..0000000
--- a/providers/tl1/device/src/main/java/org/onosproject/provider/tl1/device/impl/Tl1ProviderConfig.java
+++ /dev/null
@@ -1,60 +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.tl1.device.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-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 org.onosproject.tl1.DefaultTl1Device;
-import org.onosproject.tl1.Tl1Device;
-
-import java.util.Set;
-
-/**
- * Configuration for TL1 provider.
- * @deprecated 1.10.0 Kingfisher
- *
- */
-@Deprecated
-public class Tl1ProviderConfig extends Config<ApplicationId> {
- public static final String CONFIG_VALUE_ERROR = "Error parsing config value";
- private static final String IP = "ip";
- private static final String PORT = "port";
- private static final String USERNAME = "username";
- private static final String PASSWORD = "password";
-
- Set<Tl1Device> readDevices() throws ConfigException {
- Set<Tl1Device> devices = Sets.newHashSet();
-
- try {
- for (JsonNode node : array) {
- String ip = node.path(IP).asText();
- IpAddress ipAddress = IpAddress.valueOf(ip);
- int port = node.path(PORT).asInt();
- String username = node.path(USERNAME).asText();
- String password = node.path(PASSWORD).asText();
- devices.add(new DefaultTl1Device(ipAddress, port, username, password));
- }
- } catch (IllegalArgumentException e) {
- throw new ConfigException(CONFIG_VALUE_ERROR, e);
- }
-
- return devices;
- }
-}