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


Java VirtualMachineConfigSpec类代码示例

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


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

示例1: replaceNetworkAdapter

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
private static void replaceNetworkAdapter(
        VirtualMachineConfigSpec vmConfigSpec, VirtualDevice oldNIC,
        ManagedObjectReference newNetworkRef, String newNetworkName)
        throws Exception {
    logger.debug("new network: " + newNetworkName);
    VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
    nicBacking.setDeviceName(newNetworkName);
    nicBacking.setNetwork(newNetworkRef);
    nicBacking.setUseAutoDetect(true);
    oldNIC.setBacking(nicBacking);

    VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
    info.setConnected(true);
    info.setStartConnected(true);
    info.setAllowGuestControl(true);
    oldNIC.setConnectable(info);
    // oldNIC.getConnectable().setConnected(true);
    // oldNIC.getConnectable().setStartConnected(true);
    VirtualDeviceConfigSpec vmDeviceSpec = new VirtualDeviceConfigSpec();
    vmDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
    vmDeviceSpec.setDevice(oldNIC);
    vmConfigSpec.getDeviceChange().add(vmDeviceSpec);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:24,代码来源:NetworkManager.java

示例2: reconfigureDisks

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
/**
 * Reconfigures VMware system disks and data disks.
 */
public void reconfigureDisks(VirtualMachineConfigSpec vmConfigSpec,
        ManagedObjectReference vmwInstance) throws Exception {

    logger.debug("");

    long systemDiskMB = (long) paramHandler.getConfigDiskSpaceMB();
    VirtualMachineConfigInfo configSpec = (VirtualMachineConfigInfo) vmw
            .getServiceUtil().getDynamicProperty(vmwInstance, "config");
    List<VirtualDevice> devices = configSpec.getHardware().getDevice();
    VirtualDisk vdSystemDisk = getVMSystemDisk(devices,
            configSpec.getName());

    configureSystemDisk(vmConfigSpec, systemDiskMB, vdSystemDisk);
    configureDataDisks(vmConfigSpec, devices, vdSystemDisk);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:DiskManager.java

示例3: detachDiskFromVM

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的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

示例4: addHardDisk

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
public void addHardDisk(String diskFilePath, VirtualDiskMode diskMode) throws Exception
{
  VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();

  VirtualDeviceConfigSpec diskSpec = new VirtualDeviceConfigSpec();
  VirtualDeviceConfigSpec[] vdiskSpecArray = {diskSpec};
  vmConfigSpec.setDeviceChange(vdiskSpecArray);
  
  VirtualDiskFlatVer2BackingInfo diskfileBacking = new VirtualDiskFlatVer2BackingInfo();
  diskfileBacking.setFileName(diskFilePath);
  diskfileBacking.setDiskMode(diskMode.toString());

  
  VirtualSCSIController scsiController = getFirstAvailableController(VirtualSCSIController.class);
  int unitNumber = getFirstFreeUnitNumberForController(scsiController);

  VirtualDisk disk = new VirtualDisk();
  disk.setControllerKey(scsiController.key);
  disk.setUnitNumber(unitNumber);
  disk.setBacking(diskfileBacking);
  //Unlike required by API ref, the capacityKB is optional. So skip setCapacityInKB() method.
  disk.setKey(-100);

  diskSpec.setOperation(VirtualDeviceConfigSpecOperation.add);           
  diskSpec.setDevice(disk);                 
  
  Task task = vm.reconfigVM_Task(vmConfigSpec);

  task.waitForTask(200, 100);
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:31,代码来源:VirtualMachineDeviceManager.java

示例5: getPopulatedVmConfigSpec

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
VirtualMachineConfigSpec getPopulatedVmConfigSpec(VirtualMachineConfigSpec vmConfigSpec, VmInputs vmInputs, String name) {
    vmConfigSpec.setName(name);
    vmConfigSpec.setNumCPUs(vmInputs.getIntNumCPUs());
    vmConfigSpec.setMemoryMB(vmInputs.getLongVmMemorySize());
    vmConfigSpec.setAnnotation(vmInputs.getDescription());

    if (vmInputs.getCoresPerSocket() != null) {
        vmConfigSpec.setNumCoresPerSocket(InputUtils.getIntInput(vmInputs.getCoresPerSocket(), DEFAULT_CORES_PER_SOCKET));
    }

    if (vmInputs.getGuestOsId() != null) {
        vmConfigSpec.setGuestId(vmInputs.getGuestOsId());
    }

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

示例6: createVM

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
/**
 * Method used to connect to specified data center and create a virtual machine using the inputs provided.
 *
 * @param httpInputs Object that has all the inputs necessary to made a connection to data center
 * @param vmInputs   Object that has all the specific inputs necessary to create a new virtual machine
 * @return Map with String as key and value that contains returnCode of the operation, success message with task id
 *         of the execution or failure message and the exception if there is one
 * @throws Exception
 */
public Map<String, String> createVM(HttpInputs httpInputs, VmInputs vmInputs) throws Exception {
    ConnectionResources connectionResources = new ConnectionResources(httpInputs, vmInputs);
    try {
        VmUtils utils = new VmUtils();
        ManagedObjectReference vmFolderMor = utils.getMorFolder(vmInputs.getFolderName(), connectionResources);
        ManagedObjectReference resourcePoolMor = utils.getMorResourcePool(vmInputs.getResourcePool(), connectionResources);
        ManagedObjectReference hostMor = utils.getMorHost(vmInputs.getHostname(), connectionResources, null);
        VirtualMachineConfigSpec vmConfigSpec = new VmConfigSpecs().getVmConfigSpec(vmInputs, connectionResources);

        ManagedObjectReference task = connectionResources.getVimPortType()
                .createVMTask(vmFolderMor, vmConfigSpec, resourcePoolMor, hostMor);

        return new ResponseHelper(connectionResources, task).getResultsMap("Success: Created [" +
                        vmInputs.getVirtualMachineName() + "] VM. The taskId is: " + task.getValue(),
                "Failure: Could not create [" + vmInputs.getVirtualMachineName() + "] VM");
    } catch (Exception ex) {
        return ResponseUtils.getResultsMap(ex.toString(), Outputs.RETURN_CODE_FAILURE);
    } finally {
        if (httpInputs.isCloseSession()) {
            connectionResources.getConnection().disconnect();
            clearConnectionFromContext(httpInputs.getGlobalSessionObject());
        }
    }

}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:35,代码来源:VmService.java

示例7: createVm

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
@Override
public boolean createVm(VirtualMachineConfigSpec vmSpec) throws Exception {
    assert (vmSpec != null);
    DatacenterMO dcMo = new DatacenterMO(_context, getHyperHostDatacenter());
    ManagedObjectReference morPool = getHyperHostOwnerResourcePool();

    ManagedObjectReference morTask = _context.getService().createVMTask(dcMo.getVmFolder(), vmSpec, morPool, _mor);
    boolean result = _context.getVimClient().waitForTask(morTask);

    if (result) {
        _context.waitForTaskProgressDone(morTask);
        return true;
    } else {
        s_logger.error("VMware createVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    }
    return false;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:18,代码来源:HostMO.java

示例8: tearDownDevices

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
public void tearDownDevices(Class<?>[] deviceClasses) throws Exception {
    VirtualDevice[] devices = getMatchedDevices(deviceClasses);

    if (devices.length > 0) {
        VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
        VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[devices.length];

        for (int i = 0; i < devices.length; i++) {
            deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
            deviceConfigSpecArray[i].setDevice(devices[i]);
            deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.REMOVE);
            vmConfigSpec.getDeviceChange().add(deviceConfigSpecArray[i]);
        }

        if (!configureVm(vmConfigSpec)) {
            throw new Exception("Failed to detach devices");
        }
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:20,代码来源:VirtualMachineMO.java

示例9: ensurePvScsiDeviceController

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
public void ensurePvScsiDeviceController(int requiredNumScsiControllers, int availableBusNum) throws Exception {
    VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();

    int busNum = availableBusNum;
    while (busNum < requiredNumScsiControllers) {
        ParaVirtualSCSIController scsiController = new ParaVirtualSCSIController();

        scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
        scsiController.setBusNumber(busNum);
        scsiController.setKey(busNum - VmwareHelper.MAX_SCSI_CONTROLLER_COUNT);
        VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
        scsiControllerSpec.setDevice(scsiController);
        scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);

        vmConfig.getDeviceChange().add(scsiControllerSpec);
        busNum++;
    }

    if (configureVm(vmConfig)) {
        throw new Exception("Unable to add Scsi controllers to the VM " + getName());
    } else {
        s_logger.info("Successfully added " + requiredNumScsiControllers + " SCSI controllers.");
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:25,代码来源:VirtualMachineMO.java

示例10: ensureLsiLogicDeviceControllers

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
public void ensureLsiLogicDeviceControllers(int count, int availableBusNum) throws Exception {
    int scsiControllerKey = getLsiLogicDeviceControllerKeyNoException();
    if (scsiControllerKey < 0) {
        VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();

        int busNum = availableBusNum;
        while (busNum < count) {
            VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
            scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
            scsiController.setBusNumber(busNum);
            scsiController.setKey(busNum - VmwareHelper.MAX_SCSI_CONTROLLER_COUNT);
            VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
            scsiControllerSpec.setDevice(scsiController);
            scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);

            vmConfig.getDeviceChange().add(scsiControllerSpec);
            busNum++;
        }
        if (configureVm(vmConfig)) {
            throw new Exception("Unable to add Lsi Logic controllers to the VM " + getName());
        } else {
            s_logger.info("Successfully added " + count + " LsiLogic Parallel SCSI controllers.");
        }
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:26,代码来源:VirtualMachineMO.java

示例11: ensureScsiDeviceController

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
public void ensureScsiDeviceController() throws Exception {
    int scsiControllerKey = getScsiDeviceControllerKeyNoException();
    if (scsiControllerKey < 0) {
        VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();

        // Scsi controller
        VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
        scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
        scsiController.setBusNumber(0);
        scsiController.setKey(1);
        VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
        scsiControllerSpec.setDevice(scsiController);
        scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);

        vmConfig.getDeviceChange().add(scsiControllerSpec);
        if (configureVm(vmConfig)) {
            throw new Exception("Unable to add Scsi controller");
        }
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:21,代码来源:VirtualMachineMO.java

示例12: ensureScsiDeviceControllers

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
public void ensureScsiDeviceControllers(int count, int availableBusNum) throws Exception {
    int scsiControllerKey = getScsiDeviceControllerKeyNoException();
    if (scsiControllerKey < 0) {
        VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();

        int busNum = availableBusNum;
        while (busNum < count) {
        VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
        scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
            scsiController.setBusNumber(busNum);
            scsiController.setKey(busNum - VmwareHelper.MAX_SCSI_CONTROLLER_COUNT);
        VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
        scsiControllerSpec.setDevice(scsiController);
        scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);

        vmConfig.getDeviceChange().add(scsiControllerSpec);
            busNum++;
        }
        if (configureVm(vmConfig)) {
            throw new Exception("Unable to add Scsi controllers to the VM " + getName());
        } else {
            s_logger.info("Successfully added " + count + " SCSI controllers.");
        }
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:26,代码来源:VirtualMachineMO.java

示例13: ensureLsiLogicSasDeviceControllers

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
public void ensureLsiLogicSasDeviceControllers(int count, int availableBusNum) throws Exception {
    int scsiControllerKey = getLsiLogicSasDeviceControllerKeyNoException();
    if (scsiControllerKey < 0) {
        VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();

        int busNum = availableBusNum;
        while (busNum < count) {
            VirtualLsiLogicSASController scsiController = new VirtualLsiLogicSASController();
            scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
            scsiController.setBusNumber(busNum);
            scsiController.setKey(busNum - VmwareHelper.MAX_SCSI_CONTROLLER_COUNT);
            VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
            scsiControllerSpec.setDevice(scsiController);
            scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);

            vmConfig.getDeviceChange().add(scsiControllerSpec);
            busNum++;
        }
        if (configureVm(vmConfig)) {
            throw new Exception("Unable to add Scsi controller of type LsiLogic SAS.");
        }
    }

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

示例14: createVm

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
@Override
public boolean createVm(VirtualMachineConfigSpec vmSpec) throws Exception {
    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - createVM_Task(). target MOR: " + _mor.getValue() + ", VirtualMachineConfigSpec: " + new Gson().toJson(vmSpec));

    assert (vmSpec != null);
    DatacenterMO dcMo = new DatacenterMO(_context, getHyperHostDatacenter());
    ManagedObjectReference morPool = getHyperHostOwnerResourcePool();

    ManagedObjectReference morTask = _context.getService().createVMTask(dcMo.getVmFolder(), vmSpec, morPool, null);
    boolean result = _context.getVimClient().waitForTask(morTask);

    if (result) {
        _context.waitForTaskProgressDone(morTask);

        if (s_logger.isTraceEnabled())
            s_logger.trace("vCenter API trace - createVM_Task() done(successfully)");
        return true;
    } else {
        s_logger.error("VMware createVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    }

    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - createVM_Task() done(failed)");
    return false;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:27,代码来源:ClusterMO.java

示例15: setVmScaleUpConfig

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
public static void setVmScaleUpConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB,
        boolean limitCpuUse) {

    // VM config for scaling up
    vmConfig.setMemoryMB((long)memoryMB);
    vmConfig.setNumCPUs(cpuCount);

    ResourceAllocationInfo cpuInfo = new ResourceAllocationInfo();
    if (limitCpuUse) {
        cpuInfo.setLimit((long)(cpuSpeedMHz * cpuCount));
    } else {
        cpuInfo.setLimit(-1L);
    }

    cpuInfo.setReservation((long)cpuReservedMhz);
    vmConfig.setCpuAllocation(cpuInfo);

    ResourceAllocationInfo memInfo = new ResourceAllocationInfo();
    memInfo.setLimit((long)memoryMB);
    memInfo.setReservation((long)memoryReserveMB);
    vmConfig.setMemoryAllocation(memInfo);

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


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