GutoVeronezi commented on a change in pull request #4701:
URL: https://github.com/apache/cloudstack/pull/4701#discussion_r590622664



##########
File path: 
plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
##########
@@ -5732,16 +5733,24 @@ protected Answer execute(UnregisterNicCommand cmd) {
     }
 
     public void cleanupNetwork(HostMO hostMo, NetworkDetails netDetails) {
-        // we will no longer cleanup VLAN networks in order to support native 
VMware HA
-        /*
-         * assert(netDetails.getName() != null); try { synchronized(this) { 
NetworkMO networkMo = new
-         * NetworkMO(hostMo.getContext(), netDetails.getNetworkMor()); 
ManagedObjectReference[] vms =
-         * networkMo.getVMsOnNetwork(); if(vms == null || vms.length == 0) { 
if(s_logger.isInfoEnabled()) {
-         * s_logger.info("Cleanup network as it is currently not in use: " + 
netDetails.getName()); }
-         *
-         * hostMo.deletePortGroup(netDetails.getName()); } } } catch(Throwable 
e) {
-         * s_logger.warn("Unable to cleanup network due to exception, skip for 
next time"); }
-         */
+        if (!VmwareManager.s_vmwareCleanupPortGroups.value()){
+            return;
+        }
+        assert(netDetails.getName() != null);
+        try {
+            synchronized(this) {
+                NetworkMO networkMo = new NetworkMO(hostMo.getContext(), 
netDetails.getNetworkMor());
+                List<ManagedObjectReference> vms = networkMo.getVMsOnNetwork();
+                if(vms == null || vms.size() == 0) {

Review comment:
       Suggestion:
   Use `vms.isEmpty()` instead of `vms.size() == 0`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to