rafaelweingartner commented on a change in pull request #2503: Support multiple 
volume access groups per compute cluster
URL: https://github.com/apache/cloudstack/pull/2503#discussion_r178158136
 
 

 ##########
 File path: 
plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageProcessor.java
 ##########
 @@ -2956,6 +3033,61 @@ public void handleTargets(boolean add, 
ModifyTargetsCommand.TargetTypeToRemove t
         }
     }
 
+    private String waitForDatastoreName(HostDatastoreSystemMO 
hostDatastoreSystemMO, String iqn) throws Exception {
+        long secondsToWait = 120;
+        long endWaitTime = System.currentTimeMillis() + secondsToWait * 1000;
+
+        do {
+            String datastoreName = getDatastoreName(hostDatastoreSystemMO, 
iqn);
+
+            if (datastoreName != null) {
+                return datastoreName;
+            }
+
+            Thread.sleep(5000);
+        }
+        while (System.currentTimeMillis() < endWaitTime);
+
+        throw new CloudRuntimeException("Could not find the datastore name");
+    }
+
+    private String getDatastoreName(HostDatastoreSystemMO 
hostDatastoreSystemMO, String iqn) throws Exception {
+        String datastoreName = "-" + iqn + "-0";
+
+        ManagedObjectReference morDs = 
hostDatastoreSystemMO.findDatastoreByName(datastoreName);
+
+        if (morDs != null) {
+            return datastoreName;
+        }
+
+        datastoreName = "_" + iqn + "_0";
+
+        morDs = hostDatastoreSystemMO.findDatastoreByName(datastoreName);
+
+        if (morDs != null) {
+            return datastoreName;
+        }
+
+        return null;
+    }
+
+    private void handleRemove(List<HostInternetScsiHbaStaticTarget> 
targetsToRemove, HostMO host, List<HostMO> hosts) {
+        try {
+            for (HostInternetScsiHbaStaticTarget target : targetsToRemove) {
+                String datastoreName = 
waitForDatastoreName(host.getHostDatastoreSystemMO(), target.getIScsiName());
+
+                unmountVmfsDatastore2(host.getContext(), host, datastoreName, 
hosts);
+            }
+
+            addRemoveInternetScsiTargetsToAllHosts(false, targetsToRemove, 
hosts);
+
+            rescanAllHosts(hosts, true, false);
+        }
+        catch (Exception ex) {
 
 Review comment:
   Sorry, I did not see that the methods you were using are throwing Exception.
   It is fine then. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to