|
28 | 28 | import javax.net.ssl.SSLSession; |
29 | 29 | import javax.xml.ws.BindingProvider; |
30 | 30 | import javax.xml.ws.handler.MessageContext; |
| 31 | +import javax.xml.ws.WebServiceException; |
| 32 | + |
| 33 | +import org.apache.log4j.Logger; |
31 | 34 |
|
32 | 35 | import com.vmware.vim25.DynamicProperty; |
33 | 36 | import com.vmware.vim25.InvalidCollectorVersionFaultMsg; |
|
59 | 62 | * |
60 | 63 | */ |
61 | 64 | public class VmwareClient { |
| 65 | + private static final Logger s_logger = Logger.getLogger(VmwareClient.class); |
62 | 66 |
|
63 | 67 | private static class TrustAllTrustManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager { |
64 | 68 |
|
@@ -313,20 +317,25 @@ private List<ObjectContent> retrieveMoRefProperties(ManagedObjectReference mObj, |
313 | 317 | * @throws RuntimeFaultFaultMsg |
314 | 318 | * @throws InvalidPropertyFaultMsg |
315 | 319 | */ |
316 | | - public boolean waitForTask(ManagedObjectReference task) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg { |
| 320 | + public boolean waitForTask(ManagedObjectReference task) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg, Exception { |
317 | 321 |
|
318 | 322 | boolean retVal = false; |
319 | 323 |
|
320 | | - // info has a property - state for state of the task |
321 | | - Object[] result = |
322 | | - waitForValues(task, new String[] {"info.state", "info.error"}, new String[] {"state"}, new Object[][] {new Object[] {TaskInfoState.SUCCESS, |
323 | | - TaskInfoState.ERROR}}); |
324 | | - |
325 | | - if (result[0].equals(TaskInfoState.SUCCESS)) { |
326 | | - retVal = true; |
327 | | - } |
328 | | - if (result[1] instanceof LocalizedMethodFault) { |
329 | | - throw new RuntimeException(((LocalizedMethodFault)result[1]).getLocalizedMessage()); |
| 324 | + try { |
| 325 | + // info has a property - state for state of the task |
| 326 | + Object[] result = waitForValues(task, new String[] { "info.state", "info.error" }, new String[] { "state" }, new Object[][] { new Object[] { |
| 327 | + TaskInfoState.SUCCESS, TaskInfoState.ERROR } }); |
| 328 | + |
| 329 | + if (result[0].equals(TaskInfoState.SUCCESS)) { |
| 330 | + retVal = true; |
| 331 | + } |
| 332 | + if (result[1] instanceof LocalizedMethodFault) { |
| 333 | + throw new RuntimeException(((LocalizedMethodFault) result[1]).getLocalizedMessage()); |
| 334 | + } |
| 335 | + } catch(WebServiceException we) { |
| 336 | + s_logger.debug("Cancelling vCenter task because task failed with " + we.getLocalizedMessage()); |
| 337 | + getService().cancelTask(task); |
| 338 | + throw new RuntimeException("vCenter task failed due to " + we.getLocalizedMessage()); |
330 | 339 | } |
331 | 340 | return retVal; |
332 | 341 | } |
|
0 commit comments