Refactoring ID creation for netconf and REST

Change-Id: I4165ad53e19c86d9d9b304d09e24dcfeec2b9ddf
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
index 251a74b..0d83978 100644
--- 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
@@ -81,8 +81,7 @@
     @Override
     public NetconfDevice getNetconfDevice(IpAddress ip, int port) {
         for (DeviceId info : netconfDeviceMap.keySet()) {
-            if (IpAddress.valueOf(info.uri().getHost()).equals(ip) &&
-                    info.uri().getPort() == port) {
+            if (info.uri().getSchemeSpecificPart().equals(ip.toString() + ":" + port)) {
                 return netconfDeviceMap.get(info);
             }
         }
@@ -102,7 +101,7 @@
 
     @Override
     public void removeDevice(NetconfDeviceInfo deviceInfo) {
-        if (netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) {
+        if (!netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) {
             log.warn("Device {} is not present", deviceInfo);
         } else {
             stopDevice(deviceInfo);