public void onError(LocalizedMethodFault error) { RemoteException remoteException = new RemoteException(error.getLocalizedMessage()); set(remoteException.getMessage(), remoteException); } }
/** * Create an instance of {@link LocalizedMethodFault } * */ public LocalizedMethodFault createLocalizedMethodFault() { return new LocalizedMethodFault(); }
if(fault!=null) MethodFault mf = fault.getFault(); throw mf;
System.out.println(info.getError().getFault());
/** * Attempts to delete the VM from disk. * @throws RemoteException * @throws InterruptedException */ public void removeVm() throws RemoteException, InterruptedException { try { Task task = vm.destroy_Task(); String status = task.waitForTask(); if (!status.equals("success")) { String message = task.getTaskInfo().getError() .getLocalizedMessage(); throw new RemoteException("Failed: " + message); } } catch (NotFound e) { log.warn("VM not found before attempting to delete it", e); } }
System.out.println(info.getError().getFault());
protected boolean getTaskResultAfterDone(ConnectionResources connectionResources, ManagedObjectReference task) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg { WaitForValues waitForValues = new WaitForValues(connectionResources.getConnection()); Object[] result = waitForValues.wait(task, new String[]{VmParameter.INFO_STATE.getValue(), VmParameter.INFO_ERROR.getValue()}, new String[]{VmParameter.STATE.getValue()}, new Object[][]{new Object[]{TaskInfoState.SUCCESS, TaskInfoState.ERROR}}); if (result[1] instanceof LocalizedMethodFault) { throw new RuntimeException(((LocalizedMethodFault) result[1]).getLocalizedMessage()); } return result[0].equals(TaskInfoState.SUCCESS); } }
TaskInfo info = task.getTaskInfo(); log(WARNING, "vMotion of " + targetVMName + " to " + newHostName + " failed. Error details: " + info.getError().getFault()); return false;
private void handleTask(Task task) throws DestructionException, InterruptedException, RemoteException { task.waitForTask(); TaskInfo taskInfo = task.getTaskInfo(); if (TaskInfoState.error == taskInfo.getState()) { throw new DestructionException(taskInfo.getError().getLocalizedMessage()); } }
Log.getLogWriter().warning( "vMotion of " + targetVMName + " to " + newHostName + " failed. Error details: " + info.getError().getFault()); return false;
/** * Generate the log bundles for the specific hosts. After the task done, print all the URLs of the generated bundles. * @param si ServiceInstance object. * @param includeDefault Specifies if the bundle should include the default server. * @param hosts Lists hosts that are included. */ public void generateLogBundles(ServiceInstance si, boolean includeDefault, HostSystem[] hosts) throws Exception { DiagnosticManager diagMgr = si.getDiagnosticManager(); Task task = diagMgr.generateLogBundles_Task(includeDefault, hosts); String result = task.waitForTask(); if (Task.SUCCESS.equals(result)) { ArrayOfDiagnosticManagerBundleInfo bundleArray = (ArrayOfDiagnosticManagerBundleInfo) task.getTaskInfo().getResult(); DiagnosticManagerBundleInfo[] bundles = bundleArray.getDiagnosticManagerBundleInfo(); if (bundles != null) { System.out.println("============ Log URL ============"); for (DiagnosticManagerBundleInfo bundle : bundles) { System.out.println(bundle.getUrl()); } } else { System.out.println("No bundle generated."); } } else { throw new Exception("Generate log bundles failed: error: " + task.getTaskInfo().getError().getLocalizedMessage()); } }
if (lmf!=null) error = lmf.getLocalizedMessage();
if (lmf!=null) error = lmf.getLocalizedMessage();
public void attachNic(VirtualMachine vm, VirtualEthernetCard nic, Network network) throws RemoteException, InterruptedException { VirtualEthernetCardNetworkBackingInfo backing = (VirtualEthernetCardNetworkBackingInfo) nic.getBacking(); backing.setDeviceName(network.getName()); backing.setNetwork(network.getMOR()); nic.setBacking(backing); nic.getDeviceInfo().setSummary(network.getName()); VirtualDeviceConfigSpec nicSpec = new VirtualDeviceConfigSpec(); nicSpec.setOperation(VirtualDeviceConfigSpecOperation.edit); nicSpec.setDevice(nic); VirtualDeviceConfigSpec[] configSpecs = new VirtualDeviceConfigSpec[1]; configSpecs[0] = nicSpec; VirtualMachineConfigSpec machineConfigSpec = new VirtualMachineConfigSpec(); machineConfigSpec.setDeviceChange(configSpecs); Task task = vm.reconfigVM_Task(machineConfigSpec); String status = task.waitForTask(); if (!status.equals("success")) { String message = task.getTaskInfo().getError().getLocalizedMessage(); throw new RemoteException("Failed: " + message); } }