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


Java OvfCreateDescriptorResult类代码示例

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


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

示例1: createDescriptor

import com.vmware.vim25.OvfCreateDescriptorResult; //导入依赖的package包/类
public OvfCreateDescriptorResult createDescriptor(ManagedEntity obj, OvfCreateDescriptorParams cdp) throws TaskInProgress, VmConfigFault, ConcurrentAccess, FileFault, InvalidState, RuntimeFault, RemoteException
{
	return getVimService().createDescriptor(getMOR(), obj.getMOR(), cdp);
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:5,代码来源:OvfManager.java

示例2: createOvfFile

import com.vmware.vim25.OvfCreateDescriptorResult; //导入依赖的package包/类
public static void createOvfFile(VmwareHypervisorHost host, String diskFileName, String ovfName, String datastorePath, String templatePath, long diskCapacity, long fileSize,
        ManagedObjectReference morDs) throws Exception {
    VmwareContext context = host.getContext();
    ManagedObjectReference morOvf = context.getServiceContent().getOvfManager();
    VirtualMachineMO workerVmMo = HypervisorHostHelper.createWorkerVM(host, new DatastoreMO(context, morDs), ovfName);
    if (workerVmMo == null)
        throw new Exception("Unable to find just-created worker VM");

    String[] disks = {datastorePath + File.separator + diskFileName};
    try {
        VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
        VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();

        // Reconfigure worker VM with datadisk
        VirtualDevice device = VmwareHelper.prepareDiskDevice(workerVmMo, null, -1, disks, morDs, -1, 1);
        deviceConfigSpec.setDevice(device);
        deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
        vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
        workerVmMo.configureVm(vmConfigSpec);

        // Write OVF descriptor file
        OvfCreateDescriptorParams ovfDescParams = new OvfCreateDescriptorParams();
        String deviceId = File.separator + workerVmMo.getMor().getValue() + File.separator + "VirtualIDEController0:0";
        OvfFile ovfFile = new OvfFile();
        ovfFile.setPath(diskFileName);
        ovfFile.setDeviceId(deviceId);
        ovfFile.setSize(fileSize);
        ovfFile.setCapacity(diskCapacity);
        ovfDescParams.getOvfFiles().add(ovfFile);
        OvfCreateDescriptorResult ovfCreateDescriptorResult = context.getService().createDescriptor(morOvf, workerVmMo.getMor(), ovfDescParams);

        String ovfPath = templatePath + File.separator + ovfName + ".ovf";
        try {
            FileWriter out = new FileWriter(ovfPath);
            out.write(ovfCreateDescriptorResult.getOvfDescriptor());
            out.close();
        } catch (Exception e) {
            throw e;
        }
    } finally {
        workerVmMo.detachAllDisks();
        workerVmMo.destroy();
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:45,代码来源:HypervisorHostHelper.java


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