Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions 31 vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.vmware.vim25.InvalidPropertyFaultMsg;
import com.vmware.vim25.LocalizedMethodFault;
import com.vmware.vim25.ManagedObjectReference;
import com.vmware.vim25.MethodFault;
import com.vmware.vim25.ObjectContent;
import com.vmware.vim25.ObjectSpec;
import com.vmware.vim25.ObjectUpdate;
Expand All @@ -30,9 +31,11 @@
import com.vmware.vim25.PropertyFilterSpec;
import com.vmware.vim25.PropertyFilterUpdate;
import com.vmware.vim25.PropertySpec;
import com.vmware.vim25.RequestCanceled;
import com.vmware.vim25.RuntimeFaultFaultMsg;
import com.vmware.vim25.SelectionSpec;
import com.vmware.vim25.ServiceContent;
import com.vmware.vim25.TaskInfo;
import com.vmware.vim25.TaskInfoState;
import com.vmware.vim25.TraversalSpec;
import com.vmware.vim25.UpdateSet;
Expand Down Expand Up @@ -334,10 +337,32 @@ public boolean waitForTask(ManagedObjectReference task) throws InvalidPropertyFa
if (result[1] instanceof LocalizedMethodFault) {
throw new RuntimeException(((LocalizedMethodFault) result[1]).getLocalizedMessage());
}
} catch(WebServiceException we) {
s_logger.debug("Cancelling vCenter task because task failed with " + we.getLocalizedMessage());
} catch (WebServiceException we) {
s_logger.warn("Session to vCenter failed with: " + we.getLocalizedMessage());
TaskInfo taskInfo = (TaskInfo) getDynamicProperty(task, "info");
if (!taskInfo.isCancelable()) {
s_logger.warn("vCenter task: " + taskInfo.getName() + "(" + taskInfo.getKey() + ")" + " will continue to run on vCenter because the task cannot be cancelled");
throw new RuntimeException(we.getLocalizedMessage());
}
s_logger.debug("Cancelling vCenter task: " + taskInfo.getName() + "(" + taskInfo.getKey() + ")");
getService().cancelTask(task);
throw new RuntimeException("vCenter task failed due to " + we.getLocalizedMessage());
// Since task cancellation is asynchronous, wait for the task to be cancelled
Object[] result = waitForValues(task, new String[] { "info.state", "info.error" }, new String[] { "state" }, new Object[][] { new Object[] {
TaskInfoState.SUCCESS, TaskInfoState.ERROR } });

if (result[0].equals(TaskInfoState.SUCCESS)) {
s_logger.warn("Failed to cancel vCenter task: " + taskInfo.getName() + "(" + taskInfo.getKey() + ")" + " and the task successfully completed");
retVal = true;
}
if (result[1] instanceof LocalizedMethodFault) {
MethodFault fault = ((LocalizedMethodFault) result[1]).getFault();
if (fault instanceof RequestCanceled) {
s_logger.debug("vCenter task " + taskInfo.getName() + "(" + taskInfo.getKey() + ")" + " was successfully cancelled");
throw new RuntimeException(we.getLocalizedMessage());
}
} else {
throw new RuntimeException(((LocalizedMethodFault) result[1]).getLocalizedMessage());
}
}
return retVal;
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.