Refactoring ID creation for netconf and REST
Change-Id: I4165ad53e19c86d9d9b304d09e24dcfeec2b9ddf
diff --git a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
index 8331a12..46fa997 100644
--- a/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
+++ b/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
@@ -40,6 +40,7 @@
private IpAddress ipAddress;
private int port;
private File keyFile;
+ private DeviceId deviceId;
/**
@@ -143,13 +144,14 @@
* @return DeviceId
*/
public DeviceId getDeviceId() {
-
- try {
- return DeviceId.deviceId(new URI(this.toString()));
- } catch (URISyntaxException e) {
- log.debug("Unable to build deviceID for device {} ", this, e);
+ if (deviceId == null) {
+ try {
+ deviceId = DeviceId.deviceId(new URI("netconf", ipAddress.toString() + ":" + port, null));
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Unable to build deviceID for device " + toString(), e);
+ }
}
- return null;
+ return deviceId;
}
@Override