当前位置: 首页>>代码示例>>Java>>正文


Java VirtualMachineRelocateSpec.setDatastore方法代码示例

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


在下文中一共展示了VirtualMachineRelocateSpec.setDatastore方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFullClone

import com.vmware.vim25.VirtualMachineRelocateSpec; //导入方法依赖的package包/类
public boolean createFullClone(String cloneName, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool, ManagedObjectReference morDs)
        throws Exception {

    VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
    VirtualMachineRelocateSpec relocSpec = new VirtualMachineRelocateSpec();
    cloneSpec.setLocation(relocSpec);
    cloneSpec.setPowerOn(false);
    cloneSpec.setTemplate(false);

    relocSpec.setDatastore(morDs);
    relocSpec.setPool(morResourcePool);
    ManagedObjectReference morTask = _context.getService().cloneVMTask(_mor, morFolder, cloneName, cloneSpec);

    boolean result = _context.getVimClient().waitForTask(morTask);
    if (result) {
        _context.waitForTaskProgressDone(morTask);
        return true;
    } else {
        s_logger.error("VMware cloneVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    }

    return false;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:24,代码来源:VirtualMachineMO.java

示例2: getVirtualMachineRelocateSpec

import com.vmware.vim25.VirtualMachineRelocateSpec; //导入方法依赖的package包/类
public VirtualMachineRelocateSpec getVirtualMachineRelocateSpec(ManagedObjectReference resourcePool,
                                                                ManagedObjectReference host,
                                                                ManagedObjectReference dataStore,
                                                                VmInputs vmInputs) {
    VirtualMachineRelocateSpec vmRelocateSpec = new VirtualMachineRelocateSpec();
    vmRelocateSpec.setPool(resourcePool);
    vmRelocateSpec.setHost(host);
    vmRelocateSpec.setDatastore(dataStore);

    if (vmInputs.isThickProvision()) {
        vmRelocateSpec.setTransform(VirtualMachineRelocateTransformation.FLAT);
    } else {
        vmRelocateSpec.setTransform(VirtualMachineRelocateTransformation.SPARSE);
    }

    return vmRelocateSpec;
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:18,代码来源:VmUtils.java

示例3: configureRelocateSpec

import com.vmware.vim25.VirtualMachineRelocateSpec; //导入方法依赖的package包/类
private VirtualMachineRelocateSpec configureRelocateSpec(ResourcePool resourcePool, Datastore datastore, VirtualMachine master)
        throws Exception, InvalidProperty, RuntimeFault, RemoteException {
   VirtualMachineRelocateSpec rSpec = new VirtualMachineRelocateSpec();
   if (cloningStrategy.equals("linked")) {
      ArrayList<Integer> diskKeys = getIndependentVirtualDiskKeys(master);
      if (diskKeys.size() > 0) {
         Datastore[] dss = master.getDatastores();

         VirtualMachineRelocateSpecDiskLocator[] diskLocator = new VirtualMachineRelocateSpecDiskLocator[diskKeys.size()];
         int count = 0;
         for (Integer key : diskKeys) {
            diskLocator[count] = new VirtualMachineRelocateSpecDiskLocator();
            diskLocator[count].setDatastore(dss[0].getMOR());
            diskLocator[count]
                    .setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.moveAllDiskBackingsAndDisallowSharing
                            .toString());
            diskLocator[count].setDiskId(key);
            count = count + 1;
         }
         rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.createNewChildDiskBacking.toString());
         rSpec.setDisk(diskLocator);
      } else {
         rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.createNewChildDiskBacking.toString());
      }
   } else if (cloningStrategy.equals("full")) {
      rSpec.setDatastore(datastore.getMOR());
      rSpec.setPool(resourcePool.getMOR());
      //rSpec.setHost();
   } else
      throw new Exception(String.format("Cloning strategy %s not supported", cloningStrategy));
   return rSpec;
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:33,代码来源:MasterToVirtualMachineCloneSpec.java

示例4: createCloneSpec

import com.vmware.vim25.VirtualMachineRelocateSpec; //导入方法依赖的package包/类
protected VirtualMachineCloneSpec createCloneSpec(String computeResourceName, String resourcePoolName,
        String datastoreName) {
    VirtualMachineRelocateSpec relocateSpec = new VirtualMachineRelocateSpec();

    // ComputeResource
    ComputeResource computeResource = vmwareClient.search(ComputeResource.class, computeResourceName);
    if (computeResource == null) {
        // ComputeResourceが見つからない場合
        throw new AutoException("EPROCESS-000503", computeResourceName);
    }

    // ResourcePool
    if (StringUtils.isEmpty(resourcePoolName)) {
        resourcePoolName = "Resources";
    }
    ResourcePool resourcePool = vmwareClient.search(computeResource, ResourcePool.class, resourcePoolName);
    if (resourcePool == null) {
        // ResourcePoolが見つからない場合
        throw new AutoException("EPROCESS-000504", resourcePoolName);
    }
    relocateSpec.setPool(resourcePool.getMOR());

    // Datastore
    if (StringUtils.isNotEmpty(datastoreName)) {
        // データストアが指定されている場合
        Datastore datastore = vmwareClient.search(Datastore.class, datastoreName);
        if (datastore == null) {
            // データストアが見つからない場合
            throw new AutoException("EPROCESS-000505", datastoreName);
        }
        relocateSpec.setDatastore(datastore.getMOR());
    }

    VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
    cloneSpec.setLocation(relocateSpec);
    cloneSpec.setPowerOn(false);
    cloneSpec.setTemplate(false);

    return cloneSpec;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:41,代码来源:VmwareProcessClient.java

示例5: cloneVm

import com.vmware.vim25.VirtualMachineRelocateSpec; //导入方法依赖的package包/类
private ManagedObjectReference cloneVm(ManagedObjectReference template) throws Exception {
    ManagedObjectReference folder = getVmFolder();
    List<VirtualMachineDefinedProfileSpec> pbmSpec = getPbmProfileSpec(this.bootDisk);
    ManagedObjectReference datastore = getDataStoreForDisk(this.bootDisk, pbmSpec);
    ManagedObjectReference resourcePool = getResourcePool();

    Map<String, Object> props = this.get.entityProps(template, VimPath.vm_config_hardware_device);

    ArrayOfVirtualDevice devices = (ArrayOfVirtualDevice) props
            .get(VimPath.vm_config_hardware_device);

    VirtualDisk vd = devices.getVirtualDevice().stream()
            .filter(d -> d instanceof VirtualDisk)
            .map(d -> (VirtualDisk) d).findFirst().orElse(null);

    VirtualMachineRelocateSpec relocSpec = new VirtualMachineRelocateSpec();
    relocSpec.setDatastore(datastore);
    if (pbmSpec != null) {
        pbmSpec.stream().forEach(spec -> {
            relocSpec.getProfile().add(spec);
        });
    }
    relocSpec.setFolder(folder);
    relocSpec.setPool(resourcePool);
    relocSpec.setDiskMoveType(computeDiskMoveType().value());

    VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
    cloneSpec.setLocation(relocSpec);

    //Set the provisioning type of the parent disk.
    VirtualMachineRelocateSpecDiskLocator diskProvisionTypeLocator = setProvisioningType(vd, datastore,
            pbmSpec);
    if (diskProvisionTypeLocator != null) {
        cloneSpec.getLocation().getDisk().add(diskProvisionTypeLocator);
    }

    cloneSpec.setPowerOn(false);
    cloneSpec.setTemplate(false);

    String displayName = this.ctx.child.name;

    ManagedObjectReference cloneTask = getVimPort()
            .cloneVMTask(template, folder, displayName, cloneSpec);

    TaskInfo info = waitTaskEnd(cloneTask);

    if (info.getState() == TaskInfoState.ERROR) {
        MethodFault fault = info.getError().getFault();
        if (fault instanceof FileAlreadyExists) {
            // a .vmx file already exists, assume someone won the race to create the vm
            return null;
        } else {
            return VimUtils.rethrow(info.getError());
        }
    }

    return (ManagedObjectReference) info.getResult();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:59,代码来源:InstanceClient.java


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