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


Java VirtualDeviceConfigSpecOperation类代码示例

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


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

示例1: replaceNetworkAdapter

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

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
public static VirtualDeviceConfigSpec createCdrom(VirtualDevice ideController, int unitNumber) {
    VirtualCdrom cdrom = new VirtualCdrom();

    cdrom.setControllerKey(ideController.getKey());
    cdrom.setUnitNumber(unitNumber);

    VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
    info.setAllowGuestControl(true);
    info.setConnected(true);
    info.setStartConnected(true);
    cdrom.setConnectable(info);

    VirtualCdromAtapiBackingInfo backing = new VirtualCdromAtapiBackingInfo();
    backing.setDeviceName(String.format("cdrom-%d-%d", ideController.getKey(), unitNumber));
    backing.setUseAutoDetect(false);
    cdrom.setBacking(backing);

    VirtualDeviceConfigSpec spec = new VirtualDeviceConfigSpec();
    spec.setDevice(cdrom);
    spec.setOperation(VirtualDeviceConfigSpecOperation.ADD);

    return spec;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:24,代码来源:ClientUtils.java

示例3: createFloppy

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
public static VirtualDeviceConfigSpec createFloppy(VirtualDevice sioController, int unitNumber) {
    VirtualFloppy floppy = new VirtualFloppy();

    floppy.setControllerKey(sioController.getKey());
    floppy.setUnitNumber(unitNumber);

    VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
    info.setAllowGuestControl(true);
    info.setConnected(true);
    info.setStartConnected(true);
    floppy.setConnectable(info);

    VirtualFloppyDeviceBackingInfo backing = new VirtualFloppyDeviceBackingInfo();
    backing.setDeviceName(String.format("floppy-%d", unitNumber));
    floppy.setBacking(backing);

    VirtualDeviceConfigSpec spec = new VirtualDeviceConfigSpec();
    spec.setDevice(floppy);
    spec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
    return spec;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:ClientUtils.java

示例4: reconfigureCdrom

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
private VirtualDeviceConfigSpec reconfigureCdrom(VirtualCdrom vcd) {
    VirtualCdrom cdrom = new VirtualCdrom();

    cdrom.setControllerKey(vcd.getControllerKey());
    cdrom.setKey(vcd.getKey());
    cdrom.setUnitNumber(vcd.getUnitNumber());

    VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
    info.setAllowGuestControl(true);
    info.setConnected(true);
    info.setStartConnected(true);
    cdrom.setConnectable(info);

    cdrom.setBacking(vcd.getBacking());

    VirtualDeviceConfigSpec spec = new VirtualDeviceConfigSpec();
    spec.setDevice(cdrom);
    spec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);

    return spec;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:InstanceClient.java

示例5: detachDiskFromVM

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

示例6: addHardDisk

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

示例7: createRemoveDiskConfigSpec

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
static VirtualDeviceConfigSpec createRemoveDiskConfigSpec(
    VirtualMachine vm, String diskName) throws Exception
{
  VirtualDeviceConfigSpec diskSpec = new VirtualDeviceConfigSpec();      
  VirtualDisk disk = (VirtualDisk) findVirtualDevice(vm.getConfig(), diskName);
    
  if(disk != null)
  {
    diskSpec.setOperation(VirtualDeviceConfigSpecOperation.remove);           
    diskSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.destroy);           
    diskSpec.setDevice(disk);
    return diskSpec;
  }
  else 
  {
    System.out.println("No device found: " + diskName);
    return null;
  }
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:20,代码来源:VmDiskOp.java

示例8: createAddCdConfigSpec

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
static VirtualDeviceConfigSpec createAddCdConfigSpec(VirtualMachine vm, String dsName, String isoName) throws Exception 
{
  VirtualDeviceConfigSpec cdSpec = new VirtualDeviceConfigSpec();

  cdSpec.setOperation(VirtualDeviceConfigSpecOperation.add);         

  VirtualCdrom cdrom =  new VirtualCdrom();
  VirtualCdromIsoBackingInfo cdDeviceBacking = new  VirtualCdromIsoBackingInfo();
  DatastoreSummary ds = findDatastoreSummary(vm, dsName);
  cdDeviceBacking.setDatastore(ds.getDatastore());
  cdDeviceBacking.setFileName("[" + dsName +"] "+ vm.getName() 
      + "/" + isoName + ".iso");
  VirtualDevice vd = getIDEController(vm);          
  cdrom.setBacking(cdDeviceBacking);                    
  cdrom.setControllerKey(vd.getKey());
  cdrom.setUnitNumber(vd.getUnitNumber());
  cdrom.setKey(-1);          

  cdSpec.setDevice(cdrom);

  return cdSpec;          
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:23,代码来源:VmCdOp.java

示例9: createRemoveCdConfigSpec

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
static VirtualDeviceConfigSpec createRemoveCdConfigSpec(VirtualMachine vm, String cdName) throws Exception 
{
  VirtualDeviceConfigSpec cdSpec = new VirtualDeviceConfigSpec();
  cdSpec.setOperation(VirtualDeviceConfigSpecOperation.remove);
  VirtualCdrom cdRemove = (VirtualCdrom)findVirtualDevice(vm.getConfig(), cdName);
  if(cdRemove != null) 
  {
    cdSpec.setDevice(cdRemove);
    return cdSpec;
  }
  else 
  {
    System.out.println("No device available " + cdName);
    return null;
  }
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:17,代码来源:VmCdOp.java

示例10: createRemoveDiskConfigSpec

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
static VirtualDeviceConfigSpec createRemoveDiskConfigSpec(
    VirtualMachineConfigInfo vmConfig, String diskName) 
        throws Exception
{
  VirtualDeviceConfigSpec diskSpec = 
      new VirtualDeviceConfigSpec();      
  VirtualDisk disk = (VirtualDisk) findVirtualDevice(
      vmConfig, diskName);
    
  if(disk != null)
  {
    diskSpec.setOperation(
        VirtualDeviceConfigSpecOperation.remove);    
    // remove the following line can keep the disk file
    diskSpec.setFileOperation(
        VirtualDeviceConfigSpecFileOperation.destroy);           
    diskSpec.setDevice(disk);
    return diskSpec;
  }
  else 
  {
    throw new Exception("No device found: " + diskName);
  }
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:25,代码来源:RemoveVmDisk.java

示例11: createDiskSpec

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
static VirtualDeviceConfigSpec createDiskSpec(String dsName, 
    int cKey, long diskSizeKB, String diskMode)
{
  VirtualDeviceConfigSpec diskSpec = 
      new VirtualDeviceConfigSpec();
  diskSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
  diskSpec.setFileOperation(
      VirtualDeviceConfigSpecFileOperation.create);
  
  VirtualDisk vd = new VirtualDisk();
  vd.setCapacityInKB(diskSizeKB);
  diskSpec.setDevice(vd);
  vd.setKey(0);
  vd.setUnitNumber(0);
  vd.setControllerKey(cKey);

  VirtualDiskFlatVer2BackingInfo diskfileBacking = 
      new VirtualDiskFlatVer2BackingInfo();
  String fileName = "["+ dsName +"]";
  diskfileBacking.setFileName(fileName);
  diskfileBacking.setDiskMode(diskMode);
  diskfileBacking.setThinProvisioned(true);
  vd.setBacking(diskfileBacking);
  return diskSpec;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:26,代码来源:CreateVM.java

示例12: createNicSpec

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
static VirtualDeviceConfigSpec createNicSpec(String netName, 
    String nicName) throws Exception
{
  VirtualDeviceConfigSpec nicSpec = 
      new VirtualDeviceConfigSpec();
  nicSpec.setOperation(VirtualDeviceConfigSpecOperation.add);

  VirtualEthernetCard nic =  new VirtualPCNet32();
  VirtualEthernetCardNetworkBackingInfo nicBacking = 
      new VirtualEthernetCardNetworkBackingInfo();
  nicBacking.setDeviceName(netName);

  Description info = new Description();
  info.setLabel(nicName);
  info.setSummary(netName);
  nic.setDeviceInfo(info);
  
  // type: "generated", "manual", "assigned" by VC
  nic.setAddressType("generated");
  nic.setBacking(nicBacking);
  nic.setKey(0);
 
  nicSpec.setDevice(nic);
  return nicSpec;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:26,代码来源:CreateVM.java

示例13: getNicSpecs

import com.vmware.vim25.VirtualDeviceConfigSpecOperation; //导入依赖的package包/类
VirtualDeviceConfigSpec getNicSpecs(String fileName, List<VirtualDevice> virtualDevicesList,
                                    VirtualDeviceConfigSpecOperation operation, String addressType,
                                    Integer key, String parameter, VmInputs vmInputs) {
    VirtualDeviceConfigSpec nicSpecs = new VirtualDeviceConfigSpec();
    VirtualEthernetCard nic;
    if (Operation.ADD.toString().equalsIgnoreCase(parameter)) {
        nic = getEth(fileName, addressType, key);
        return getNicOpSpec(nicSpecs, operation, nic);
    } else {
        nic = findVirtualDevice(VirtualEthernetCard.class, virtualDevicesList, vmInputs);
        if (nic != null) {
            return getNicOpSpec(nicSpecs, operation, nic);
        }
    }
    throw new RuntimeException("No nic named: [" + vmInputs.getUpdateValue() + "] can be found.");
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:17,代码来源:VmUtils.java

示例14: tearDownDevices

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

示例15: ensurePvScsiDeviceController

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


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