Merge remote-tracking branch 'origin/master' into dev/murrelet
diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
index e5c9973..99b8afb 100644
--- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
+++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
@@ -90,6 +90,8 @@
public static final ProviderId PROVIDER_ID = new ProviderId("host", DHCP_RELAY_APP);
public static final String HOST_LOCATION_PROVIDER =
"org.onosproject.provider.host.impl.HostLocationProvider";
+ public static final String ROUTE_STORE_IMPL =
+ "org.onosproject.routeservice.store.RouteStoreImpl";
private final Logger log = LoggerFactory.getLogger(getClass());
private final InternalConfigListener cfgListener = new InternalConfigListener();
@@ -170,6 +172,9 @@
// disable dhcp from host location provider
compCfgService.preSetProperty(HOST_LOCATION_PROVIDER,
"useDhcp", Boolean.FALSE.toString());
+ // Enable distribute route store
+ compCfgService.preSetProperty(ROUTE_STORE_IMPL,
+ "distributed", Boolean.TRUE.toString());
compCfgService.registerProperties(getClass());
log.info("DHCP-RELAY Started");
}
diff --git a/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfTranslatorImpl.java b/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfTranslatorImpl.java
index fa262cc..b2c2161 100644
--- a/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfTranslatorImpl.java
+++ b/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfTranslatorImpl.java
@@ -69,7 +69,7 @@
import java.util.regex.Pattern;
import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.netconf.TargetConfig.RUNNING;
+import static org.onosproject.netconf.DatastoreId.RUNNING;
import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE;
import static org.onosproject.yang.runtime.SerializerHelper.addDataNode;
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index 477b466..49e2969 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -21,7 +21,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-
import org.onlab.packet.ChassisId;
import org.onlab.packet.EthType;
import org.onlab.packet.Ip4Address;
@@ -139,6 +138,7 @@
import org.onosproject.net.flow.criteria.OchSignalTypeCriterion;
import org.onosproject.net.flow.criteria.OduSignalIdCriterion;
import org.onosproject.net.flow.criteria.OduSignalTypeCriterion;
+import org.onosproject.net.flow.criteria.PiCriterion;
import org.onosproject.net.flow.criteria.PortCriterion;
import org.onosproject.net.flow.criteria.SctpPortCriterion;
import org.onosproject.net.flow.criteria.TcpPortCriterion;
@@ -153,6 +153,7 @@
import org.onosproject.net.flow.instructions.L2ModificationInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction;
import org.onosproject.net.flow.instructions.L4ModificationInstruction;
+import org.onosproject.net.flow.instructions.PiInstruction;
import org.onosproject.net.flowobjective.DefaultFilteringObjective;
import org.onosproject.net.flowobjective.DefaultForwardingObjective;
import org.onosproject.net.flowobjective.DefaultNextObjective;
@@ -198,7 +199,31 @@
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.DefaultPacketRequest;
import org.onosproject.net.packet.PacketPriority;
+import org.onosproject.net.pi.model.PiMatchType;
+import org.onosproject.net.pi.model.PiPipeconfId;
+import org.onosproject.net.pi.runtime.PiAction;
+import org.onosproject.net.pi.runtime.PiActionGroup;
+import org.onosproject.net.pi.runtime.PiActionGroupId;
+import org.onosproject.net.pi.runtime.PiActionGroupMember;
+import org.onosproject.net.pi.runtime.PiActionGroupMemberId;
+import org.onosproject.net.pi.runtime.PiActionId;
+import org.onosproject.net.pi.runtime.PiActionParam;
+import org.onosproject.net.pi.runtime.PiActionParamId;
+import org.onosproject.net.pi.runtime.PiExactFieldMatch;
+import org.onosproject.net.pi.runtime.PiFieldMatch;
+import org.onosproject.net.pi.runtime.PiHeaderFieldId;
+import org.onosproject.net.pi.runtime.PiLpmFieldMatch;
+import org.onosproject.net.pi.runtime.PiMatchKey;
+import org.onosproject.net.pi.runtime.PiPacketMetadata;
+import org.onosproject.net.pi.runtime.PiPacketMetadataId;
+import org.onosproject.net.pi.runtime.PiPacketOperation;
+import org.onosproject.net.pi.runtime.PiPipeconfConfig;
+import org.onosproject.net.pi.runtime.PiRangeFieldMatch;
+import org.onosproject.net.pi.runtime.PiTableAction;
+import org.onosproject.net.pi.runtime.PiTableEntry;
import org.onosproject.net.pi.runtime.PiTableId;
+import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
+import org.onosproject.net.pi.runtime.PiValidFieldMatch;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.region.DefaultRegion;
import org.onosproject.net.region.Region;
@@ -215,10 +240,10 @@
import org.onosproject.store.primitives.MapUpdate;
import org.onosproject.store.primitives.TransactionId;
import org.onosproject.store.service.MapEvent;
-import org.onosproject.store.service.TransactionLog;
import org.onosproject.store.service.MultimapEvent;
import org.onosproject.store.service.SetEvent;
import org.onosproject.store.service.Task;
+import org.onosproject.store.service.TransactionLog;
import org.onosproject.store.service.Versioned;
import org.onosproject.store.service.WorkQueueStats;
import org.onosproject.ui.model.topo.UiTopoLayoutId;
@@ -565,6 +590,38 @@
.register(MarkerResource.class)
.register(new BitSetSerializer(), BitSet.class)
.register(DomainIntent.class)
+ .register(
+ // PI model
+ PiMatchType.class,
+ PiPipeconfId.class,
+ // PI Runtime
+ PiAction.class,
+ PiActionGroup.class,
+ PiActionGroupId.class,
+ PiActionGroupMember.class,
+ PiActionGroupMemberId.class,
+ PiActionId.class,
+ PiActionParam.class,
+ PiActionParamId.class,
+ PiExactFieldMatch.class,
+ PiFieldMatch.class,
+ PiHeaderFieldId.class,
+ PiLpmFieldMatch.class,
+ PiMatchKey.class,
+ PiPacketMetadata.class,
+ PiPacketMetadataId.class,
+ PiPacketOperation.class,
+ PiPipeconfConfig.class,
+ PiRangeFieldMatch.class,
+ PiTableAction.class,
+ PiTableEntry.class,
+ PiTableId.class,
+ PiTernaryFieldMatch.class,
+ PiValidFieldMatch.class,
+ // Other
+ PiCriterion.class,
+ PiInstruction.class
+ )
.build("API");
/**
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfig.java
index bbb373d..860d6e1 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfig.java
@@ -31,7 +31,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtility.*;
import static org.slf4j.LoggerFactory.getLogger;
-import static org.onosproject.netconf.TargetConfig.RUNNING;
+import static org.onosproject.netconf.DatastoreId.RUNNING;
/**
* Implementation to get and set parameters available in vOLT
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfig.java
index 4fd8ed1..c304609 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfig.java
@@ -31,7 +31,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtility.*;
import static org.slf4j.LoggerFactory.getLogger;
-import static org.onosproject.netconf.TargetConfig.RUNNING;
+import static org.onosproject.netconf.DatastoreId.RUNNING;
/**
* Implementation to get and set parameters available in vOLT
diff --git a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java
index 4908127..bbf405c 100644
--- a/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java
+++ b/drivers/fujitsu/src/main/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfig.java
@@ -35,7 +35,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtility.*;
import static org.slf4j.LoggerFactory.getLogger;
-import static org.onosproject.netconf.TargetConfig.RUNNING;
+import static org.onosproject.netconf.DatastoreId.RUNNING;
/**
* Implementation to get and set parameters available in vOLT
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfControllerMock.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfControllerMock.java
index e9b3af4..8659246 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfControllerMock.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfControllerMock.java
@@ -24,7 +24,7 @@
import org.onosproject.netconf.NetconfDevice;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.ctl.NetconfControllerImpl;
+import org.onosproject.netconf.ctl.impl.NetconfControllerImpl;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfSessionListenerTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfSessionListenerTest.java
index a5b1433..f1930bc 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfSessionListenerTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfSessionListenerTest.java
@@ -17,7 +17,7 @@
package org.onosproject.drivers.fujitsu;
-import org.onosproject.netconf.TargetConfig;
+import org.onosproject.netconf.DatastoreId;
public interface FujitsuNetconfSessionListenerTest {
@@ -50,7 +50,7 @@
* @param newConfiguration configuration to set
* @return true if everuthing as expected
*/
- boolean verifyEditConfig(TargetConfig targetConfiguration, String mode, String newConfiguration);
+ boolean verifyEditConfig(DatastoreId targetConfiguration, String mode, String newConfiguration);
/**
* Verify get request arguments.
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfSessionMock.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfSessionMock.java
index 745c095..132b11d 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfSessionMock.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuNetconfSessionMock.java
@@ -17,19 +17,19 @@
package org.onosproject.drivers.fujitsu;
import com.google.common.annotations.Beta;
-import org.onosproject.netconf.TargetConfig;
+
+import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfDeviceOutputEventListener;
import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.NetconfSession;
+import org.onosproject.netconf.NetconfSessionAdapter;
-import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* Mock NetconfSessionImpl.
*/
-public class FujitsuNetconfSessionMock implements NetconfSession {
+public class FujitsuNetconfSessionMock extends NetconfSessionAdapter {
private FujitsuNetconfSessionListenerTest listener;
@@ -81,28 +81,6 @@
}
@Override
- public String getConfig(TargetConfig targetConfiguration) throws NetconfException {
- return null;
- }
-
- @Override
- public String getConfig(String targetConfiguration) throws NetconfException {
- return null;
- }
-
- @Override
- public String getConfig(TargetConfig targetConfiguration, String configurationFilterSchema)
- throws NetconfException {
- return null;
- }
-
- @Override
- public String getConfig(String targetConfiguration, String configurationFilterSchema)
- throws NetconfException {
- return null;
- }
-
- @Override
public boolean editConfig(String newConfiguration) throws NetconfException {
boolean result = true;
if (listener != null) {
@@ -112,7 +90,7 @@
}
@Override
- public boolean editConfig(TargetConfig targetConfiguration, String mode, String newConfiguration)
+ public boolean editConfig(DatastoreId targetConfiguration, String mode, String newConfiguration)
throws NetconfException {
boolean result = true;
if (listener != null) {
@@ -122,17 +100,7 @@
}
@Override
- public boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
- throws NetconfException {
- boolean result = true;
- if (listener != null) {
- result = listener.verifyEditConfig(targetConfiguration, mode, newConfiguration);
- }
- return result;
- }
-
- @Override
- public boolean copyConfig(TargetConfig targetConfiguration, String newConfiguration)
+ public boolean copyConfig(DatastoreId targetConfiguration, String newConfiguration)
throws NetconfException {
return false;
}
@@ -144,17 +112,11 @@
}
@Override
- public boolean deleteConfig(TargetConfig targetConfiguration) throws NetconfException {
+ public boolean deleteConfig(DatastoreId targetConfiguration) throws NetconfException {
return false;
}
@Override
- public boolean deleteConfig(String targetConfiguration) throws NetconfException {
- return false;
- }
-
-
- @Override
public void startSubscription() throws NetconfException {
}
@@ -172,12 +134,12 @@
}
@Override
- public boolean lock(String configType) throws NetconfException {
+ public boolean lock(DatastoreId configType) throws NetconfException {
return false;
}
@Override
- public boolean unlock(String configType) throws NetconfException {
+ public boolean unlock(DatastoreId configType) throws NetconfException {
return false;
}
@@ -202,15 +164,6 @@
}
@Override
- public String getServerCapabilities() {
- return null;
- }
-
- @Override
- public void setDeviceCapabilities(List<String> capabilities) {
- }
-
- @Override
public void checkAndReestablish() throws NetconfException {
}
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfigTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfigTest.java
index 02136f8..f12b631 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfigTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltAlertConfigTest.java
@@ -19,7 +19,7 @@
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.netconf.TargetConfig;
+import org.onosproject.netconf.DatastoreId;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -31,7 +31,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtilityMock.*;
-import static org.onosproject.netconf.TargetConfig.*;
+import static org.onosproject.netconf.DatastoreId.*;
/**
@@ -232,11 +232,11 @@
@Override
public boolean verifyEditConfig(String targetConfiguration, String mode, String newConfiguration) {
- return verifyEditConfig(TargetConfig.valueOf(targetConfiguration), mode, newConfiguration);
+ return verifyEditConfig(DatastoreId.datastore(targetConfiguration), mode, newConfiguration);
}
@Override
- public boolean verifyEditConfig(TargetConfig target, String mode, String request) {
+ public boolean verifyEditConfig(DatastoreId target, String mode, String request) {
boolean result;
assertTrue("Incorrect target", target.equals(RUNNING));
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltControllerConfigTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltControllerConfigTest.java
index 3365bb8..0605ba7 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltControllerConfigTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltControllerConfigTest.java
@@ -23,8 +23,7 @@
import org.onosproject.net.behaviour.ControllerInfo;
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.netconf.TargetConfig;
-
+import org.onosproject.netconf.DatastoreId;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -191,7 +190,7 @@
}
@Override
- public boolean verifyEditConfig(TargetConfig target, String mode, String request) {
+ public boolean verifyEditConfig(DatastoreId target, String mode, String request) {
return false;
}
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltFwdlConfigTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltFwdlConfigTest.java
index c01b448..fb8b373 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltFwdlConfigTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltFwdlConfigTest.java
@@ -18,7 +18,7 @@
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.netconf.TargetConfig;
+import org.onosproject.netconf.DatastoreId;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
@@ -165,7 +165,7 @@
}
@Override
- public boolean verifyEditConfig(TargetConfig target, String mode, String request) {
+ public boolean verifyEditConfig(DatastoreId target, String mode, String request) {
return false;
}
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltNeConfigTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltNeConfigTest.java
index 2368eb1..0214627 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltNeConfigTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltNeConfigTest.java
@@ -18,8 +18,7 @@
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.netconf.TargetConfig;
-
+import org.onosproject.netconf.DatastoreId;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtilityMock.*;
@@ -81,7 +80,7 @@
}
@Override
- public boolean verifyEditConfig(TargetConfig target, String mode, String request) {
+ public boolean verifyEditConfig(DatastoreId target, String mode, String request) {
return false;
}
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfigTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfigTest.java
index 5e9c55c..53e19d3 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfigTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltNniLinkConfigTest.java
@@ -18,14 +18,13 @@
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.netconf.TargetConfig;
-
+import org.onosproject.netconf.DatastoreId;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtilityMock.*;
-import static org.onosproject.netconf.TargetConfig.RUNNING;
+import static org.onosproject.netconf.DatastoreId.RUNNING;
/**
* Unit tests for methods of FujitsuVoltPonLinkConfig.
@@ -216,7 +215,7 @@
}
@Override
- public boolean verifyEditConfig(TargetConfig target, String mode, String request) {
+ public boolean verifyEditConfig(DatastoreId target, String mode, String request) {
boolean result;
assertTrue("Incorrect target", target.equals(RUNNING));
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuConfigTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuConfigTest.java
index 5778a1b..aecf2c1 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuConfigTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuConfigTest.java
@@ -18,8 +18,7 @@
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.netconf.TargetConfig;
-
+import org.onosproject.netconf.DatastoreId;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
@@ -345,7 +344,7 @@
}
@Override
- public boolean verifyEditConfig(TargetConfig target, String mode, String request) {
+ public boolean verifyEditConfig(DatastoreId target, String mode, String request) {
return false;
}
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfigTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfigTest.java
index 7268d9a..307af6a 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfigTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltOnuOperConfigTest.java
@@ -18,7 +18,7 @@
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.netconf.TargetConfig;
+import org.onosproject.netconf.DatastoreId;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
@@ -220,7 +220,7 @@
}
@Override
- public boolean verifyEditConfig(TargetConfig target, String mode, String request) {
+ public boolean verifyEditConfig(DatastoreId target, String mode, String request) {
return false;
}
diff --git a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfigTest.java b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfigTest.java
index a1d7f7a..ba141b2 100644
--- a/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfigTest.java
+++ b/drivers/fujitsu/src/test/java/org/onosproject/drivers/fujitsu/FujitsuVoltPonLinkConfigTest.java
@@ -18,14 +18,13 @@
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.netconf.TargetConfig;
-
+import org.onosproject.netconf.DatastoreId;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.onosproject.drivers.fujitsu.FujitsuVoltXmlUtilityMock.*;
-import static org.onosproject.netconf.TargetConfig.RUNNING;
+import static org.onosproject.netconf.DatastoreId.RUNNING;
/**
* Unit tests for methods of FujitsuVoltPonLinkConfig.
@@ -227,7 +226,7 @@
}
@Override
- public boolean verifyEditConfig(TargetConfig target, String mode, String request) {
+ public boolean verifyEditConfig(DatastoreId target, String mode, String request) {
boolean result;
assertTrue("Incorrect target", target.equals(RUNNING));
diff --git a/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/NetconfConfigGetter.java b/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/NetconfConfigGetter.java
index bbdd614..087af0c 100644
--- a/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/NetconfConfigGetter.java
+++ b/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/NetconfConfigGetter.java
@@ -16,6 +16,7 @@
package org.onosproject.drivers.microsemi;
+import static org.onosproject.netconf.DatastoreId.datastore;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.IOException;
@@ -66,7 +67,8 @@
return UNABLE_TO_READ_CONFIG;
}
try {
- return controller.getDevicesMap().get(ofDeviceId).getSession().getConfig(type.replace("cfgType=", ""));
+ return controller.getDevicesMap().get(ofDeviceId).getSession()
+ .getConfig(datastore(type.replace("cfgType=", "")));
} catch (IOException e) {
log.error("Configuration could not be retrieved {}", e.getMessage());
}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockNetconfSessionEa1000.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockNetconfSessionEa1000.java
index 244934b..8068cff 100644
--- a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockNetconfSessionEa1000.java
+++ b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/MockNetconfSessionEa1000.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.drivers.microsemi.yang;
-import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
@@ -24,12 +23,11 @@
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfDeviceOutputEventListener;
import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.NetconfSession;
-import org.onosproject.netconf.TargetConfig;
+import org.onosproject.netconf.NetconfSessionAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class MockNetconfSessionEa1000 implements NetconfSession {
+public class MockNetconfSessionEa1000 extends NetconfSessionAdapter {
private static final Logger log = LoggerFactory
.getLogger(MockNetconfSessionEa1000.class);
@@ -822,7 +820,6 @@
return reply;
}
-
@Override
public String getConfig(DatastoreId targetConfiguration, String configurationSchema) throws NetconfException {
StringBuilder rpc = new StringBuilder(XML_HEADER);
@@ -888,7 +885,7 @@
@Override
public boolean copyConfig(String targetConfiguration, String newConfiguration) throws NetconfException {
- return copyConfig(TargetConfig.valueOf(targetConfiguration), newConfiguration);
+ return copyConfig(DatastoreId.datastore(targetConfiguration), newConfiguration);
}
@Override
@@ -933,18 +930,6 @@
}
@Override
- public String getServerCapabilities() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setDeviceCapabilities(List<String> capabilities) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
// TODO Auto-generated method stub
diff --git a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/package-info.java b/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/package-info.java
deleted file mode 100644
index 7acdee9..0000000
--- a/drivers/microsemi/src/test/java/org/onosproject/drivers/microsemi/yang/package-info.java
+++ /dev/null
@@ -1,20 +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 for Microsemi device drivers support for NETCONF for EA1000.
- */
-package org.onosproject.drivers.microsemi.yang;
\ No newline at end of file
diff --git a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigGetter.java b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigGetter.java
index 446a0e2..2739872 100644
--- a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigGetter.java
+++ b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfConfigGetter.java
@@ -19,9 +19,9 @@
import com.google.common.base.Preconditions;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.ConfigGetter;
-import org.onosproject.netconf.TargetConfig;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfController;
import org.slf4j.Logger;
@@ -56,7 +56,7 @@
return controller.getDevicesMap().
get(ofDeviceId).
getSession().
- getConfig(TargetConfig.valueOf(type));
+ getConfig(DatastoreId.datastore(type));
} catch (IOException e) {
log.error("Configuration could not be retrieved {}",
e.getMessage());
diff --git a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfControllerConfig.java b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfControllerConfig.java
index bce3b6d..6a8710d 100644
--- a/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfControllerConfig.java
+++ b/drivers/netconf/src/main/java/org/onosproject/drivers/netconf/NetconfControllerConfig.java
@@ -24,6 +24,7 @@
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfController;
import org.onosproject.netconf.NetconfDevice;
@@ -35,7 +36,6 @@
import java.util.ArrayList;
import java.util.List;
-import static org.onosproject.netconf.TargetConfig.RUNNING;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -59,7 +59,7 @@
if (mastershipService.isLocalMaster(deviceId)) {
try {
String reply = controller.getNetconfDevice(deviceId).getSession().
- getConfig(RUNNING);
+ getConfig(DatastoreId.RUNNING);
log.debug("Reply XML {}", reply);
controllers.addAll(XmlConfigParser.parseStreamControllers(XmlConfigParser.
loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8)))));
@@ -87,7 +87,7 @@
String config = null;
try {
- String reply = device.getSession().getConfig(RUNNING);
+ String reply = device.getSession().getConfig(DatastoreId.RUNNING);
log.info("reply XML {}", reply);
config = XmlConfigParser.createControllersConfig(
XmlConfigParser.loadXml(getClass().getResourceAsStream("controllers.xml")),
diff --git a/drivers/netconf/src/test/java/org/onosproject/drivers/netconf/MockNetconfSession.java b/drivers/netconf/src/test/java/org/onosproject/drivers/netconf/MockNetconfSession.java
index 1a973dd..155a5a0 100644
--- a/drivers/netconf/src/test/java/org/onosproject/drivers/netconf/MockNetconfSession.java
+++ b/drivers/netconf/src/test/java/org/onosproject/drivers/netconf/MockNetconfSession.java
@@ -15,20 +15,19 @@
*/
package org.onosproject.drivers.netconf;
-import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
+import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfDeviceOutputEventListener;
import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.NetconfSession;
-import org.onosproject.netconf.TargetConfig;
+import org.onosproject.netconf.NetconfSessionAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class MockNetconfSession implements NetconfSession {
+public class MockNetconfSession extends NetconfSessionAdapter {
private static final Logger log = LoggerFactory
.getLogger(MockNetconfSession.class);
@@ -158,23 +157,13 @@
@Override
- public String getConfig(String targetConfiguration, String configurationSchema) throws NetconfException {
- return getConfig(TargetConfig.valueOf(targetConfiguration));
- }
-
- @Override
- public String getConfig(String targetConfiguration) throws NetconfException {
- return getConfig(TargetConfig.valueOf(targetConfiguration), null);
- }
-
- @Override
- public String getConfig(TargetConfig netconfTargetConfig)
+ public String getConfig(DatastoreId netconfTargetConfig)
throws NetconfException {
return getConfig(netconfTargetConfig, null);
}
@Override
- public String getConfig(TargetConfig netconfTargetConfig, String configurationFilterSchema)
+ public String getConfig(DatastoreId netconfTargetConfig, String configurationFilterSchema)
throws NetconfException {
StringBuilder rpc = new StringBuilder(XML_HEADER);
rpc.append("<rpc ");
@@ -201,7 +190,7 @@
}
@Override
- public boolean editConfig(TargetConfig netconfTargetConfig, String mode, String newConfiguration)
+ public boolean editConfig(DatastoreId netconfTargetConfig, String mode, String newConfiguration)
throws NetconfException {
newConfiguration = newConfiguration.trim();
StringBuilder rpc = new StringBuilder(XML_HEADER);
@@ -234,17 +223,11 @@
@Override
public boolean editConfig(String newConfiguration) throws NetconfException {
- return editConfig(TargetConfig.RUNNING, null, newConfiguration);
+ return editConfig(DatastoreId.RUNNING, null, newConfiguration);
}
@Override
- public boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
- throws NetconfException {
- return editConfig(TargetConfig.valueOf(targetConfiguration), mode, newConfiguration);
- }
-
- @Override
- public boolean copyConfig(TargetConfig netconfTargetConfig, String newConfiguration) throws NetconfException {
+ public boolean copyConfig(DatastoreId netconfTargetConfig, String newConfiguration) throws NetconfException {
newConfiguration = newConfiguration.trim();
StringBuilder rpc = new StringBuilder(XML_HEADER);
rpc.append(RPC_OPEN);
@@ -271,11 +254,11 @@
@Override
public boolean copyConfig(String targetConfiguration, String newConfiguration) throws NetconfException {
- return copyConfig(TargetConfig.valueOf(targetConfiguration), newConfiguration);
+ return copyConfig(DatastoreId.datastore(targetConfiguration), newConfiguration);
}
@Override
- public boolean deleteConfig(TargetConfig netconfTargetConfig) throws NetconfException {
+ public boolean deleteConfig(DatastoreId netconfTargetConfig) throws NetconfException {
StringBuilder rpc = new StringBuilder(XML_HEADER);
rpc.append(RPC_OPEN);
rpc.append(MESSAGE_ID_STRING);
@@ -297,11 +280,6 @@
}
@Override
- public boolean deleteConfig(String targetConfiguration) throws NetconfException {
- return deleteConfig(TargetConfig.valueOf(targetConfiguration));
- }
-
- @Override
public void startSubscription() throws NetconfException {
// TODO Auto-generated method stub
@@ -320,18 +298,6 @@
}
@Override
- public boolean lock(String configType) throws NetconfException {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean unlock(String configType) throws NetconfException {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
public boolean lock() throws NetconfException {
// TODO Auto-generated method stub
return false;
@@ -355,18 +321,6 @@
}
@Override
- public String getServerCapabilities() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setDeviceCapabilities(List<String> capabilities) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
// TODO Auto-generated method stub
diff --git a/features/BUCK b/features/BUCK
index 8094ff9..bb87afc 100644
--- a/features/BUCK
+++ b/features/BUCK
@@ -36,6 +36,8 @@
'//lib:commons-io',
'//lib:jersey-client',
'//lib:mapdb',
+ '//lib:bcpkix-jdk15on',
+ '//lib:bcprov-jdk15on',
]
)
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualMeterStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualMeterStore.java
index 3b5d122..3042f33 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualMeterStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualMeterStore.java
@@ -19,9 +19,11 @@
import com.google.common.collect.Collections2;
import com.google.common.collect.Maps;
import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.NodeId;
import org.onosproject.incubator.net.virtual.NetworkId;
@@ -53,7 +55,8 @@
* Implementation of the virtual meter store for a single instance.
*/
//TODO: support distributed meter store for virtual networks
-
+@Component(immediate = true)
+@Service
public class SimpleVirtualMeterStore
extends AbstractVirtualStore<MeterEvent, MeterStoreDelegate>
implements VirtualNetworkMeterStore {
diff --git a/lib/BUCK b/lib/BUCK
index 87add7d..1ca9fbb 100644
--- a/lib/BUCK
+++ b/lib/BUCK
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Thu, 31 Aug 2017 21:26:06 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Sun, 3 Sep 2017 12:12:12 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
pass_thru_pom(
@@ -1491,3 +1491,21 @@
visibility = [ 'PUBLIC' ],
)
+remote_jar (
+ name = 'bcpkix-jdk15on',
+ out = 'bcpkix-jdk15on-1.58.jar',
+ url = 'mvn:org.bouncycastle:bcpkix-jdk15on:jar:1.58',
+ sha1 = '15a760a039b040e767a75c77ffcc4ff62558f903',
+ maven_coords = 'org.bouncycastle:bcpkix-jdk15on:1.58',
+ visibility = [ 'PUBLIC' ],
+)
+
+remote_jar (
+ name = 'bcprov-jdk15on',
+ out = 'bcprov-jdk15on-1.58.jar',
+ url = 'mvn:org.bouncycastle:bcprov-jdk15on:jar:1.58',
+ sha1 = '2c9aa1c4e3372b447ba5daabade4adf2a2264b12',
+ maven_coords = 'org.bouncycastle:bcprov-jdk15on:1.58',
+ visibility = [ 'PUBLIC' ],
+)
+
diff --git a/lib/deps.json b/lib/deps.json
index 35282c4..7ed72bc 100644
--- a/lib/deps.json
+++ b/lib/deps.json
@@ -266,6 +266,8 @@
"google-truth-0.28": "mvn:com.google.truth:truth:0.28",
"google-code-findbugs-3.0.0": "mvn:com.google.code.findbugs:jsr305:3.0.0",
"google-errorprone-2.0.19": "mvn:com.google.errorprone:error_prone_annotations:2.0.19",
- "google-instrumentation-0.3.0": "mvn:com.google.instrumentation:instrumentation-api:0.3.0"
+ "google-instrumentation-0.3.0": "mvn:com.google.instrumentation:instrumentation-api:0.3.0",
+ "bcpkix-jdk15on": "mvn:org.bouncycastle:bcpkix-jdk15on:1.58",
+ "bcprov-jdk15on": "mvn:org.bouncycastle:bcprov-jdk15on:1.58"
}
}
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
index 06c8b9c..420a961 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
@@ -20,12 +20,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
/**
* NETCONF session object that allows NETCONF operations on top with the physical
@@ -100,44 +96,7 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- default String getConfig(DatastoreId netconfTargetConfig) throws NetconfException {
- // default implementation provided for backward compatibility
- // this API is the one, which should be implemented
- // TODO default implementation here should be removed after
- // deprecation of the other 2 variants.
- return getConfig(netconfTargetConfig.id());
- }
-
- /**
- * Retrieves the specified configuration.
- *
- * @param netconfTargetConfig the type of configuration to retrieve.
- * @return specified configuration.
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration parameter instead
- */
- @Deprecated
- default String getConfig(TargetConfig netconfTargetConfig) throws NetconfException {
- return getConfig(TargetConfig.toDatastoreId(netconfTargetConfig));
- }
-
- /**
- * Retrieves the specified configuration.
- *
- * @param netconfTargetConfig the type of configuration to retrieve.
- * @return specified configuration.
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration parameter instead
- */
- @Deprecated
- default String getConfig(String netconfTargetConfig) throws NetconfException {
- return getConfig(TargetConfig.toDatastoreId(netconfTargetConfig));
- }
-
+ String getConfig(DatastoreId netconfTargetConfig) throws NetconfException;
/**
* Retrieves part of the specified configuration based on the filterSchema.
@@ -149,55 +108,9 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- default String getConfig(DatastoreId netconfTargetConfig,
+ String getConfig(DatastoreId netconfTargetConfig,
String configurationFilterSchema)
- throws NetconfException {
- // default implementation provided for backward compatibility
- // this API is the one, which should be implemented
- // TODO default implementation here should be removed after
- // deprecation of the other 2 variants.
- return getConfig(netconfTargetConfig.id(), configurationFilterSchema);
- }
-
-
- /**
- * Retrieves part of the specified configuration based on the filterSchema.
- *
- * @param netconfTargetConfig the type of configuration to retrieve.
- * @param configurationFilterSchema XML schema to filter the configuration
- * elements we are interested in
- * @return device running configuration.
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfig enum parameter instead
- */
- @Deprecated
- default String getConfig(String netconfTargetConfig, String configurationFilterSchema)
- throws NetconfException {
- return getConfig(TargetConfig.toDatastoreId(netconfTargetConfig),
- configurationFilterSchema);
- }
-
- /**
- * Retrieves part of the specified configuration based on the filterSchema.
- *
- * @param netconfTargetConfig the type of configuration to retrieve.
- * @param configurationFilterSchema XML schema to filter the configuration
- * elements we are interested in
- * @return device running configuration.
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfig enum parameter instead
- */
- @Deprecated
- default String getConfig(TargetConfig netconfTargetConfig, String configurationFilterSchema)
- throws NetconfException {
- return getConfig(TargetConfig.toDatastoreId(netconfTargetConfig),
- configurationFilterSchema);
- }
-
+ throws NetconfException;
/**
* Retrieves part of the specified configuration based on the filterSchema.
@@ -207,7 +120,6 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
-
boolean editConfig(String newConfiguration) throws NetconfException;
/**
@@ -220,54 +132,8 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- default boolean editConfig(DatastoreId netconfTargetConfig, String mode, String newConfiguration)
- throws NetconfException {
- // default implementation provided for backward compatibility
- // this API is the one, which should be implemented
- // TODO default implementation here should be removed after
- // deprecation of the other 2 variants.
- return editConfig(netconfTargetConfig.id(), mode, newConfiguration);
- }
-
- /**
- * Retrieves part of the specified configuration based on the filterSchema.
- *
- * @param netconfTargetConfig the targetConfiguration to change
- * @param mode selected mode to change the configuration
- * @param newConfiguration configuration to set
- * @return true if the configuration was edited correctly
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration enum parameter instead
- */
- @Deprecated
- default boolean editConfig(String netconfTargetConfig, String mode, String newConfiguration)
- throws NetconfException {
- return editConfig(TargetConfig.toDatastoreId(netconfTargetConfig),
- mode,
- newConfiguration);
- }
-
- /**
- * Retrieves part of the specified configuration based on the filterSchema.
- *
- * @param netconfTargetConfig the targetConfiguration to change
- * @param mode selected mode to change the configuration
- * @param newConfiguration configuration to set
- * @return true if the configuration was edited correctly
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration enum parameter instead
- */
- @Deprecated
- default boolean editConfig(TargetConfig netconfTargetConfig, String mode, String newConfiguration)
- throws NetconfException {
- return editConfig(TargetConfig.toDatastoreId(netconfTargetConfig),
- mode,
- newConfiguration);
- }
+ boolean editConfig(DatastoreId netconfTargetConfig, String mode, String newConfiguration)
+ throws NetconfException;
/**
* Copies the configuration between configuration datastores.
@@ -280,14 +146,8 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- default boolean copyConfig(DatastoreId destination, DatastoreId source)
- throws NetconfException {
- // default implementation provided for backward compatibility
- // but this API should be implemented overriding the default
- // TODO default implementation here should be removed after
- // deprecation of the other 2 variants.
- return copyConfig(destination.id(), source.id());
- }
+ boolean copyConfig(DatastoreId destination, DatastoreId source)
+ throws NetconfException;
/**
* Copies the new configuration, an Url or a complete configuration xml tree
@@ -300,14 +160,8 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- default boolean copyConfig(DatastoreId netconfTargetConfig, String newConfiguration)
- throws NetconfException {
- // default implementation provided for backward compatibility
- // but this API should be implemented overriding the default
- // TODO default implementation here should be removed after
- // deprecation of the other 2 variants.
- return copyConfig(netconfTargetConfig.id(), newConfiguration);
- }
+ boolean copyConfig(DatastoreId netconfTargetConfig, String newConfiguration)
+ throws NetconfException;
/**
* Copies the new configuration, an Url or a complete configuration xml tree
@@ -324,25 +178,6 @@
throws NetconfException;
/**
- * Copies the new configuration, an Url or a complete configuration xml tree
- * to the target configuration.
- * The target configuration can't be the running one
- *
- * @param netconfTargetConfig the type of configuration to retrieve.
- * @param newConfiguration configuration to set
- * @return true if the configuration was copied correctly
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration enum parameter instead
- */
- @Deprecated
- default boolean copyConfig(TargetConfig netconfTargetConfig, String newConfiguration)
- throws NetconfException {
- return copyConfig(TargetConfig.toDatastoreId(netconfTargetConfig), newConfiguration);
- }
-
- /**
* Deletes part of the specified configuration based on the filterSchema.
*
* @param netconfTargetConfig the name of the configuration to delete
@@ -350,43 +185,7 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- default boolean deleteConfig(DatastoreId netconfTargetConfig) throws NetconfException {
- // default implementation provided for backward compatibility
- // this API is the one, which should be implemented
- // TODO default implementation here should be removed after
- // deprecation of the other 2 variants.
- return deleteConfig(netconfTargetConfig.id());
- }
-
- /**
- * Deletes part of the specified configuration based on the filterSchema.
- *
- * @param netconfTargetConfig the name of the configuration to delete
- * @return true if the configuration was deleted correctly
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration enum parameter instead
- */
- @Deprecated
- default boolean deleteConfig(String netconfTargetConfig) throws NetconfException {
- return deleteConfig(TargetConfig.toDatastoreId(netconfTargetConfig));
- }
-
- /**
- * Deletes part of the specified configuration based on the filterSchema.
- *
- * @param netconfTargetConfig the name of the configuration to delete
- * @return true if the configuration was copied correctly
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration enum parameter instead
- */
- @Deprecated
- default boolean deleteConfig(TargetConfig netconfTargetConfig) throws NetconfException {
- return deleteConfig(TargetConfig.toDatastoreId(netconfTargetConfig));
- }
+ boolean deleteConfig(DatastoreId netconfTargetConfig) throws NetconfException;
/**
* Starts subscription to the device's notifications.
@@ -419,28 +218,7 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- default boolean lock(DatastoreId datastore) throws NetconfException {
- // default implementation provided for backward compatibility
- // this API is the one, which should be implemented
- // TODO default implementation here should be removed after
- // deprecation of the other 2 variants.
- return lock(datastore.id());
- }
-
- /**
- * Locks the specified configuration.
- *
- * @param configType type of configuration to be locked
- * @return true if successful.
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration parameter instead
- */
- @Deprecated
- default boolean lock(String configType) throws NetconfException {
- return lock(TargetConfig.toDatastoreId(configType));
- }
+ boolean lock(DatastoreId datastore) throws NetconfException;
/**
* Unlocks the specified configuration.
@@ -450,28 +228,7 @@
* @throws NetconfException when there is a problem in the communication process on
* the underlying connection
*/
- default boolean unlock(DatastoreId datastore) throws NetconfException {
- // default implementation provided for backward compatibility
- // this API is the one, which should be implemented
- // TODO default implementation here should be removed after
- // deprecation of the other 2 variants.
- return unlock(datastore.id());
- }
-
- /**
- * Unlocks the specified configuration.
- *
- * @param configType type of configuration to be locked
- * @return true if successful.
- * @throws NetconfException when there is a problem in the communication process on
- * the underlying connection
- * @deprecated - 1.10.0 Kingfisher use method overload that accepts
- * org.onosproject.netconf.TargetConfiguration parameter instead
- */
- @Deprecated
- default boolean unlock(String configType) throws NetconfException {
- return unlock(TargetConfig.toDatastoreId(configType));
- }
+ boolean unlock(DatastoreId datastore) throws NetconfException;
/**
* Locks the running configuration.
@@ -519,40 +276,8 @@
* @return Network capabilities as strings in a Set.
*
* @since 1.10.0
- * Note: default implementation provided with the interface
- * will be removed when {@code getServerCapabilities()} reaches
- * deprecation grace period.
*/
- default Set<String> getDeviceCapabilitiesSet() {
- // default implementation should be removed in the future
- Set<String> capabilities = new LinkedHashSet<>();
- Matcher capabilityMatcher =
- Pattern.compile("<capability>\\s*(.*?)\\s*</capability>")
- .matcher(getServerCapabilities());
- while (capabilityMatcher.find()) {
- capabilities.add(capabilityMatcher.group(1));
- }
- return capabilities;
- }
-
- /**
- * Gets the capabilities of the Netconf server (remote device) associated
- * to this session.
- *
- * @return Network capabilities as a string.
- * @deprecated 1.10.0 use {@link #getDeviceCapabilitiesSet()} instead
- */
- @Deprecated
- String getServerCapabilities();
-
- /**
- * Sets the ONOS side capabilities.
- *
- * @param capabilities list of capabilities the device has.
- * @deprecated 1.10.0 use {@link #setOnosCapabilities(Iterable)} instead
- */
- @Deprecated
- void setDeviceCapabilities(List<String> capabilities);
+ Set<String> getDeviceCapabilitiesSet();
/**
* Checks the state of the underlying SSH session and connection
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSessionAdapter.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSessionAdapter.java
index a399d92..6ca84c7 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSessionAdapter.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSessionAdapter.java
@@ -15,7 +15,8 @@
*/
package org.onosproject.netconf;
-import java.util.List;
+import java.util.Collections;
+import java.util.Set;
import java.util.concurrent.CompletableFuture;
import org.onlab.util.Tools;
@@ -34,10 +35,6 @@
}
@Override
- public void setDeviceCapabilities(List<String> capabilities) {
- }
-
- @Override
public String requestSync(String request) throws NetconfException {
return null;
}
@@ -58,11 +55,6 @@
}
@Override
- public String getServerCapabilities() {
- return null;
- }
-
- @Override
public String get(String filterSchema, String withDefaultsMode)
throws NetconfException {
return null;
@@ -88,6 +80,19 @@
}
@Override
+ public boolean copyConfig(DatastoreId destination, DatastoreId source)
+ throws NetconfException {
+ return true;
+ }
+
+ @Override
+ public boolean copyConfig(DatastoreId netconfTargetConfig,
+ String newConfiguration)
+ throws NetconfException {
+ return true;
+ }
+
+ @Override
public boolean copyConfig(String netconfTargetConfig,
String newConfiguration)
throws NetconfException {
@@ -102,4 +107,45 @@
@Override
public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
}
+
+ @Override
+ public String getConfig(DatastoreId netconfTargetConfig)
+ throws NetconfException {
+ return null;
+ }
+
+ @Override
+ public String getConfig(DatastoreId netconfTargetConfig,
+ String configurationFilterSchema)
+ throws NetconfException {
+ return null;
+ }
+
+ @Override
+ public boolean editConfig(DatastoreId netconfTargetConfig, String mode,
+ String newConfiguration)
+ throws NetconfException {
+ return true;
+ }
+
+ @Override
+ public boolean deleteConfig(DatastoreId netconfTargetConfig)
+ throws NetconfException {
+ return true;
+ }
+
+ @Override
+ public boolean lock(DatastoreId datastore) throws NetconfException {
+ return true;
+ }
+
+ @Override
+ public boolean unlock(DatastoreId datastore) throws NetconfException {
+ return true;
+ }
+
+ @Override
+ public Set<String> getDeviceCapabilitiesSet() {
+ return Collections.emptySet();
+ }
}
\ No newline at end of file
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/TargetConfig.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/TargetConfig.java
deleted file mode 100644
index 4314baf..0000000
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/TargetConfig.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2017-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.netconf;
-
-/**
- * @deprecated in 1.10.0 use TargetConfiguration instead
- * According to NETCONF RFC,
- * various additional configuration datastores may be defined by capabilities.
- */
-@Deprecated
-public enum TargetConfig {
- RUNNING("running"),
- CANDIDATE("candidate"),
- STARTUP("startup");
-
- private String name;
-
- TargetConfig(String name) {
- this.name = name;
- }
-
- public static TargetConfig toTargetConfig(String targetConfig) {
- return valueOf(targetConfig.toUpperCase());
- }
-
- public static DatastoreId toDatastoreId(String cfg) {
- return toDatastoreId(toTargetConfig(cfg));
- }
-
- public static DatastoreId toDatastoreId(TargetConfig cfg) {
- switch (cfg) {
- case CANDIDATE:
- return DatastoreId.CANDIDATE;
- case RUNNING:
- return DatastoreId.RUNNING;
- case STARTUP:
- return DatastoreId.STARTUP;
- default:
- return DatastoreId.datastore(cfg.name);
- }
- }
-
- @Override
- public String toString() {
- return this.name;
- }
-
-}
diff --git a/protocols/netconf/ctl/BUCK b/protocols/netconf/ctl/BUCK
index 2d79045..8abf233 100644
--- a/protocols/netconf/ctl/BUCK
+++ b/protocols/netconf/ctl/BUCK
@@ -6,6 +6,8 @@
'//cli:onos-cli',
'//lib:org.apache.karaf.shell.console',
'//lib:sshd-core',
+ '//lib:bcpkix-jdk15on',
+ '//lib:bcprov-jdk15on',
]
TEST_DEPS = [
diff --git a/protocols/netconf/ctl/pom.xml b/protocols/netconf/ctl/pom.xml
index c4108ae..0306e181 100644
--- a/protocols/netconf/ctl/pom.xml
+++ b/protocols/netconf/ctl/pom.xml
@@ -78,6 +78,18 @@
<artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk15on</artifactId>
+ <version>1.58</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ <version>1.58</version>
+ </dependency>
+
</dependencies>
<build>
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java
deleted file mode 100644
index 1d36bc3..0000000
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/DefaultNetconfDevice.java
+++ /dev/null
@@ -1,98 +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.netconf.ctl;
-
-import org.onosproject.netconf.NetconfDevice;
-import org.onosproject.netconf.NetconfDeviceInfo;
-import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.NetconfSession;
-import org.onosproject.netconf.NetconfSessionFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-/**
- * Default implementation of a NETCONF device.
- *
- * @deprecated in 1.10.0
- */
-@Deprecated
-public class DefaultNetconfDevice implements NetconfDevice {
-
- public static final Logger log = LoggerFactory
- .getLogger(DefaultNetconfDevice.class);
-
- private NetconfDeviceInfo netconfDeviceInfo;
- private boolean deviceState = true;
- protected NetconfSessionFactory sessionFactory = new SshNetconfSessionFactory();
- private NetconfSession netconfSession;
-
- /**
- * Creates a new default NETCONF device with the information provided.
- * The device gets created only if no exception is thrown while connecting to
- * it and establishing the NETCONF session.
- * @param deviceInfo information about the device to be created.
- * @throws NetconfException if there are problems in creating or establishing
- * the underlying NETCONF connection and session.
- */
- public DefaultNetconfDevice(NetconfDeviceInfo deviceInfo)
- throws NetconfException {
- netconfDeviceInfo = deviceInfo;
- try {
- netconfSession = sessionFactory.createNetconfSession(deviceInfo);
- } catch (IOException e) {
- deviceState = false;
- throw new NetconfException("Cannot create connection and session for device " +
- deviceInfo, e);
- }
- }
-
- @Override
- public boolean isActive() {
- return deviceState;
- }
-
- @Override
- public NetconfSession getSession() {
- return netconfSession;
- }
-
- @Override
- public void disconnect() {
- deviceState = false;
- try {
- netconfSession.close();
- } catch (IOException e) {
- log.warn("Cannot communicate with the device {} session already closed", netconfDeviceInfo);
- }
- }
-
- @Override
- public NetconfDeviceInfo getDeviceInfo() {
- return netconfDeviceInfo;
- }
-
- public class SshNetconfSessionFactory implements NetconfSessionFactory {
-
- @Override
- public NetconfSession createNetconfSession(NetconfDeviceInfo netconfDeviceInfo) throws NetconfException {
- return new NetconfSessionImpl(netconfDeviceInfo);
- }
- }
-
-}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java
deleted file mode 100644
index c26500f..0000000
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java
+++ /dev/null
@@ -1,344 +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.netconf.ctl;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Modified;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cfg.ComponentConfigService;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.key.DeviceKey;
-import org.onosproject.net.key.DeviceKeyId;
-import org.onosproject.net.key.DeviceKeyService;
-import org.onosproject.net.key.UsernamePassword;
-import org.onosproject.netconf.NetconfController;
-import org.onosproject.netconf.NetconfDevice;
-import org.onosproject.netconf.NetconfDeviceFactory;
-import org.onosproject.netconf.NetconfDeviceInfo;
-import org.onosproject.netconf.NetconfDeviceListener;
-import org.onosproject.netconf.NetconfDeviceOutputEvent;
-import org.onosproject.netconf.NetconfDeviceOutputEventListener;
-import org.onosproject.netconf.NetconfException;
-import org.osgi.service.component.ComponentContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onlab.util.Tools.get;
-import static org.onlab.util.Tools.groupedThreads;
-
-/**
- * The implementation of NetconfController.
- *
- * @deprecated in 1.10.0
- */
-@Deprecated
-@Component(immediate = false, enabled = false)
-@Service
-public class NetconfControllerImpl implements NetconfController {
- private static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 5;
- private static final String PROP_NETCONF_CONNECT_TIMEOUT = "netconfConnectTimeout";
- @Property(name = PROP_NETCONF_CONNECT_TIMEOUT, intValue = DEFAULT_CONNECT_TIMEOUT_SECONDS,
- label = "Time (in seconds) to wait for a NETCONF connect.")
- protected static int netconfConnectTimeout = DEFAULT_CONNECT_TIMEOUT_SECONDS;
-
- private static final String PROP_NETCONF_REPLY_TIMEOUT = "netconfReplyTimeout";
- private static final int DEFAULT_REPLY_TIMEOUT_SECONDS = 5;
- @Property(name = PROP_NETCONF_REPLY_TIMEOUT, intValue = DEFAULT_REPLY_TIMEOUT_SECONDS,
- label = "Time (in seconds) waiting for a NetConf reply")
- protected static int netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ComponentConfigService cfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceKeyService deviceKeyService;
-
- public static final Logger log = LoggerFactory
- .getLogger(NetconfControllerImpl.class);
-
- private Map<DeviceId, NetconfDevice> netconfDeviceMap = new ConcurrentHashMap<>();
-
- private final NetconfDeviceOutputEventListener downListener = new DeviceDownEventListener();
-
- protected Set<NetconfDeviceListener> netconfDeviceListeners = new CopyOnWriteArraySet<>();
- protected NetconfDeviceFactory deviceFactory = new DefaultNetconfDeviceFactory();
-
- protected final ExecutorService executor =
- Executors.newCachedThreadPool(groupedThreads("onos/netconfdevicecontroller",
- "connection-reopen-%d", log));
-
- @Activate
- public void activate(ComponentContext context) {
- cfgService.registerProperties(getClass());
- modified(context);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- cfgService.unregisterProperties(getClass(), false);
- netconfDeviceMap.clear();
- log.info("Stopped");
- }
-
- @Modified
- public void modified(ComponentContext context) {
- if (context == null) {
- netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS;
- netconfConnectTimeout = DEFAULT_CONNECT_TIMEOUT_SECONDS;
- log.info("No component configuration");
- return;
- }
-
- Dictionary<?, ?> properties = context.getProperties();
-
- int newNetconfReplyTimeout;
- int newNetconfConnectTimeout;
- try {
- String s = get(properties, PROP_NETCONF_REPLY_TIMEOUT);
- newNetconfReplyTimeout = isNullOrEmpty(s) ?
- netconfReplyTimeout : Integer.parseInt(s.trim());
-
- s = get(properties, PROP_NETCONF_CONNECT_TIMEOUT);
- newNetconfConnectTimeout = isNullOrEmpty(s) ?
- netconfConnectTimeout : Integer.parseInt(s.trim());
-
- } catch (NumberFormatException e) {
- log.warn("Component configuration had invalid value", e);
- return;
- }
-
- if (newNetconfConnectTimeout < 0) {
- log.warn("netconfConnectTimeout is invalid - less than 0");
- return;
- } else if (newNetconfReplyTimeout <= 0) {
- log.warn("netconfReplyTimeout is invalid - 0 or less.");
- return;
- }
-
- netconfReplyTimeout = newNetconfReplyTimeout;
- netconfConnectTimeout = newNetconfConnectTimeout;
- log.info("Settings: {} = {}, {} = {}",
- PROP_NETCONF_REPLY_TIMEOUT, netconfReplyTimeout, PROP_NETCONF_CONNECT_TIMEOUT, netconfConnectTimeout);
- }
-
- @Override
- public void addDeviceListener(NetconfDeviceListener listener) {
- if (!netconfDeviceListeners.contains(listener)) {
- netconfDeviceListeners.add(listener);
- }
- }
-
- @Override
- public void removeDeviceListener(NetconfDeviceListener listener) {
- netconfDeviceListeners.remove(listener);
- }
-
- @Override
- public NetconfDevice getNetconfDevice(DeviceId deviceInfo) {
- return netconfDeviceMap.get(deviceInfo);
- }
-
- @Override
- public NetconfDevice getNetconfDevice(IpAddress ip, int port) {
- for (DeviceId info : netconfDeviceMap.keySet()) {
- if (info.uri().getSchemeSpecificPart().equals(ip.toString() + ":" + port)) {
- return netconfDeviceMap.get(info);
- }
- }
- return null;
- }
-
- @Override
- public NetconfDevice connectDevice(DeviceId deviceId) throws NetconfException {
- if (netconfDeviceMap.containsKey(deviceId)) {
- log.debug("Device {} is already present", deviceId);
- return netconfDeviceMap.get(deviceId);
- } else {
- log.debug("Creating NETCONF device {}", deviceId);
- Device device = deviceService.getDevice(deviceId);
- String ip;
- int port;
- if (device != null) {
- ip = device.annotations().value("ipaddress");
- port = Integer.parseInt(device.annotations().value("port"));
- } else {
- String[] info = deviceId.toString().split(":");
- if (info.length == 3) {
- ip = info[1];
- port = Integer.parseInt(info[2]);
- } else {
- ip = Arrays.asList(info).stream().filter(el -> !el.equals(info[0])
- && !el.equals(info[info.length - 1]))
- .reduce((t, u) -> t + ":" + u)
- .get();
- log.debug("ip v6 {}", ip);
- port = Integer.parseInt(info[info.length - 1]);
- }
- }
- try {
- DeviceKey deviceKey = deviceKeyService.getDeviceKey(
- DeviceKeyId.deviceKeyId(deviceId.toString()));
- NetconfDeviceInfo deviceInfo = null;
- if (deviceKey.type() == DeviceKey.Type.USERNAME_PASSWORD) {
- UsernamePassword usernamepasswd = deviceKey.asUsernamePassword();
-
- deviceInfo = new NetconfDeviceInfo(usernamepasswd.username(),
- usernamepasswd.password(),
- IpAddress.valueOf(ip),
- port);
-
- } else if (deviceKey.type() == DeviceKey.Type.SSL_KEY) {
- String username = deviceKey.annotations().value(AnnotationKeys.USERNAME);
- String password = deviceKey.annotations().value(AnnotationKeys.PASSWORD);
- String sshkey = deviceKey.annotations().value(AnnotationKeys.SSHKEY);
-
- deviceInfo = new NetconfDeviceInfo(username,
- password,
- IpAddress.valueOf(ip),
- port,
- sshkey);
- } else {
- log.error("Unknown device key for device {}", deviceId);
- }
- NetconfDevice netconfDevicedevice = createDevice(deviceInfo);
- netconfDevicedevice.getSession().addDeviceOutputListener(downListener);
- return netconfDevicedevice;
- } catch (NullPointerException e) {
- throw new NetconfException("No Device Key for device " + deviceId, e);
- }
- }
- }
-
- @Override
- public void disconnectDevice(DeviceId deviceId, boolean remove) {
- if (!netconfDeviceMap.containsKey(deviceId)) {
- log.warn("Device {} is not present", deviceId);
- } else {
- stopDevice(deviceId, remove);
- }
- }
-
- private void stopDevice(DeviceId deviceId, boolean remove) {
- netconfDeviceMap.get(deviceId).disconnect();
- netconfDeviceMap.remove(deviceId);
- if (remove) {
- for (NetconfDeviceListener l : netconfDeviceListeners) {
- l.deviceRemoved(deviceId);
- }
- }
- }
-
- @Override
- public void removeDevice(DeviceId deviceId) {
- if (!netconfDeviceMap.containsKey(deviceId)) {
- log.warn("Device {} is not present", deviceId);
- for (NetconfDeviceListener l : netconfDeviceListeners) {
- l.deviceRemoved(deviceId);
- }
- } else {
- netconfDeviceMap.remove(deviceId);
- for (NetconfDeviceListener l : netconfDeviceListeners) {
- l.deviceRemoved(deviceId);
- }
- }
- }
-
- private NetconfDevice createDevice(NetconfDeviceInfo deviceInfo) throws NetconfException {
- NetconfDevice netconfDevice = deviceFactory.createNetconfDevice(deviceInfo);
- netconfDeviceMap.put(deviceInfo.getDeviceId(), netconfDevice);
- for (NetconfDeviceListener l : netconfDeviceListeners) {
- l.deviceAdded(deviceInfo.getDeviceId());
- }
- return netconfDevice;
- }
-
-
- @Override
- public Map<DeviceId, NetconfDevice> getDevicesMap() {
- return netconfDeviceMap;
- }
-
- @Override
- public Set<DeviceId> getNetconfDevices() {
- return netconfDeviceMap.keySet();
- }
-
-
- //Device factory for the specific NetconfDeviceImpl
- private class DefaultNetconfDeviceFactory implements NetconfDeviceFactory {
-
- @Override
- public NetconfDevice createNetconfDevice(NetconfDeviceInfo netconfDeviceInfo) throws NetconfException {
- return new DefaultNetconfDevice(netconfDeviceInfo);
- }
- }
-
- //Listener for closed session with devices, gets triggered whe devices goes down
- // or sends the endpattern ]]>]]>
- private class DeviceDownEventListener implements NetconfDeviceOutputEventListener {
-
- @Override
- public void event(NetconfDeviceOutputEvent event) {
- DeviceId did = event.getDeviceInfo().getDeviceId();
- if (event.type().equals(NetconfDeviceOutputEvent.Type.DEVICE_UNREGISTERED)) {
- removeDevice(did);
- } else if (event.type().equals(NetconfDeviceOutputEvent.Type.SESSION_CLOSED)) {
- log.info("Trying to reestablish connection with device {}", did);
- executor.execute(() -> {
- try {
- netconfDeviceMap.get(did).getSession().checkAndReestablish();
- log.info("Connection with device {} was reestablished", did);
- } catch (NetconfException e) {
- log.error("The SSH connection with device {} couldn't be " +
- "reestablished due to {}. " +
- "Marking the device as unreachable", e.getMessage());
- log.debug("Complete exception: ", e);
- removeDevice(did);
- }
- });
- }
- }
-
- @Override
- public boolean isRelevant(NetconfDeviceOutputEvent event) {
- return getDevicesMap().containsKey(event.getDeviceInfo().getDeviceId());
- }
- }
-}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceOutputEventListenerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceOutputEventListenerImpl.java
deleted file mode 100644
index 9b093f2..0000000
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceOutputEventListenerImpl.java
+++ /dev/null
@@ -1,71 +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.netconf.ctl;
-
-import org.onosproject.netconf.NetconfDeviceInfo;
-import org.onosproject.netconf.NetconfDeviceOutputEvent;
-import org.onosproject.netconf.NetconfDeviceOutputEventListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Example of a listener for events that happen a Netconf session established
- * for a particular NETCONF device.
- *
- * @deprecated in 1.10.0 use FilteringNetconfDeviceOutputEventListener
- */
-@Deprecated
-public class NetconfDeviceOutputEventListenerImpl implements NetconfDeviceOutputEventListener {
-
- private static final Logger log =
- LoggerFactory.getLogger(NetconfDeviceOutputEventListenerImpl.class);
-
- private NetconfDeviceInfo deviceInfo;
-
- public NetconfDeviceOutputEventListenerImpl(NetconfDeviceInfo deviceInfo) {
- this.deviceInfo = deviceInfo;
- }
-
- @Override
- public void event(NetconfDeviceOutputEvent event) {
- switch (event.type()) {
- case DEVICE_REPLY:
- log.debug("Device {} has reply: {}", deviceInfo, event.getMessagePayload());
- break;
- case DEVICE_NOTIFICATION:
- log.info("Device {} has notification: {}", deviceInfo, event.getMessagePayload());
- break;
- case DEVICE_UNREGISTERED:
- log.warn("Device {} has closed session", deviceInfo);
- break;
- case DEVICE_ERROR:
- log.warn("Device {} has error: {}", deviceInfo, event.getMessagePayload());
- break;
- case SESSION_CLOSED:
- log.warn("Device {} has closed Session: {}", deviceInfo, event.getMessagePayload());
- break;
- default:
- log.warn("Wrong event type {} ", event.type());
- }
-
- }
-
- @Override
- public boolean isRelevant(NetconfDeviceOutputEvent event) {
- return deviceInfo.equals(event.getDeviceInfo());
- }
-}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionDelegate.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionDelegate.java
deleted file mode 100644
index a4a1f87..0000000
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionDelegate.java
+++ /dev/null
@@ -1,36 +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.netconf.ctl;
-
-import org.onosproject.netconf.NetconfDeviceOutputEvent;
-
-/**
- * Entity associated with a NetconfSessionImpl and capable of receiving notifications of
- * events about the session.
- *
- * @deprecated in 1.10.0
- */
-@Deprecated
-public interface NetconfSessionDelegate {
-
- /**
- * Notifies the delegate via the specified event.
- *
- * @param event store generated event
- */
- void notify(NetconfDeviceOutputEvent event);
-}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
deleted file mode 100644
index a2c6a3d..0000000
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
+++ /dev/null
@@ -1,695 +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.netconf.ctl;
-
-import com.google.common.annotations.Beta;
-import ch.ethz.ssh2.Connection;
-import ch.ethz.ssh2.Session;
-import ch.ethz.ssh2.channel.Channel;
-import com.google.common.base.Preconditions;
-import org.onosproject.netconf.TargetConfig;
-import org.onosproject.netconf.NetconfDeviceInfo;
-import org.onosproject.netconf.NetconfDeviceOutputEvent;
-import org.onosproject.netconf.NetconfDeviceOutputEventListener;
-import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.NetconfSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Pattern;
-
-
-/**
- * Implementation of a NETCONF session to talk to a device.
- *
- * @deprecated in 1.10.0
- */
-@Deprecated
-public class NetconfSessionImpl implements NetconfSession {
-
- private static final Logger log = LoggerFactory
- .getLogger(NetconfSessionImpl.class);
-
- private static final String ENDPATTERN = "]]>]]>";
- private static final String MESSAGE_ID_STRING = "message-id";
- private static final String HELLO = "<hello";
- private static final String NEW_LINE = "\n";
- private static final String END_OF_RPC_OPEN_TAG = "\">";
- private static final String EQUAL = "=";
- private static final String NUMBER_BETWEEN_QUOTES_MATCHER = "\"+([0-9]+)+\"";
- private static final String RPC_OPEN = "<rpc ";
- private static final String RPC_CLOSE = "</rpc>";
- private static final String GET_OPEN = "<get>";
- private static final String GET_CLOSE = "</get>";
- private static final String WITH_DEFAULT_OPEN = "<with-defaults ";
- private static final String WITH_DEFAULT_CLOSE = "</with-defaults>";
- private static final String DEFAULT_OPERATION_OPEN = "<default-operation>";
- private static final String DEFAULT_OPERATION_CLOSE = "</default-operation>";
- private static final String SUBTREE_FILTER_OPEN = "<filter type=\"subtree\">";
- private static final String SUBTREE_FILTER_CLOSE = "</filter>";
- private static final String EDIT_CONFIG_OPEN = "<edit-config>";
- private static final String EDIT_CONFIG_CLOSE = "</edit-config>";
- private static final String TARGET_OPEN = "<target>";
- private static final String TARGET_CLOSE = "</target>";
- private static final String CONFIG_OPEN = "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">";
- private static final String CONFIG_CLOSE = "</config>";
- private static final String XML_HEADER =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
- private static final String NETCONF_BASE_NAMESPACE =
- "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"";
- private static final String NETCONF_WITH_DEFAULTS_NAMESPACE =
- "xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\"";
- private static final String SUBSCRIPTION_SUBTREE_FILTER_OPEN =
- "<filter xmlns:base10=\"urn:ietf:params:xml:ns:netconf:base:1.0\" base10:type=\"subtree\">";
-
- private static Pattern msgIdPattern = Pattern.compile("(message-id=\"[0-9]+\")");
-
- private final AtomicInteger messageIdInteger = new AtomicInteger(0);
- private Connection netconfConnection;
- private NetconfDeviceInfo deviceInfo;
- private Session sshSession;
- private boolean connectionActive;
- private List<String> deviceCapabilities =
- Collections.singletonList("urn:ietf:params:netconf:base:1.0");
- private String serverCapabilities;
- private NetconfStreamHandler streamHandler;
- private Map<Integer, CompletableFuture<String>> replies;
- private List<String> errorReplies;
- private boolean subscriptionConnected = false;
- private String notificationFilterSchema = null;
-
- private int connectTimeout;
- private int replyTimeout;
-
-
- public NetconfSessionImpl(NetconfDeviceInfo deviceInfo) throws NetconfException {
- this.deviceInfo = deviceInfo;
- this.netconfConnection = null;
- this.sshSession = null;
- connectionActive = false;
- replies = new ConcurrentHashMap<>();
- errorReplies = new ArrayList<>();
- connectTimeout = deviceInfo.getConnectTimeoutSec().orElse(
- NetconfControllerImpl.netconfConnectTimeout);
- replyTimeout = deviceInfo.getReplyTimeoutSec().orElse(
- NetconfControllerImpl.netconfReplyTimeout);
- log.info("Connecting to {} with timeouts C:{}, R:{}. idle=connect", deviceInfo,
- connectTimeout, replyTimeout);
- startConnection();
- }
-
- private void startConnection() throws NetconfException {
- if (!connectionActive) {
- netconfConnection = new Connection(deviceInfo.ip().toString(), deviceInfo.port());
-
- try {
- netconfConnection.connect(null, 1000 * connectTimeout, 1000 * connectTimeout);
- } catch (IOException e) {
- throw new NetconfException("Cannot open a connection with device " + deviceInfo, e);
- }
- boolean isAuthenticated;
- try {
- if (deviceInfo.getKeyFile() != null && deviceInfo.getKeyFile().canRead()) {
- log.debug("Authenticating with key file to device {} with username {}",
- deviceInfo.getDeviceId(), deviceInfo.name());
- isAuthenticated = netconfConnection.authenticateWithPublicKey(
- deviceInfo.name(), deviceInfo.getKeyFile(),
- deviceInfo.password().equals("") ? null : deviceInfo.password());
- } else if (deviceInfo.getKey() != null) {
- log.debug("Authenticating with key to device {} with username {}",
- deviceInfo.getDeviceId(), deviceInfo.name());
- isAuthenticated = netconfConnection.authenticateWithPublicKey(
- deviceInfo.name(), deviceInfo.getKey(),
- deviceInfo.password().equals("") ? null : deviceInfo.password());
- } else {
- log.debug("Authenticating to device {} with username {} with password",
- deviceInfo.getDeviceId(), deviceInfo.name());
- isAuthenticated = netconfConnection.authenticateWithPassword(
- deviceInfo.name(), deviceInfo.password());
- }
- } catch (IOException e) {
- log.error("Authentication connection to device {} failed",
- deviceInfo.getDeviceId(), e);
- throw new NetconfException("Authentication connection to device " +
- deviceInfo.getDeviceId() + " failed", e);
- }
-
- connectionActive = true;
- Preconditions.checkArgument(isAuthenticated,
- "Authentication to device %s with username " +
- "%s failed",
- deviceInfo.getDeviceId(), deviceInfo.name());
- startSshSession();
- }
- }
-
- private void startSshSession() throws NetconfException {
- try {
- sshSession = netconfConnection.openSession();
- sshSession.startSubSystem("netconf");
- streamHandler = new NetconfStreamThread(sshSession.getStdout(), sshSession.getStdin(),
- sshSession.getStderr(), deviceInfo,
- new NetconfSessionDelegateImpl(),
- replies);
- this.addDeviceOutputListener(new NetconfDeviceOutputEventListenerImpl(deviceInfo));
- sendHello();
- } catch (IOException e) {
- log.error("Failed to create ch.ethz.ssh2.Session session {} ", e.getMessage());
- throw new NetconfException("Failed to create ch.ethz.ssh2.Session session with device" +
- deviceInfo, e);
- }
- }
-
-
- @Beta
- private void startSubscriptionConnection(String filterSchema) throws NetconfException {
- if (!serverCapabilities.contains("interleave")) {
- throw new NetconfException("Device" + deviceInfo + "does not support interleave");
- }
- String reply = sendRequest(createSubscriptionString(filterSchema));
- if (!checkReply(reply)) {
- throw new NetconfException("Subscription not successful with device "
- + deviceInfo + " with reply " + reply);
- }
- subscriptionConnected = true;
- }
-
- @Override
- public void startSubscription() throws NetconfException {
- if (!subscriptionConnected) {
- startSubscriptionConnection(null);
- }
- streamHandler.setEnableNotifications(true);
- }
-
- @Beta
- @Override
- public void startSubscription(String filterSchema) throws NetconfException {
- if (!subscriptionConnected) {
- notificationFilterSchema = filterSchema;
- startSubscriptionConnection(filterSchema);
- }
- streamHandler.setEnableNotifications(true);
- }
-
- @Beta
- private String createSubscriptionString(String filterSchema) {
- StringBuilder subscriptionbuffer = new StringBuilder();
- subscriptionbuffer.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
- subscriptionbuffer.append(" <create-subscription\n");
- subscriptionbuffer.append("xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">\n");
- // FIXME Only subtree filtering supported at the moment.
- if (filterSchema != null) {
- subscriptionbuffer.append(" ");
- subscriptionbuffer.append(SUBSCRIPTION_SUBTREE_FILTER_OPEN).append(NEW_LINE);
- subscriptionbuffer.append(filterSchema).append(NEW_LINE);
- subscriptionbuffer.append(" ");
- subscriptionbuffer.append(SUBTREE_FILTER_CLOSE).append(NEW_LINE);
- }
- subscriptionbuffer.append(" </create-subscription>\n");
- subscriptionbuffer.append("</rpc>\n");
- subscriptionbuffer.append(ENDPATTERN);
- return subscriptionbuffer.toString();
- }
-
- @Override
- public void endSubscription() throws NetconfException {
- if (subscriptionConnected) {
- streamHandler.setEnableNotifications(false);
- } else {
- throw new NetconfException("Subscription does not exist.");
- }
- }
-
- private void sendHello() throws NetconfException {
- serverCapabilities = sendRequest(createHelloString());
- }
-
- private String createHelloString() {
- StringBuilder hellobuffer = new StringBuilder();
- hellobuffer.append(XML_HEADER);
- hellobuffer.append("\n");
- hellobuffer.append("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
- hellobuffer.append(" <capabilities>\n");
- deviceCapabilities.forEach(
- cap -> hellobuffer.append(" <capability>")
- .append(cap)
- .append("</capability>\n"));
- hellobuffer.append(" </capabilities>\n");
- hellobuffer.append("</hello>\n");
- hellobuffer.append(ENDPATTERN);
- return hellobuffer.toString();
-
- }
-
- @Override
- public void checkAndReestablish() throws NetconfException {
- if (sshSession.getState() != Channel.STATE_OPEN) {
- try {
- log.debug("Trying to reopen the Sesion with {}", deviceInfo.getDeviceId());
- startSshSession();
- } catch (IOException | IllegalStateException e) {
- log.debug("Trying to reopen the Connection with {}", deviceInfo.getDeviceId());
- try {
- connectionActive = false;
- replies.clear();
- messageIdInteger.set(0);
- startConnection();
- if (subscriptionConnected) {
- log.debug("Restarting subscription with {}", deviceInfo.getDeviceId());
- subscriptionConnected = false;
- startSubscription(notificationFilterSchema);
- }
- } catch (IOException e2) {
- log.error("No connection {} for device {}", netconfConnection, e.getMessage());
- throw new NetconfException("Cannot re-open the connection with device" + deviceInfo, e);
- }
- }
- }
- }
-
- @Override
- public String requestSync(String request) throws NetconfException {
- if (!request.contains(ENDPATTERN)) {
- request = request + NEW_LINE + ENDPATTERN;
- }
- String reply = sendRequest(request);
- checkReply(reply);
- return reply;
- }
-
- @Override
- @Deprecated
- public CompletableFuture<String> request(String request) {
- return streamHandler.sendMessage(request);
- }
-
- private CompletableFuture<String> request(String request, int messageId) {
- return streamHandler.sendMessage(request, messageId);
- }
-
- private String sendRequest(String request) throws NetconfException {
- checkAndReestablish();
- final int messageId = messageIdInteger.getAndIncrement();
- request = formatRequestMessageId(request, messageId);
- request = formatXmlHeader(request);
- CompletableFuture<String> futureReply = request(request, messageId);
- String rp;
- try {
- rp = futureReply.get(replyTimeout, TimeUnit.SECONDS);
- replies.remove(messageId);
- } catch (InterruptedException | ExecutionException | TimeoutException e) {
- throw new NetconfException("No matching reply for request " + request, e);
- }
- log.debug("Result {} from request {} to device {}", rp, request, deviceInfo);
- return rp.trim();
- }
-
- private String formatRequestMessageId(String request, int messageId) {
- if (request.contains(MESSAGE_ID_STRING)) {
- //FIXME if application provides his own counting of messages this fails that count
- request = request.replaceFirst(MESSAGE_ID_STRING + EQUAL + NUMBER_BETWEEN_QUOTES_MATCHER,
- MESSAGE_ID_STRING + EQUAL + "\"" + messageId + "\"");
- } else if (!request.contains(MESSAGE_ID_STRING) && !request.contains(HELLO)) {
- //FIXME find out a better way to enforce the presence of message-id
- request = request.replaceFirst(END_OF_RPC_OPEN_TAG, "\" " + MESSAGE_ID_STRING + EQUAL + "\""
- + messageId + "\"" + ">");
- }
- return request;
- }
-
- private String formatXmlHeader(String request) {
- if (!request.contains(XML_HEADER)) {
- //FIXME if application provieds his own XML header of different type there is a clash
- request = XML_HEADER + "\n" + request;
- }
- return request;
- }
-
- @Override
- public String doWrappedRpc(String request) throws NetconfException {
- StringBuilder rpc = new StringBuilder(XML_HEADER);
- rpc.append(RPC_OPEN);
- rpc.append(MESSAGE_ID_STRING);
- rpc.append(EQUAL);
- rpc.append("\"");
- rpc.append(messageIdInteger.get());
- rpc.append("\" ");
- rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
- rpc.append(request);
- rpc.append(RPC_CLOSE).append(NEW_LINE);
- rpc.append(ENDPATTERN);
- String reply = sendRequest(rpc.toString());
- checkReply(reply);
- return reply;
- }
-
- @Override
- public String get(String request) throws NetconfException {
- return requestSync(request);
- }
-
- @Override
- public String get(String filterSchema, String withDefaultsMode) throws NetconfException {
- StringBuilder rpc = new StringBuilder(XML_HEADER);
- rpc.append(RPC_OPEN);
- rpc.append(MESSAGE_ID_STRING);
- rpc.append(EQUAL);
- rpc.append("\"");
- rpc.append(messageIdInteger.get());
- rpc.append("\" ");
- rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
- rpc.append(GET_OPEN).append(NEW_LINE);
- if (filterSchema != null) {
- rpc.append(SUBTREE_FILTER_OPEN).append(NEW_LINE);
- rpc.append(filterSchema).append(NEW_LINE);
- rpc.append(SUBTREE_FILTER_CLOSE).append(NEW_LINE);
- }
- if (withDefaultsMode != null) {
- rpc.append(WITH_DEFAULT_OPEN).append(NETCONF_WITH_DEFAULTS_NAMESPACE).append(">");
- rpc.append(withDefaultsMode).append(WITH_DEFAULT_CLOSE).append(NEW_LINE);
- }
- rpc.append(GET_CLOSE).append(NEW_LINE);
- rpc.append(RPC_CLOSE).append(NEW_LINE);
- rpc.append(ENDPATTERN);
- String reply = sendRequest(rpc.toString());
- checkReply(reply);
- return reply;
- }
-
- @Override
- public String getConfig(TargetConfig netconfTargetConfig) throws NetconfException {
- return getConfig(netconfTargetConfig, null);
- }
-
- @Override
- public String getConfig(String netconfTargetConfig) throws NetconfException {
- return getConfig(TargetConfig.toTargetConfig(netconfTargetConfig));
- }
-
- @Override
- public String getConfig(String netconfTargetConfig, String configurationFilterSchema) throws NetconfException {
- return getConfig(TargetConfig.toTargetConfig(netconfTargetConfig), configurationFilterSchema);
- }
-
- @Override
- public String getConfig(TargetConfig netconfTargetConfig, String configurationSchema) throws NetconfException {
- StringBuilder rpc = new StringBuilder(XML_HEADER);
- rpc.append("<rpc ");
- rpc.append(MESSAGE_ID_STRING);
- rpc.append(EQUAL);
- rpc.append("\"");
- rpc.append(messageIdInteger.get());
- rpc.append("\" ");
- rpc.append("xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
- rpc.append("<get-config>\n");
- rpc.append("<source>\n");
- rpc.append("<").append(netconfTargetConfig).append("/>");
- rpc.append("</source>");
- if (configurationSchema != null) {
- rpc.append("<filter type=\"subtree\">\n");
- rpc.append(configurationSchema).append("\n");
- rpc.append("</filter>\n");
- }
- rpc.append("</get-config>\n");
- rpc.append("</rpc>\n");
- rpc.append(ENDPATTERN);
- String reply = sendRequest(rpc.toString());
- return checkReply(reply) ? reply : "ERROR " + reply;
- }
-
- @Override
- public boolean editConfig(String newConfiguration) throws NetconfException {
- newConfiguration = newConfiguration + ENDPATTERN;
- return checkReply(sendRequest(newConfiguration));
- }
-
- @Override
- public boolean editConfig(String netconfTargetConfig, String mode, String newConfiguration)
- throws NetconfException {
- return editConfig(TargetConfig.toTargetConfig(netconfTargetConfig), mode, newConfiguration);
- }
-
- @Override
- public boolean editConfig(TargetConfig netconfTargetConfig, String mode, String newConfiguration)
- throws NetconfException {
- newConfiguration = newConfiguration.trim();
- StringBuilder rpc = new StringBuilder(XML_HEADER);
- rpc.append(RPC_OPEN);
- rpc.append(MESSAGE_ID_STRING);
- rpc.append(EQUAL);
- rpc.append("\"");
- rpc.append(messageIdInteger.get());
- rpc.append("\" ");
- rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
- rpc.append(EDIT_CONFIG_OPEN).append("\n");
- rpc.append(TARGET_OPEN);
- rpc.append("<").append(netconfTargetConfig).append("/>");
- rpc.append(TARGET_CLOSE).append("\n");
- if (mode != null) {
- rpc.append(DEFAULT_OPERATION_OPEN);
- rpc.append(mode);
- rpc.append(DEFAULT_OPERATION_CLOSE).append("\n");
- }
- rpc.append(CONFIG_OPEN).append("\n");
- rpc.append(newConfiguration);
- rpc.append(CONFIG_CLOSE).append("\n");
- rpc.append(EDIT_CONFIG_CLOSE).append("\n");
- rpc.append(RPC_CLOSE);
- rpc.append(ENDPATTERN);
- log.debug(rpc.toString());
- String reply = sendRequest(rpc.toString());
- return checkReply(reply);
- }
-
- @Override
- public boolean copyConfig(String netconfTargetConfig, String newConfiguration) throws NetconfException {
- return copyConfig(TargetConfig.toTargetConfig(netconfTargetConfig), newConfiguration);
- }
-
- @Override
- public boolean copyConfig(TargetConfig netconfTargetConfig, String newConfiguration)
- throws NetconfException {
- newConfiguration = newConfiguration.trim();
- if (!newConfiguration.startsWith("<config>")) {
- newConfiguration = "<config>" + newConfiguration
- + "</config>";
- }
- StringBuilder rpc = new StringBuilder(XML_HEADER);
- rpc.append(RPC_OPEN);
- rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
- rpc.append("<copy-config>");
- rpc.append("<target>");
- rpc.append("<").append(netconfTargetConfig).append("/>");
- rpc.append("</target>");
- rpc.append("<source>");
- rpc.append(newConfiguration);
- rpc.append("</source>");
- rpc.append("</copy-config>");
- rpc.append("</rpc>");
- rpc.append(ENDPATTERN);
- return checkReply(sendRequest(rpc.toString()));
- }
-
- @Override
- public boolean deleteConfig(String netconfTargetConfig) throws NetconfException {
- return deleteConfig(TargetConfig.toTargetConfig(netconfTargetConfig));
- }
-
- @Override
- public boolean deleteConfig(TargetConfig netconfTargetConfig) throws NetconfException {
- if (netconfTargetConfig.equals(TargetConfig.RUNNING)) {
- log.warn("Target configuration for delete operation can't be \"running\"",
- netconfTargetConfig);
- return false;
- }
- StringBuilder rpc = new StringBuilder(XML_HEADER);
- rpc.append("<rpc>");
- rpc.append("<delete-config>");
- rpc.append("<target>");
- rpc.append("<").append(netconfTargetConfig).append("/>");
- rpc.append("</target>");
- rpc.append("</delete-config>");
- rpc.append("</rpc>");
- rpc.append(ENDPATTERN);
- return checkReply(sendRequest(rpc.toString()));
- }
-
- @Override
- public boolean lock(String configType) throws NetconfException {
- StringBuilder rpc = new StringBuilder(XML_HEADER);
- rpc.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
- rpc.append("<lock>");
- rpc.append("<target>");
- rpc.append("<");
- rpc.append(configType);
- rpc.append("/>");
- rpc.append("</target>");
- rpc.append("</lock>");
- rpc.append("</rpc>");
- rpc.append(ENDPATTERN);
- String lockReply = sendRequest(rpc.toString());
- return checkReply(lockReply);
- }
-
- @Override
- public boolean unlock(String configType) throws NetconfException {
- StringBuilder rpc = new StringBuilder(XML_HEADER);
- rpc.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
- rpc.append("<unlock>");
- rpc.append("<target>");
- rpc.append("<");
- rpc.append(configType);
- rpc.append("/>");
- rpc.append("</target>");
- rpc.append("</unlock>");
- rpc.append("</rpc>");
- rpc.append(ENDPATTERN);
- String unlockReply = sendRequest(rpc.toString());
- return checkReply(unlockReply);
- }
-
- @Override
- public boolean lock() throws NetconfException {
- return lock("running");
- }
-
- @Override
- public boolean unlock() throws NetconfException {
- return unlock("running");
- }
-
- @Override
- public boolean close() throws NetconfException {
- return close(false);
- }
-
- private boolean close(boolean force) throws NetconfException {
- StringBuilder rpc = new StringBuilder();
- rpc.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">");
- if (force) {
- rpc.append("<kill-session/>");
- } else {
- rpc.append("<close-session/>");
- }
- rpc.append("</rpc>");
- rpc.append(ENDPATTERN);
- return checkReply(sendRequest(rpc.toString())) || close(true);
- }
-
- @Override
- public String getSessionId() {
- if (serverCapabilities.contains("<session-id>")) {
- String[] outer = serverCapabilities.split("<session-id>");
- Preconditions.checkArgument(outer.length != 1,
- "Error in retrieving the session id");
- String[] value = outer[1].split("</session-id>");
- Preconditions.checkArgument(value.length != 1,
- "Error in retrieving the session id");
- return value[0];
- } else {
- return String.valueOf(-1);
- }
- }
-
- @Override
- public String getServerCapabilities() {
- return serverCapabilities;
- }
-
- @Override
- public void setDeviceCapabilities(List<String> capabilities) {
- deviceCapabilities = capabilities;
- }
-
- @Override
- public int timeoutConnectSec() {
- return connectTimeout;
- }
-
- @Override
- public int timeoutReplySec() {
- return replyTimeout;
- }
-
- /**
- * Idle timeout is not settable on ETZ_SSH - the valuse used is the connect timeout.
- */
- @Override
- public int timeoutIdleSec() {
- return connectTimeout;
- }
-
- @Override
- public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
- streamHandler.addDeviceEventListener(listener);
- }
-
- @Override
- public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
- streamHandler.removeDeviceEventListener(listener);
- }
-
- private boolean checkReply(String reply) throws NetconfException {
- if (reply != null) {
- if (!reply.contains("<rpc-error>")) {
- log.debug("Device {} sent reply {}", deviceInfo, reply);
- return true;
- } else if (reply.contains("<ok/>")
- || (reply.contains("<rpc-error>")
- && reply.contains("warning"))) {
- log.debug("Device {} sent reply {}", deviceInfo, reply);
- return true;
- }
- }
- log.warn("Device {} has error in reply {}", deviceInfo, reply);
- return false;
- }
-
- public class NetconfSessionDelegateImpl implements NetconfSessionDelegate {
-
- @Override
- public void notify(NetconfDeviceOutputEvent event) {
- Optional<Integer> messageId = event.getMessageID();
- log.debug("messageID {}, waiting replies messageIDs {}", messageId,
- replies.keySet());
- if (!messageId.isPresent()) {
- errorReplies.add(event.getMessagePayload());
- log.error("Device {} sent error reply {}",
- event.getDeviceInfo(), event.getMessagePayload());
- return;
- }
- CompletableFuture<String> completedReply =
- replies.get(messageId.get());
- if (completedReply != null) {
- completedReply.complete(event.getMessagePayload());
- }
- }
- }
-}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamHandler.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamHandler.java
deleted file mode 100644
index a0bdd90..0000000
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamHandler.java
+++ /dev/null
@@ -1,75 +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.netconf.ctl;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.netconf.NetconfDeviceOutputEventListener;
-
-import java.util.concurrent.CompletableFuture;
-
-/**
- * Interface to represent an objects that does all the IO on a NETCONF session
- * with a device.
- *
- * @deprecated in 1.10.0
- */
-@Deprecated
-public interface NetconfStreamHandler {
- /**
- * Sends the request on the stream that is used to communicate to and from the device.
- *
- * If this request does not contain a messageId then this will throw a NoSuchElementException
- *
- * @param request request to send to the physical device
- * @return a CompletableFuture of type String that will contain the response for the request.
- * @deprecated - use method with messageId parameter instead
- */
- @Deprecated
- CompletableFuture<String> sendMessage(String request);
-
- /**
- * Sends the request on the stream that is used to communicate to and from the device.
- *
- * @param request request to send to the physical device
- * @param messageId The identifier of the message - should be unique for the session
- * @return a CompletableFuture of type String that will contain the response for the request.
- */
- CompletableFuture<String> sendMessage(String request, int messageId);
-
- /**
- * Adds a listener for netconf events on the handled stream.
- *
- * @param listener Netconf device event listener
- */
- void addDeviceEventListener(NetconfDeviceOutputEventListener listener);
-
- /**
- * Removes a listener for netconf events on the handled stream.
- *
- * @param listener Netconf device event listener
- */
- void removeDeviceEventListener(NetconfDeviceOutputEventListener listener);
-
- @Beta
- /**
- * Sets instance variable that when true allows receipt of notifications.
- *
- * @param enableNotifications if true, allows action based off notifications
- * else, stops action based off notifications
- */
- void setEnableNotifications(boolean enableNotifications);
-}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java
deleted file mode 100644
index 4bb15c4..0000000
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfStreamThread.java
+++ /dev/null
@@ -1,283 +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.netconf.ctl;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import org.onosproject.netconf.NetconfDeviceInfo;
-import org.onosproject.netconf.NetconfDeviceOutputEvent;
-import org.onosproject.netconf.NetconfDeviceOutputEventListener;
-import org.onosproject.netconf.NetconfException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.CompletableFuture;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Thread that gets spawned each time a session is established and handles all the input
- * and output from the session's streams to and from the NETCONF device the session is
- * established with.
- *
- * @deprecated in 1.10.0
- */
-@Deprecated
-public class NetconfStreamThread extends Thread implements NetconfStreamHandler {
-
- private static final Logger log = LoggerFactory
- .getLogger(NetconfStreamThread.class);
- private static final String HELLO = "<hello";
- private static final String END_PATTERN = "]]>]]>";
- private static final String RPC_REPLY = "rpc-reply";
- private static final String RPC_ERROR = "rpc-error";
- private static final String NOTIFICATION_LABEL = "<notification";
- private static final String MESSAGE_ID = "message-id=";
- private static final Pattern MSGID_PATTERN = Pattern.compile(MESSAGE_ID + "\"(\\d+)\"");
-
- private PrintWriter outputStream;
- private final InputStream err;
- private final InputStream in;
- private NetconfDeviceInfo netconfDeviceInfo;
- private NetconfSessionDelegate sessionDelegate;
- private NetconfMessageState state;
- private List<NetconfDeviceOutputEventListener> netconfDeviceEventListeners
- = Lists.newCopyOnWriteArrayList();
- private boolean enableNotifications = true;
- private Map<Integer, CompletableFuture<String>> replies;
-
- public NetconfStreamThread(final InputStream in, final OutputStream out,
- final InputStream err, NetconfDeviceInfo deviceInfo,
- NetconfSessionDelegate delegate,
- Map<Integer, CompletableFuture<String>> replies) {
- this.in = in;
- this.err = err;
- outputStream = new PrintWriter(out);
- netconfDeviceInfo = deviceInfo;
- state = NetconfMessageState.NO_MATCHING_PATTERN;
- sessionDelegate = delegate;
- this.replies = replies;
- log.debug("Stream thread for device {} session started", deviceInfo);
- start();
- }
-
- @Override
- public CompletableFuture<String> sendMessage(String request) {
- Optional<Integer> messageId = getMsgId(request);
- return sendMessage(request, messageId.get());
- }
-
- @Override
- public CompletableFuture<String> sendMessage(String request, int messageId) {
- log.debug("Sending message {} to device {}", request, netconfDeviceInfo);
- CompletableFuture<String> cf = new CompletableFuture<>();
- replies.put(messageId, cf);
-
- synchronized (outputStream) {
- outputStream.print(request);
- outputStream.flush();
- }
-
- return cf;
- }
-
- public enum NetconfMessageState {
-
- NO_MATCHING_PATTERN {
- @Override
- NetconfMessageState evaluateChar(char c) {
- if (c == ']') {
- return FIRST_BRACKET;
- } else {
- return this;
- }
- }
- },
- FIRST_BRACKET {
- @Override
- NetconfMessageState evaluateChar(char c) {
- if (c == ']') {
- return SECOND_BRACKET;
- } else {
- return NO_MATCHING_PATTERN;
- }
- }
- },
- SECOND_BRACKET {
- @Override
- NetconfMessageState evaluateChar(char c) {
- if (c == '>') {
- return FIRST_BIGGER;
- } else {
- return NO_MATCHING_PATTERN;
- }
- }
- },
- FIRST_BIGGER {
- @Override
- NetconfMessageState evaluateChar(char c) {
- if (c == ']') {
- return THIRD_BRACKET;
- } else {
- return NO_MATCHING_PATTERN;
- }
- }
- },
- THIRD_BRACKET {
- @Override
- NetconfMessageState evaluateChar(char c) {
- if (c == ']') {
- return ENDING_BIGGER;
- } else {
- return NO_MATCHING_PATTERN;
- }
- }
- },
- ENDING_BIGGER {
- @Override
- NetconfMessageState evaluateChar(char c) {
- if (c == '>') {
- return END_PATTERN;
- } else {
- return NO_MATCHING_PATTERN;
- }
- }
- },
- END_PATTERN {
- @Override
- NetconfMessageState evaluateChar(char c) {
- return NO_MATCHING_PATTERN;
- }
- };
-
- abstract NetconfMessageState evaluateChar(char c);
- }
-
- @Override
- public void run() {
- BufferedReader bufferReader = new BufferedReader(new InputStreamReader(in));
- try {
- boolean socketClosed = false;
- StringBuilder deviceReplyBuilder = new StringBuilder();
- while (!socketClosed) {
- int cInt = bufferReader.read();
- if (cInt == -1) {
- log.debug("Netconf device {} sent error char in session," +
- " will need to be reopend", netconfDeviceInfo);
- NetconfDeviceOutputEvent event = new NetconfDeviceOutputEvent(
- NetconfDeviceOutputEvent.Type.SESSION_CLOSED,
- null, null, Optional.of(-1), netconfDeviceInfo);
- netconfDeviceEventListeners.forEach(
- listener -> listener.event(event));
- socketClosed = true;
- log.debug("Netconf device {} ERROR cInt == -1 socketClosed = true", netconfDeviceInfo);
- }
- char c = (char) cInt;
- state = state.evaluateChar(c);
- deviceReplyBuilder.append(c);
- if (state == NetconfMessageState.END_PATTERN) {
- String deviceReply = deviceReplyBuilder.toString();
- if (deviceReply.equals(END_PATTERN)) {
- socketClosed = true;
- log.debug("Netconf device {} socketClosed = true DEVICE_UNREGISTERED {}",
- netconfDeviceInfo, deviceReply);
- NetconfDeviceOutputEvent event = new NetconfDeviceOutputEvent(
- NetconfDeviceOutputEvent.Type.DEVICE_UNREGISTERED,
- null, null, Optional.of(-1), netconfDeviceInfo);
- netconfDeviceEventListeners.forEach(
- listener -> listener.event(event));
- this.interrupt();
- } else {
- deviceReply = deviceReply.replace(END_PATTERN, "");
- if (deviceReply.contains(RPC_REPLY) ||
- deviceReply.contains(RPC_ERROR) ||
- deviceReply.contains(HELLO)) {
- log.debug("Netconf device {} sessionDelegate.notify() DEVICE_REPLY {} {}",
- netconfDeviceInfo, getMsgId(deviceReply), deviceReply);
- NetconfDeviceOutputEvent event = new NetconfDeviceOutputEvent(
- NetconfDeviceOutputEvent.Type.DEVICE_REPLY,
- null, deviceReply, getMsgId(deviceReply), netconfDeviceInfo);
- sessionDelegate.notify(event);
- netconfDeviceEventListeners.forEach(
- listener -> listener.event(event));
- } else if (deviceReply.contains(NOTIFICATION_LABEL)) {
- log.debug("Netconf device {} DEVICE_NOTIFICATION {} {} {}",
- netconfDeviceInfo, enableNotifications,
- getMsgId(deviceReply), deviceReply);
- if (enableNotifications) {
- log.debug("dispatching to {} listeners", netconfDeviceEventListeners.size());
- final String finalDeviceReply = deviceReply;
- netconfDeviceEventListeners.forEach(
- listener -> listener.event(new NetconfDeviceOutputEvent(
- NetconfDeviceOutputEvent.Type.DEVICE_NOTIFICATION,
- null, finalDeviceReply, getMsgId(finalDeviceReply),
- netconfDeviceInfo)));
- }
- } else {
- log.debug("Error on reply from device {} {}", netconfDeviceInfo, deviceReply);
- }
- deviceReplyBuilder.setLength(0);
- }
- }
- }
- } catch (IOException e) {
- log.warn("Error in reading from the session for device {} ", netconfDeviceInfo, e);
- throw new RuntimeException(new NetconfException("Error in reading from the session for device {}" +
- netconfDeviceInfo, e));
- //TODO should we send a socket closed message to listeners ?
- }
- }
-
- protected static Optional<Integer> getMsgId(String reply) {
- Matcher matcher = MSGID_PATTERN.matcher(reply);
- if (matcher.find()) {
- Integer messageId = Integer.parseInt(matcher.group(1));
- Preconditions.checkNotNull(messageId, "Error in retrieving the message id");
- return Optional.of(messageId);
- }
- if (reply.contains(HELLO)) {
- return Optional.of(0);
- }
- return Optional.empty();
- }
-
- @Override
- public void addDeviceEventListener(NetconfDeviceOutputEventListener listener) {
- if (!netconfDeviceEventListeners.contains(listener)) {
- netconfDeviceEventListeners.add(listener);
- }
- }
-
- @Override
- public void removeDeviceEventListener(NetconfDeviceOutputEventListener listener) {
- netconfDeviceEventListeners.remove(listener);
- }
-
- @Override
- public void setEnableNotifications(boolean enableNotifications) {
- this.enableNotifications = enableNotifications;
- }
-}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
index daba5be..a1797d7 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
@@ -24,6 +24,7 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.onlab.packet.IpAddress;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.net.AnnotationKeys;
@@ -49,6 +50,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.security.Security;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.Map;
@@ -128,6 +130,7 @@
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
modified(context);
+ Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
log.info("Started");
}
@@ -140,6 +143,7 @@
cfgService.unregisterProperties(getClass(), false);
netconfDeviceListeners.clear();
netconfDeviceMap.clear();
+ Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
log.info("Stopped");
}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
index 28c3358..48727a2 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionImpl.java
@@ -781,18 +781,6 @@
return Collections.unmodifiableSet(deviceCapabilities);
}
- @Deprecated
- @Override
- public String getServerCapabilities() {
- return serverHelloResponseOld;
- }
-
- @Deprecated
- @Override
- public void setDeviceCapabilities(List<String> capabilities) {
- onosCapabilities = capabilities;
- }
-
@Override
public void setOnosCapabilities(Iterable<String> capabilities) {
onosCapabilities = capabilities;
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
index abdd377..241ea23 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
@@ -28,6 +28,10 @@
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.openssl.PEMParser;
+import org.bouncycastle.openssl.PEMKeyPair;
+import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.onosproject.netconf.DatastoreId;
import org.onosproject.netconf.NetconfDeviceInfo;
import org.onosproject.netconf.NetconfDeviceOutputEvent;
@@ -39,12 +43,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import static java.nio.charset.StandardCharsets.UTF_8;
+import java.io.CharArrayReader;
import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
@@ -208,23 +211,15 @@
session = connectFuture.getSession();
//Using the device ssh key if possible
if (deviceInfo.getKey() != null) {
- ByteBuffer buf = StandardCharsets.UTF_8.encode(CharBuffer.wrap(deviceInfo.getKey()));
- byte[] byteKey = new byte[buf.limit()];
- buf.get(byteKey);
- PublicKey key;
+ PEMParser pemParser = new PEMParser(new CharArrayReader(deviceInfo.getKey()));
+ JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME);
try {
- key = getPublicKey(byteKey, RSA);
- } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
- try {
- key = getPublicKey(byteKey, DSA);
- } catch (NoSuchAlgorithmException | InvalidKeySpecException e1) {
- throw new NetconfException("Failed to authenticate session with device " +
- deviceInfo + "check key to be the " +
- "proper DSA or RSA key", e1);
- }
+ KeyPair kp = converter.getKeyPair((PEMKeyPair) pemParser.readObject());
+ session.addPublicKeyIdentity(kp);
+ } catch (java.io.IOException e) {
+ throw new NetconfException("Failed to authenticate session with device " +
+ deviceInfo + "check key to be a valid key", e);
}
- //privateKye can set tu null because is not used by the method.
- session.addPublicKeyIdentity(new KeyPair(key, null));
} else {
session.addPasswordIdentity(deviceInfo.password());
}
@@ -846,18 +841,6 @@
return Collections.unmodifiableSet(deviceCapabilities);
}
- @Deprecated
- @Override
- public String getServerCapabilities() {
- return serverHelloResponseOld;
- }
-
- @Deprecated
- @Override
- public void setDeviceCapabilities(List<String> capabilities) {
- onosCapabilities = capabilities;
- }
-
@Override
public void setOnosCapabilities(Iterable<String> capabilities) {
onosCapabilities = capabilities;
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java
deleted file mode 100644
index bcd68a8..0000000
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java
+++ /dev/null
@@ -1,21 +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.
- */
-
-/**
- * NETCONF controller implementations.
- */
-@java.lang.Deprecated
-package org.onosproject.netconf.ctl;
diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImplTest.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImplTest.java
index 8fd4a86..7e78b80 100644
--- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImplTest.java
+++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImplTest.java
@@ -195,7 +195,7 @@
assertNotNull("Incorrect sessionId", session1.getSessionId());
try {
assertTrue("NETCONF edit-config command failed",
- session1.editConfig(RUNNING.toString(),
+ session1.editConfig(RUNNING,
null, SAMPLE_REQUEST));
} catch (NetconfException e) {
e.printStackTrace();
@@ -211,7 +211,7 @@
assertNotNull("Incorrect sessionId", session3.getSessionId());
try {
assertTrue("NETCONF edit-config command failed",
- session3.editConfig(RUNNING.toString(),
+ session3.editConfig(RUNNING,
null, SAMPLE_REQUEST));
} catch (NetconfException e) {
e.printStackTrace();