CLOUDSTACK-8136. [VMware] Create VM snapshot fails if a previous attempt to 
take the snapshot failed.
While looking for an ongoing VM snapshot task, check the task status to 
identify if the task is still running.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/25a4f0dc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/25a4f0dc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/25a4f0dc

Branch: refs/heads/vmware-disk-controllers
Commit: 25a4f0dc530951e87fe357313dc983cb75aa8972
Parents: 13bdc1c
Author: Likitha Shetty <likitha.she...@citrix.com>
Authored: Tue Dec 30 14:16:00 2014 +0530
Committer: Likitha Shetty <likitha.she...@citrix.com>
Committed: Tue Dec 30 14:19:48 2014 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/manager/VmwareStorageManagerImpl.java   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/25a4f0dc/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index 1981303..3aec7a4 100644
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -37,6 +37,7 @@ import com.vmware.vim25.HostDatastoreBrowserSearchResults;
 import com.vmware.vim25.HostDatastoreBrowserSearchSpec;
 import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.TaskInfo;
+import com.vmware.vim25.TaskInfoState;
 import com.vmware.vim25.VirtualDisk;
 
 import org.apache.cloudstack.storage.to.TemplateObjectTO;
@@ -1181,8 +1182,10 @@ public class VmwareStorageManagerImpl implements 
VmwareStorageManager {
                 TaskInfo info = 
(TaskInfo)(context.getVimClient().getDynamicProperty(taskMor, "info"));
 
                 if (info.getEntityName().equals(cmd.getVmName()) && 
info.getName().equalsIgnoreCase("CreateSnapshot_Task")) {
-                    s_logger.debug("There is already a VM snapshot task 
running, wait for it");
-                    context.getVimClient().waitForTask(taskMor);
+                    if (!(info.getState().equals(TaskInfoState.SUCCESS) || 
info.getState().equals(TaskInfoState.ERROR))) {
+                        s_logger.debug("There is already a VM snapshot task 
running, wait for it");
+                        context.getVimClient().waitForTask(taskMor);
+                    }
                 }
             }
 

Reply via email to