• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TaskInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.vmware.vim25.TaskInfo的典型用法代码示例。如果您正苦于以下问题:Java TaskInfo类的具体用法?Java TaskInfo怎么用?Java TaskInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TaskInfo类属于com.vmware.vim25包,在下文中一共展示了TaskInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: detachDiskFromVM

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
public void detachDiskFromVM() throws Exception {
    ArrayOfVirtualDevice devices = this.get
            .entityProp(this.vm, VimPath.vm_config_hardware_device);
    VirtualDisk vd = (VirtualDisk) findMatchingVirtualDevice(getListOfVirtualDisk(devices));
    if (vd == null) {
        throw new IllegalStateException(
                String.format(
                        "Matching Virtual Disk is not for disk %s.",
                        this.diskState.documentSelfLink));
    }
    // Detach the disk from VM.
    VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
    deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.REMOVE);
    deviceConfigSpec.setDevice(vd);

    VirtualMachineConfigSpec spec = new VirtualMachineConfigSpec();
    spec.getDeviceChange().add(deviceConfigSpec);

    ManagedObjectReference reconfigureTask = getVimPort().reconfigVMTask(this.vm, spec);
    TaskInfo info = VimUtils.waitTaskEnd(this.connection, reconfigureTask);
    if (info.getState() == TaskInfoState.ERROR) {
        VimUtils.rethrow(info.getError());
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:25,代码来源:InstanceDiskClient.java


示例2: deleteDiskFromVSphere

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
private void deleteDiskFromVSphere(DiskState diskState) throws Throwable {
    Connection connection = createConnection();

    String diskFullPath = CustomProperties.of(diskState).getString(DISK_FULL_PATH, null);
    ManagedObjectReference diskManager = connection.getServiceContent()
            .getVirtualDiskManager();
    ManagedObjectReference datacenterMoRef = VimUtils.convertStringToMoRef(diskState.regionId);
    ManagedObjectReference deleteTask = connection.getVimPort().deleteVirtualDiskTask(diskManager,
            diskFullPath, datacenterMoRef);
    TaskInfo info = VimUtils.waitTaskEnd(connection, deleteTask);

    String dirName = CustomProperties.of(diskState).getString(DISK_PARENT_DIRECTORY, null);
    ManagedObjectReference fileManager = connection.getServiceContent()
            .getFileManager();
    deleteTask = connection.getVimPort().deleteDatastoreFileTask(fileManager, dirName,
            datacenterMoRef);
    info = VimUtils.waitTaskEnd(connection, deleteTask);

}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:TestVSphereDiskService.java


示例3: printTaskInfo

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
static void printTaskInfo(TaskInfo ti)
{
  System.out.println("\nName:" + ti.getName());
  System.out.println("Key:" + ti.getKey());
  System.out.println("Entity:" + ti.getEntityName());
  System.out.println("Reason:" + taskReason(ti.getReason()));
  System.out.println("QueueTime:" 
      + ti.getQueueTime().getTime());
  Calendar calStart = ti.getStartTime();
  Date dateStart = calStart==null? null : calStart.getTime();
  System.out.println("StartTime:" + dateStart);
  Calendar calStop = ti.getCompleteTime();
  Date dateStop = calStop==null? null : calStop.getTime();
  System.out.println("CompleteTime:" + dateStop);
  System.out.println("Cancelable:" + ti.isCancelable());
  System.out.println("Cancelled:" + ti.isCancelled());
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:18,代码来源:TaskHistoryMonitor.java


示例4: getTaskFailureInfo

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
public static String getTaskFailureInfo(VmwareContext context, ManagedObjectReference morTask) {
    StringBuffer sb = new StringBuffer();

    try {
        TaskInfo info = (TaskInfo)context.getVimClient().getDynamicProperty(morTask, "info");
        if (info != null) {
            LocalizedMethodFault fault = info.getError();
            if (fault != null) {
                sb.append(fault.getLocalizedMessage()).append(" ");

                if (fault.getFault() != null)
                    sb.append(fault.getFault().getClass().getName());
            }
        }
    } catch (Exception e) {
        s_logger.info("[ignored]"
                + "error retrieving failure info for task : " + e.getLocalizedMessage());
    }

    return sb.toString();
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:22,代码来源:TaskMO.java


示例5: logTaskInfo

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
private void logTaskInfo(TaskInfo info) {
    if (info == null) {
        logger.debug("Deleted task info key");
        return;
    }

    TaskInfoState state = info.getState();

    Integer progress = info.getProgress();
    if (state == TaskInfoState.SUCCESS) {
        progress = Integer.valueOf(100);
    } else if (progress == null) {
        progress = Integer.valueOf(0);
    }

    LocalizableMessage desc = info.getDescription();
    String description = desc != null ? desc.getMessage() : "";

    XMLGregorianCalendar queueT = info.getQueueTime();
    String queueTime = queueT != null
            ? queueT.toGregorianCalendar().getTime().toString() : "";

    XMLGregorianCalendar startT = info.getStartTime();
    String startTime = startT != null
            ? startT.toGregorianCalendar().getTime().toString() : "";

    XMLGregorianCalendar completeT = info.getCompleteTime();
    String completeTime = completeT != null
            ? completeT.toGregorianCalendar().getTime().toString() : "";

    logger.debug("Save task info key: " + info.getKey() + " name: "
            + info.getName() + " target: " + info.getEntityName()
            + " state: " + state.name() + " progress: " + progress
            + "% description: " + description + " queue-time: " + queueTime
            + " start-time: " + startTime + " complete-time: "
            + completeTime);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:38,代码来源:VMPropertyHandler.java


示例6: successfulTask

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
@StateMachineAction
@Override
protected String successfulTask(TaskInfo taskInfo, VMPropertyHandler ph) {
    ph.setSetting(VMPropertyHandler.GUEST_READY_TIMEOUT_REF,
            String.valueOf(System.currentTimeMillis()));
    if (TASK_NAME_CREATE_SNAPSHOT.equals(taskInfo.getName())) {
        ManagedObjectReference mor = (ManagedObjectReference) taskInfo
                .getResult();
        ph.setSetting(VMPropertyHandler.SNAPSHOT_ID, mor.getValue());
    }
    return EVENT_SUCCESS;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:13,代码来源:SnapshotActions.java


示例7: successfulTask

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
protected String successfulTask(
        @SuppressWarnings("unused") TaskInfo taskInfo,
        VMPropertyHandler ph) {
    ph.setSetting(VMPropertyHandler.GUEST_READY_TIMEOUT_REF,
            String.valueOf(System.currentTimeMillis()));
    return EVENT_SUCCESS;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:8,代码来源:Actions.java


示例8: getTaskInfo

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
protected TaskInfo getTaskInfo(VMwareClient vmw,
        VMPropertyHandler paramHandler) throws Exception {

    String instanceId = paramHandler.getInstanceName();
    String taskKey = paramHandler
            .getServiceSetting(VMPropertyHandler.TASK_KEY);
    logger.debug("VM: " + instanceId + " taskId: " + taskKey);
    if (taskKey == null || "".equals(taskKey)) {
        return null;
    }

    VimPortType service = vmw.getConnection().getService();
    ManagedObjectReference taskManager = vmw.getConnection()
            .getServiceContent().getTaskManager();
    ManagedObjectReference taskHistoryCollector = service
            .createCollectorForTasks(taskManager, new TaskFilterSpec());
    try {
        service.resetCollector(taskHistoryCollector);
        service.readNextTasks(taskHistoryCollector, 100);
        List<TaskInfo> taskList = vmw.getConnection().getService()
                .readPreviousTasks(taskHistoryCollector, 100);

        if (taskList != null) {
            for (TaskInfo taskInfo : taskList) {
                if (taskInfo != null && taskKey.equals(taskInfo.getKey())) {
                    logTaskInfo(taskInfo);
                    return taskInfo;
                }
            }
        }

        logger.error("Task not found. VM: " + instanceId + " taskId: "
                + taskKey);
        return null;
    } finally {
        service.destroyCollector(taskHistoryCollector);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:39,代码来源:Actions.java


示例9: start

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
public TaskInfo start() throws Exception {
    LOG.debug("instanceName: " + instanceName);
    ManagedObjectReference startTask = vmw.getConnection().getService()
            .powerOnVMTask(vmInstance, null);

    TaskInfo tInfo = (TaskInfo) vmw.getServiceUtil()
            .getDynamicProperty(startTask, "info");
    return tInfo;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:10,代码来源:VM.java


示例10: reconfigureVirtualMachine

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
/**
 * Reconfigures VMware instance. Memory, CPU, disk space and network
 * adapter. The VM has been created and must be stopped to reconfigure the
 * hardware.
 */
public TaskInfo reconfigureVirtualMachine(VMPropertyHandler paramHandler)
        throws Exception {
    LOG.debug("instanceName: " + instanceName);

    VimPortType service = vmw.getConnection().getService();
    VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();

    vmConfigSpec
            .setMemoryMB(Long.valueOf(paramHandler.getConfigMemoryMB()));
    vmConfigSpec.setNumCPUs(Integer.valueOf(paramHandler.getConfigCPUs()));

    String reqUser = paramHandler
            .getServiceSetting(VMPropertyHandler.REQUESTING_USER);

    String comment = Messages.get(paramHandler.getLocale(), "vm_comment",
            new Object[] { paramHandler.getSettings().getOrganizationName(),
                    paramHandler.getSettings().getSubscriptionId(),
                    reqUser });
    String annotation = vmConfigSpec.getAnnotation();
    comment = updateComment(comment, annotation);
    vmConfigSpec.setAnnotation(comment);

    DiskManager diskManager = new DiskManager(vmw, paramHandler);
    diskManager.reconfigureDisks(vmConfigSpec, vmInstance);

    NetworkManager.configureNetworkAdapter(vmw, vmConfigSpec, paramHandler,
            vmInstance);

    LOG.debug("Call vSphere API: reconfigVMTask()");
    ManagedObjectReference reconfigureTask = service
            .reconfigVMTask(vmInstance, vmConfigSpec);

    return (TaskInfo) vmw.getServiceUtil()
            .getDynamicProperty(reconfigureTask, "info");
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:41,代码来源:VM.java


示例11: updateCommentField

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
public TaskInfo updateCommentField(String comment) throws Exception {
    LOG.debug("instanceName: " + instanceName + " comment: " + comment);
    VimPortType service = vmw.getConnection().getService();
    VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
    String annotation = vmConfigSpec.getAnnotation();
    comment = updateComment(comment, annotation);
    vmConfigSpec.setAnnotation(comment);
    LOG.debug("Call vSphere API: reconfigVMTask()");
    ManagedObjectReference reconfigureTask = service
            .reconfigVMTask(vmInstance, vmConfigSpec);

    return (TaskInfo) vmw.getServiceUtil()
            .getDynamicProperty(reconfigureTask, "info");
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:15,代码来源:VM.java


示例12: delete

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
/**
 * Delete VMware instance on vSphere server.
 * 
 * @param vmw
 *            connected VMware client entity
 * @param instanceId
 *            id of the instance
 */
public TaskInfo delete() throws Exception {
    LOG.debug("Call vSphere API: destroyTask() instanceName: "
            + instanceName);
    ManagedObjectReference startTask = vmw.getConnection().getService()
            .destroyTask(vmInstance);

    return (TaskInfo) vmw.getServiceUtil().getDynamicProperty(startTask,
            "info");
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:VM.java


示例13: migrateVM

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
private static boolean migrateVM(ServiceInstance si, Folder rootFolder,
    HostSystem newHost, String targetVMName, String newHostName)
    throws Exception {

  log("Selected host [vm] for vMotion: " + newHostName + " [" + targetVMName
      + "]");
  VirtualMachine vm = (VirtualMachine)new InventoryNavigator(rootFolder)
      .searchManagedEntity("VirtualMachine", targetVMName);
  if (vm == null) {
    log(WARNING, "Could not resolve VM " + targetVMName + ", vMotion of this VM cannot be performed.");
    return false;
  }

  ComputeResource cr = (ComputeResource)newHost.getParent();

  String[] checks = new String[] { "cpu", "software" };
  HostVMotionCompatibility[] vmcs = si.queryVMotionCompatibility(vm,
      new HostSystem[] { newHost }, checks);

  String[] comps = vmcs[0].getCompatibility();
  if (checks.length != comps.length) {
    log(WARNING, "CPU/software NOT compatible, vMotion failed.");
    return false;
  }

  long start = System.currentTimeMillis();
  Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost,
      VirtualMachineMovePriority.highPriority,
      VirtualMachinePowerState.poweredOn);
  if (task.waitForMe() == Task.SUCCESS) {
    long end = System.currentTimeMillis();
    log("vMotion of " + targetVMName + " to " + newHostName
        + " completed in " + (end - start) + "ms. Task result: "
        + task.getTaskInfo().getResult());
    return true;
  } else {
    TaskInfo info = task.getTaskInfo();
    log(WARNING, "vMotion of " + targetVMName + " to " + newHostName
        + " failed. Error details: " + info.getError().getFault());
    return false;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:43,代码来源:VMotionTrigger.java


示例14: powerOffVM

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
/**
 * Power off virtual machine
 */
public static void powerOffVM(final Connection connection, final VimPortType vimPort,
        final ManagedObjectReference vm) throws Exception {
    ManagedObjectReference powerTask = vimPort.powerOffVMTask(vm);
    TaskInfo info = VimUtils.waitTaskEnd(connection, powerTask);
    if (info.getState() == TaskInfoState.ERROR) {
        VimUtils.rethrow(info.getError());
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:12,代码来源:ClientUtils.java


示例15: powerOnVM

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
/**
 * Power on virtual machine
 */
public static void powerOnVM(final Connection connection, final VimPortType vimPort,
        final ManagedObjectReference vm) throws Exception {
    ManagedObjectReference powerTask = vimPort.powerOnVMTask(vm, null);
    TaskInfo info = VimUtils.waitTaskEnd(connection, powerTask);
    if (info.getState() == TaskInfoState.ERROR) {
        VimUtils.rethrow(info.getError());
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:12,代码来源:ClientUtils.java


示例16: reconfigureBootDisk

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
/**
 * Reconfigure image disk with the customizations
 */
private void reconfigureBootDisk(ManagedObjectReference vmMoref,
        List<VirtualDeviceConfigSpec> deviceConfigSpecs) throws Exception {
    if (deviceConfigSpecs != null && !deviceConfigSpecs.isEmpty()) {
        VirtualMachineConfigSpec bootDiskSpec = new VirtualMachineConfigSpec();
        bootDiskSpec.getDeviceChange().addAll(deviceConfigSpecs);
        ManagedObjectReference task = getVimPort().reconfigVMTask(vmMoref, bootDiskSpec);
        TaskInfo info = waitTaskEnd(task);

        if (info.getState() == TaskInfoState.ERROR) {
            VimUtils.rethrow(info.getError());
        }
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:InstanceClient.java


示例17: createVirtualDisk

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
/**
 * Create Virtual Disk
 */
public void createVirtualDisk() throws Exception {
    ManagedObjectReference diskManager = this.connection.getServiceContent()
            .getVirtualDiskManager();
    List<VirtualMachineDefinedProfileSpec> pbmSpec = getPbmProfileSpec(this.diskState);

    String dsName = this.diskContext.datastoreName != null && !this.diskContext.datastoreName
            .isEmpty() ? this.diskContext.datastoreName : ClientUtils.getDefaultDatastore(this.finder);
    String diskName = getUniqueDiskName();

    // Create the parent folder before creation of the disk file
    String parentDir = String.format(VM_PATH_FORMAT, dsName, diskName);
    createParentFolder(parentDir);

    String diskFullPath = constructDiskFullPath(dsName, diskName);
    ManagedObjectReference createTask = getVimPort().createVirtualDiskTask(diskManager,
            diskFullPath, this.diskContext.datacenterMoRef,
            createVirtualDiskSpec(this.diskState, pbmSpec));
    TaskInfo info = waitTaskEnd(createTask);

    if (info.getState() == TaskInfoState.ERROR) {
        VimUtils.rethrow(info.getError());
    }

    // Update the details of the disk
    CustomProperties.of(this.diskState)
            .put(DISK_FULL_PATH, diskFullPath)
            .put(DISK_PARENT_DIRECTORY, parentDir)
            .put(DISK_DATASTORE_NAME, dsName);
    this.diskState.status = DiskService.DiskStatus.AVAILABLE;
    this.diskState.id = diskName;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:35,代码来源:DiskClient.java


示例18: deleteVirtualDisk

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
/**
 * Delete Virtual disk.
 */
public void deleteVirtualDisk()
        throws Exception {
    ManagedObjectReference diskManager = this.connection.getServiceContent()
            .getVirtualDiskManager();

    if (this.diskState.status != DiskService.DiskStatus.AVAILABLE) {
        throw new IllegalArgumentException("Only disk with status AVAILABLE can be deleted, as it is not attached to any VM.");
    }

    String diskFullPath = CustomProperties.of(this.diskState).getString(DISK_FULL_PATH, null);
    if (diskFullPath == null) {
        throw new IllegalArgumentException("Disk full path to issue delete request is empty.");
    }

    // Delete the vmdk file
    ManagedObjectReference deleteTask = getVimPort().deleteVirtualDiskTask(diskManager,
            diskFullPath, this.diskContext.datacenterMoRef);
    TaskInfo info = waitTaskEnd(deleteTask);

    if (info.getState() == TaskInfoState.ERROR) {
        VimUtils.rethrow(info.getError());
    }

    // Delete the folder that holds the vmdk file
    String dirName = CustomProperties.of(this.diskState).getString(DISK_PARENT_DIRECTORY, null);
    if (dirName != null) {
        ManagedObjectReference fileManager = this.connection.getServiceContent()
                .getFileManager();
        ManagedObjectReference deleteFile = getVimPort().deleteDatastoreFileTask(fileManager, dirName, this.diskContext
                .datacenterMoRef);
        info = waitTaskEnd(deleteFile);
        if (info.getState() == TaskInfoState.ERROR) {
            VimUtils.rethrow(info.getError());
        }
    } else {
        Utils.logWarning("Disk parent directory is null, hence couldn't cleanup disk directory in the datastore");
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:42,代码来源:DiskClient.java


示例19: waitTaskEnd

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
public static TaskInfo waitTaskEnd(Connection connection, ManagedObjectReference task)
        throws InvalidCollectorVersionFaultMsg, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    WaitForValues waitForValues = new WaitForValues(connection);

    Object[] info = waitForValues.wait(task,
            new String[] { VimPath.task_info },
            new String[] { VimPath.task_info_state },
            new Object[][] { new Object[] {
                    TaskInfoState.SUCCESS,
                    TaskInfoState.ERROR
            } });

    return (TaskInfo) info[0];
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:15,代码来源:VimUtils.java


示例20: should_report_isdone_for_error_tasks

import com.vmware.vim25.TaskInfo; //导入依赖的package包/类
public void should_report_isdone_for_error_tasks() throws ExecutionException, InterruptedException {
  VmwareTaskWrapper taskWrapper = new VmwareTaskWrapper(new Callable<Task>() {
    @Override
    public Task call() throws Exception {
      return new Task(null, null){
        @Override
        public TaskInfo getTaskInfo() throws InvalidProperty, RuntimeFault, RemoteException {
          throw new RuntimeException("getTaskInfo exception");
        }

        @Override
        public String waitForTask() throws RuntimeFault, RemoteException, InterruptedException {
          throw new RuntimeException("getTaskInfo exception");
        }

        @Override
        public void cancelTask() throws RuntimeFault, RemoteException {
          throw new RuntimeException("getTaskInfo exception");
        }
      };
    }
  }, "myTask");
  final Future<CloudTaskResult> async = taskWrapper.executeOrGetResultAsync();
  int cnt = 0;
  while (!async.isDone()){
    cnt++;
    assertTrue(cnt < 5);
  }
  final CloudTaskResult result = async.get();
  assertTrue(result.isHasErrors());
}
 
开发者ID:JetBrains,项目名称:teamcity-vmware-plugin,代码行数:32,代码来源:VmwareTaskWrapperTest.java



注:本文中的com.vmware.vim25.TaskInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Dictionary类代码示例发布时间:2022-05-22
下一篇:
Java Allocation类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap