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

Java VirtualMachineConfigSpec类代码示例

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

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



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


示例16: configNestedHVSupport

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
protected void configNestedHVSupport(VirtualMachineMO vmMo, VirtualMachineTO vmSpec, VirtualMachineConfigSpec vmConfigSpec) throws Exception {

        VmwareContext context = vmMo.getContext();
        if ("true".equals(vmSpec.getDetails().get(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG))) {
            if (s_logger.isDebugEnabled())
                s_logger.debug("Nested Virtualization enabled in configuration, checking hypervisor capability");

            ManagedObjectReference hostMor = vmMo.getRunningHost().getMor();
            ManagedObjectReference computeMor = context.getVimClient().getMoRefProp(hostMor, "parent");
            ManagedObjectReference environmentBrowser = context.getVimClient().getMoRefProp(computeMor, "environmentBrowser");
            HostCapability hostCapability = context.getService().queryTargetCapabilities(environmentBrowser, hostMor);
            Boolean nestedHvSupported = hostCapability.isNestedHVSupported();
            if (nestedHvSupported == null) {
                // nestedHvEnabled property is supported only since VMware 5.1. It's not defined for earlier versions.
                s_logger.warn("Hypervisor doesn't support nested virtualization, unable to set config for VM " + vmSpec.getName());
            } else if (nestedHvSupported.booleanValue()) {
                s_logger.debug("Hypervisor supports nested virtualization, enabling for VM " + vmSpec.getName());
                vmConfigSpec.setNestedHVEnabled(true);
            } else {
                s_logger.warn("Hypervisor doesn't support nested virtualization, unable to set config for VM " + vmSpec.getName());
                vmConfigSpec.setNestedHVEnabled(false);
            }
        }
    }
 
开发者ID:apache,项目名称:cloudstack,代码行数:25,代码来源:VmwareResource.java


示例17: configureNetworkAdapter

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
/**
 * Replaces the NICs in the given VM.
 *
 * @param vmw
 *            connected VMware client entity
 * @param paramHandler
 *            entity which holds all properties of the instance
 * @param vmwInstance
 *            the virtual machine that gets reconfigured
 */
public static void configureNetworkAdapter(VMwareClient vmw,
        VirtualMachineConfigSpec vmConfigSpec,
        VMPropertyHandler paramHandler, ManagedObjectReference vmwInstance)
        throws Exception {
    logger.debug("");

    VirtualMachineConfigInfo configInfo = (VirtualMachineConfigInfo) vmw
            .getServiceUtil().getDynamicProperty(vmwInstance, "config");
    List<VirtualEthernetCard> vmNics = getNetworkAdapter(configInfo);

    int numberOfNICs = Integer.parseInt(paramHandler
            .getServiceSetting(VMPropertyHandler.TS_NUMBER_OF_NICS));

    if (numberOfNICs != vmNics.size()) {
        throw new Exception(
                "the number of NICs in virtual machine does not match the service parameter. VM: "
                        + configInfo.getName() + " NICs: " + vmNics.size()
                        + " " + VMPropertyHandler.TS_NUMBER_OF_NICS + ": "
                        + numberOfNICs);
    }

    for (int i = 1; i <= numberOfNICs; i++) {
        String newNetworkName = paramHandler.getNetworkAdapter(i);
        VirtualEthernetCard vmNic = vmNics.get(i - 1);
        String vmNetworkName = getNetworkName(vmw, vmwInstance, i);
        if (newNetworkName != null && newNetworkName.length() > 0
                && !newNetworkName.equals(vmNetworkName)) {
            ManagedObjectReference newNetworkRef = getNetworkFromHost(vmw,
                    vmwInstance, newNetworkName);

            replaceNetworkAdapter(vmConfigSpec, vmNic, newNetworkRef,
                    newNetworkName);
        } else {
            connectNIC(vmConfigSpec, vmNic, vmNetworkName);
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:48,代码来源:NetworkManager.java


示例18: connectNIC

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
private static void connectNIC(VirtualMachineConfigSpec vmConfigSpec,
        VirtualDevice oldNIC, String vmNetworkName) throws Exception {

    logger.debug("networkName: " + vmNetworkName);

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


示例19: updateDiskConfiguration

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
private void updateDiskConfiguration(VirtualMachineConfigSpec vmConfigSpec,
        List<VirtualDevice> devices, int vdKey, long newDiskSpace)
        throws Exception {
    VirtualDisk vdDataDisk = findDataDisk(devices, vdKey);
    if (vdDataDisk != null && newDiskSpace > vdDataDisk.getCapacityInKB()) {

        logger.info("reconfigureDisks() extend data disk #" + vdKey
                + " space to " + newDiskSpace + " ("
                + vdDataDisk.getDeviceInfo().getLabel() + ")");

        if (newDiskSpace < vdDataDisk.getCapacityInKB()) {
            logger.error("Cannot reduce size of data disk "
                    + vdDataDisk.getDeviceInfo().getLabel());
            logger.error("Current disk space: "
                    + vdDataDisk.getCapacityInKB() + " new disk space: "
                    + newDiskSpace);
            throw new Exception(Messages
                    .getAll("error_invalid_diskspacereduction").get(0)
                    .getText());
        } else if (newDiskSpace > vdDataDisk.getCapacityInKB()) {
            vdDataDisk.setCapacityInKB(newDiskSpace);
            VirtualDeviceConfigSpec vmDeviceSpec = new VirtualDeviceConfigSpec();
            vmDeviceSpec
                    .setOperation(VirtualDeviceConfigSpecOperation.EDIT);
            vmDeviceSpec.setDevice(vdDataDisk);

            vmConfigSpec.getDeviceChange().add(vmDeviceSpec);
        } else {
            logger.debug("Data disk size has not been changed. "
                    + newDiskSpace + " KB");
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:34,代码来源:DiskManager.java


示例20: configureSystemDisk

import com.vmware.vim25.VirtualMachineConfigSpec; //导入依赖的package包/类
private void configureSystemDisk(VirtualMachineConfigSpec vmConfigSpec,
        long systemDiskMB, VirtualDisk vdSystemDisk) throws Exception {
    if (systemDiskMB > 0) {
        long newDiskSpace = systemDiskMB * 1024;
        if (newDiskSpace < vdSystemDisk.getCapacityInKB()) {
            logger.error("Cannot reduce size of system disk \""
                    + vdSystemDisk.getDeviceInfo().getLabel() + "\"");
            logger.error("Current disk size: "
                    + vdSystemDisk.getCapacityInKB() + " new disk space: "
                    + newDiskSpace);

            throw new Exception(Messages
                    .getAll("error_invalid_diskspacereduction").get(0)
                    .getText());
        } else if (newDiskSpace > vdSystemDisk.getCapacityInKB()) {
            logger.info("reconfigureDisks() extend system disk space to "
                    + newDiskSpace + " ("
                    + vdSystemDisk.getDeviceInfo().getLabel() + ")");
            vdSystemDisk.setCapacityInKB(newDiskSpace);
            VirtualDeviceConfigSpec vmDeviceSpec = new VirtualDeviceConfigSpec();
            vmDeviceSpec
                    .setOperation(VirtualDeviceConfigSpecOperation.EDIT);
            vmDeviceSpec.setDevice(vdSystemDisk);
            vmConfigSpec.getDeviceChange().add(vmDeviceSpec);
        } else {
            logger.debug("System disk size has not been changed. "
                    + newDiskSpace + " KB");
        }
    } else {
        logger.error("Reconfiguration of system disk not possible because system disk size is not defined.");
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:33,代码来源:DiskManager.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java FetchData类代码示例发布时间:2022-05-22
下一篇:
Java HTMLElementName类代码示例发布时间: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