本文整理汇总了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);
}
示例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();
}
}