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.
This commit is contained in:
Likitha Shetty 2014-12-30 14:16:00 +05:30
parent 13bdc1cef4
commit 25a4f0dc53

View File

@ -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);
}
}
}