Github user pedro-martins commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/556#discussion_r51372149
  
    --- Diff: 
plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 ---
    @@ -1765,7 +1767,18 @@ protected StartAnswer execute(StartCommand cmd) {
     
                 // Since VM was successfully powered-on, if there was an 
existing VM in a different cluster that was unregistered, delete all the files 
associated with it.
                 if (existingVmName != null && existingVmFileLayout != null) {
    -                deleteUnregisteredVmFiles(existingVmFileLayout, dcMo, 
true);
    +                List<String> skipDatastores = new ArrayList<String>();
    +                List<String> vmDatastoreNames = new ArrayList<String>();
    +                for (DatastoreMO vmDatastore : vmMo.getAllDatastores()) {
    +                    vmDatastoreNames.add(vmDatastore.getName());
    +                }
    +                // Don't delete files that are in a datastore that is 
being used by the new VM as well (zone-wide datastore).
    +                for (DatastoreMO existingDatastore : existingDatastores) {
    +                    if 
(vmDatastoreNames.contains(existingDatastore.getName())) {
    +                        skipDatastores.add(existingDatastore.getName());
    +                    }
    +                }
    +                deleteUnregisteredVmFiles(existingVmFileLayout, dcMo, 
true, skipDatastores);
                 }
    --- End diff --
    
    Hi, likitha.
    Could you extract the code between lines 1770 - 1775 and 1776 - 1780 to 
methods with a little test case and Javadoc explaining what the methods do, the 
params that they use and what they return?
    
    Another thing, how about you replace the logic in 'if's at lines 2272, 2283 
and 2291 for a method with a little test case and a Javadoc, that receives 2 
params, (List<String> skipDatastores, String name ) and returns  skipDatastores 
== null || !skipDatastores.contains(name).
    
    Ty.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to