You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by li...@apache.org on 2013/12/17 07:43:25 UTC

git commit: updated refs/heads/master to 5594ea9

Updated Branches:
  refs/heads/master f919441c3 -> 5594ea990


CLOUDSTACK-5519. [VMWARE] Cancel vCenter tasks if the task invoked by CloudStack failes with timeout error

Conflicts:

	vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java


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

Branch: refs/heads/master
Commit: 5594ea990f5cf9086d4ef410eca69bd69dec2b0f
Parents: f919441
Author: Likitha Shetty <li...@citrix.com>
Authored: Mon Dec 16 20:08:32 2013 +0530
Committer: Likitha Shetty <li...@citrix.com>
Committed: Tue Dec 17 12:06:19 2013 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/util/VmwareClient.java    | 31 +++++++++++++-------
 1 file changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5594ea99/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
index 0a44a72..d7aaabc 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
@@ -28,6 +28,9 @@ import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLSession;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.log4j.Logger;
 
 import com.vmware.vim25.DynamicProperty;
 import com.vmware.vim25.InvalidCollectorVersionFaultMsg;
@@ -59,6 +62,7 @@ import com.vmware.vim25.VimService;
  *
  */
 public class VmwareClient {
+    private static final Logger s_logger = Logger.getLogger(VmwareClient.class);
 
     private static class TrustAllTrustManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
 
@@ -313,20 +317,25 @@ public class VmwareClient {
      * @throws RuntimeFaultFaultMsg
      * @throws InvalidPropertyFaultMsg
      */
-    public boolean waitForTask(ManagedObjectReference task) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {
+    public boolean waitForTask(ManagedObjectReference task) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg, Exception {
 
         boolean retVal = false;
 
-        // info has a property - state for state of the task
-        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)) {
-            retVal = true;
-        }
-        if (result[1] instanceof LocalizedMethodFault) {
-            throw new RuntimeException(((LocalizedMethodFault)result[1]).getLocalizedMessage());
+        try {
+            // info has a property - state for state of the task
+            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)) {
+                retVal = true;
+            }
+            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());
+            getService().cancelTask(task);
+            throw new RuntimeException("vCenter task failed due to " + we.getLocalizedMessage());
         }
         return retVal;
     }