Unsupport operation exception in NeutronvpnManager.java 24/85924/7
authorNing Zhang <zhangninglc@inspur.com>
Mon, 25 Nov 2019 07:31:43 +0000 (15:31 +0800)
committerAbhinav Gupta <abhinav.gupta@ericsson.com>
Tue, 26 Nov 2019 08:54:25 +0000 (08:54 +0000)
1.Unsupported operation exception handling;
2.Do not use the toString() when printing logs;

Change-Id: Ifb1512a7aaa2b68595d56ee5b41b26ac3edc4a8d
Signed-off-by: Ning Zhang <zhangninglc@inspur.com>
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java
neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnManager.java

index 92c8a9bd2147a6c7ecca7fca7d4c5ae3d629d55d..d7680f34132aa255e16dc28569d83c053a2296c4 100644 (file)
@@ -680,10 +680,8 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
                     LOG.debug("handleNeutronPortCreated: Adding VPN Interface for port {} from network {}", portName,
                             networkId);
                     nvpnManager.createVpnInterface(vpnIdList, port, tx);
-                    if (!routerIds.isEmpty()) {
-                        for (Uuid routerId : routerIds) {
-                            nvpnManager.addToNeutronRouterInterfacesMap(routerId,port.getUuid().getValue());
-                        }
+                    for (Uuid routerId : routerIds) {
+                        nvpnManager.addToNeutronRouterInterfacesMap(routerId,port.getUuid().getValue());
                     }
                 }
             });
index 3712b5f87c5fe4f0a524a49fb13e5121e510f5b7..b8894033186a89c5b98c4b5f58cb89995195c55b 100644 (file)
@@ -274,7 +274,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             final ReentrantLock lock = lockForUuid(subnetId);
             lock.lock();
             try {
-                LOG.info("createSubnetmapNode: subnet ID {}", subnetId.toString());
+                LOG.info("createSubnetmapNode: subnet ID {}", subnetId.getValue());
                 Optional<Subnetmap> sn = SingleTransactionDataBroker.syncReadOptional(dataBroker,
                         LogicalDatastoreType.CONFIGURATION, subnetMapIdentifier);
                 if (sn.isPresent()) {
@@ -354,11 +354,11 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             Optional<Subnetmap> sn =
                     SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
             if (!sn.isPresent()) {
-                LOG.error("WithRouterFixedIP: subnetmap node for subnet {} does not exist, returning ",
+                LOG.error("updateSubnetNodeWithFixedIp: subnetmap node for subnet {} does not exist, returning ",
                     subnetId.getValue());
                 return;
             }
-            LOG.debug("WithRouterFixedIP: Updating existing subnetmap node for subnet ID {}",
+            LOG.debug("updateSubnetNodeWithFixedIp: Updating existing subnetmap node for subnet ID {}",
                 subnetId.getValue());
             SubnetmapBuilder builder = new SubnetmapBuilder(sn.get());
             builder.setRouterId(routerId);
@@ -373,7 +373,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 subnetId.getValue());
             SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, id, subnetmap);
         } catch (ReadFailedException | TransactionCommitFailedException e) {
-            LOG.error("WithRouterFixedIP: subnet map for Router FixedIp failed for node {}",
+            LOG.error("updateSubnetNodeWithFixedIp: subnet map for Router FixedIp failed for node {}",
                 subnetId.getValue(), e);
         } finally {
             lock.unlock();
@@ -385,7 +385,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         Subnetmap subnetmap = null;
         InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class,
                 new SubnetmapKey(subnetId)).build();
-        LOG.info("updateSubnetmapNodeWithPorts : subnetId {}, subnetMapId {}", subnetId.toString(), id.toString());
+        LOG.info("updateSubnetmapNodeWithPorts: Updating subnetMap with portList for subnetId {}", subnetId.getValue());
         final ReentrantLock lock = lockForUuid(subnetId);
         lock.lock();
         try {
@@ -406,9 +406,10 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                         subnetId.getValue(), portId.getValue());
                 }
                 if (null != directPortId) {
-                    List<Uuid> directPortList = builder.getDirectPortList();
-                    if (null == directPortList) {
-                        directPortList = new ArrayList<>();
+                    List<Uuid> existingDirectPortList = builder.getDirectPortList();
+                    List<Uuid> directPortList = new ArrayList<>();
+                    if (null != existingDirectPortList) {
+                        directPortList.addAll(existingDirectPortList);
                     }
                     directPortList.add(directPortId);
                     builder.setDirectPortList(directPortList);
@@ -1265,7 +1266,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             List<String> failStrings = associateNetworksToVpn(vpnId, networkList);
             if (!failStrings.isEmpty()) {
                 LOG.error("VPN {} association to networks failed for networks: {}. ",
-                        vpnId.getValue(), failStrings.toString());
+                        vpnId.getValue(), failStrings);
                 throw new Exception(failStrings.toString());
             }
         }
@@ -1390,8 +1391,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
             try {
                 LOG.debug("L3VPN add RPC: VpnID {}, name {}, tenantID {}, RDList {}, iRTList {}, eRTList{}, "
                                 + "routerIdList {}, networksList {}", vpn.getId().getValue(), vpn.getName(),
-                        vpn.getTenantId(), vpn.getRouteDistinguisher().toString(), vpn.getImportRT().toString(),
-                        vpn.getExportRT().toString(), rtrIdsList, vpn.getNetworkIds());
+                        vpn.getTenantId(), vpn.getRouteDistinguisher(), vpn.getImportRT(),
+                        vpn.getExportRT(), rtrIdsList, vpn.getNetworkIds());
 
                 List<String> rdList = vpn.getRouteDistinguisher() != null
                         ? new ArrayList<>(vpn.getRouteDistinguisher()) : new ArrayList<>();
@@ -1644,7 +1645,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 return;
             }
             final VpnInstance vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue());
-            LOG.debug("addSubnetToVpn: VpnInstance {}", vpnInstance.toString());
+            LOG.debug("addSubnetToVpn: VpnInstance {}", vpnInstance);
             if (isVpnOfTypeL2(vpnInstance)) {
                 neutronEvpnUtils.updateElanAndVpn(vpnInstance, sn.getNetworkId().getValue(),
                         NeutronEvpnUtils.Operation.ADD);
@@ -2538,7 +2539,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         if (!isExternalNetwork) {
             updateVpnMaps(vpnId, null, null, null, new ArrayList<>(passedNwList));
         }
-        LOG.info("Network(s) {} associated to L3VPN {} successfully", passedNwList.toString(), vpnId.getValue());
+        LOG.info("Network(s) {} associated to L3VPN {} successfully", passedNwList, vpnId.getValue());
         return failedNwList;
     }
 
@@ -2665,7 +2666,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         }
         clearFromVpnMaps(vpnId, null, new ArrayList<>(passedNwList));
         LOG.info("dissociateNetworksFromVpn: Network(s) {} disassociated from L3VPN {} successfully",
-                passedNwList.toString(), vpnId.getValue());
+                passedNwList, vpnId.getValue());
         return failedNwList;
     }
 
@@ -2733,7 +2734,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         try {
             if (neutronvpnUtils.getVpnMap(vpnId) != null) {
                 LOG.debug("associateNetworks RPC: VpnId {}, networkList {}", vpnId.getValue(),
-                        input.getNetworkId().toString());
+                        input.getNetworkId());
                 List<Uuid> netIds = input.getNetworkId();
                 if (netIds != null && !netIds.isEmpty()) {
                     List<String> failed = associateNetworksToVpn(vpnId, netIds);
@@ -2872,7 +2873,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
         try {
             if (neutronvpnUtils.getVpnMap(vpnId) != null) {
                 LOG.debug("dissociateNetworks RPC: VpnId {}, networkList {}", vpnId.getValue(),
-                        input.getNetworkId().toString());
+                        input.getNetworkId());
                 List<Uuid> netIds = input.getNetworkId();
                 if (netIds != null && !netIds.isEmpty()) {
                     List<String> failed = dissociateNetworksFromVpn(vpnId, netIds);