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

Java VirtualDevice类代码示例

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

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



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

示例1: createCustomizationAdapterMappings

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
protected List<CustomizationAdapterMapping> createCustomizationAdapterMappings(
        VmwareProcessClient vmwareProcessClient, VirtualMachine machine) {

    List<CustomizationAdapterMapping> nicSettingMap = new ArrayList<CustomizationAdapterMapping>();

    // VirtualEthernetCardを取得
    VirtualMachineConfigInfo configInfo = machine.getConfig();
    for (VirtualDevice device : configInfo.getHardware().getDevice()) {
        if (device instanceof VirtualEthernetCard) {
            VirtualEthernetCard virtualEthernetCard = VirtualEthernetCard.class.cast(device);
            CustomizationAdapterMapping mapping = new CustomizationAdapterMapping();
            CustomizationIPSettings settings = new CustomizationIPSettings();

            // すべてのNICをDHCPにする
            CustomizationDhcpIpGenerator dhcpIp = new CustomizationDhcpIpGenerator();
            settings.setIp(dhcpIp);

            mapping.setMacAddress(virtualEthernetCard.getMacAddress());
            mapping.setAdapter(settings);
            nicSettingMap.add(mapping);
        }
    }

    return nicSettingMap;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:26,代码来源:VmwareCustomizeProcess.java


示例2: replaceNetworkAdapter

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


示例3: reconfigureDisks

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


示例4: getDataDiskKey

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
private int getDataDiskKey() throws Exception {
    List<VirtualDevice> devices = configSpec.getHardware().getDevice();
    int countDisks = 0;
    int key = -1;
    for (VirtualDevice vdInfo : devices) {
        if (vdInfo instanceof VirtualDisk) {
            countDisks++;
            if (countDisks == 2) {
                key = ((VirtualDisk) vdInfo).getKey();
                break;
            }
        }
    }

    return key;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:VM.java


示例5: getDiskSizeInGB

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
private String getDiskSizeInGB(int disk) throws Exception {
    String size = "";
    List<VirtualDevice> devices = configSpec.getHardware().getDevice();
    int countDisks = 0;
    for (VirtualDevice vdInfo : devices) {
        if (vdInfo instanceof VirtualDisk) {
            countDisks++;
            if (countDisks == disk) {
                long gigabyte = ((VirtualDisk) vdInfo).getCapacityInKB()
                        / 1024 / 1024;
                size = Long.toString(gigabyte);
                break;
            }
        }
    }

    return size;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:VM.java


示例6: createCdrom

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


示例7: createFloppy

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


示例8: updateDiskStateFromVirtualDevice

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
/**
 * Capture virtual cdrom attributes in the disk state for reference.
 */
public static void updateDiskStateFromVirtualDevice(VirtualDevice vd, DiskService.DiskState
        disk, VirtualDeviceBackingInfo backing) {
    fillInControllerUnitNumber(disk, vd.getUnitNumber());
    if (backing != null && backing instanceof VirtualDeviceFileBackingInfo) {
        disk.sourceImageReference = VimUtils
                .datastorePathToUri(((VirtualDeviceFileBackingInfo) backing).getFileName());
    }
    disk.status = DiskService.DiskStatus.ATTACHED;
    CustomProperties.of(disk)
            .put(PROVIDER_DISK_UNIQUE_ID, vd.getDeviceInfo().getLabel());
    if (vd.getConnectable() != null) {
        CustomProperties.of(disk)
                .put(DEVICE_CONNECTED, vd.getConnectable().isConnected())
                .put(DEVICE_STATUS, vd.getConnectable().getStatus());
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:ClientUtils.java


示例9: updateDiskLinksAfterProvisionSuccess

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
/**
 * Update the details of the disk into compute state after the provisioning is successful
 */
private void updateDiskLinksAfterProvisionSuccess(ComputeState state, List<VirtualDevice> disks,
        ProvisionContext ctx) {
    ArrayList<String> diskLinks = new ArrayList<>(disks.size());
    // Fill in the disk links from the input to the ComputeState, as it may contain non hdd
    // disk as well. For ex, Floppy or CD-Rom
    ctx.disks.stream().forEach(ds -> diskLinks.add(ds.documentSelfLink));

    // Handle all the HDD disk
    for (VirtualDevice disk : disks) {
        DiskStateExpanded matchedDs = findMatchingDiskState(disk, ctx.disks);

        if (disk.getBacking() instanceof VirtualDeviceFileBackingInfo) {
            handleVirtualDiskUpdate(matchedDs, (VirtualDisk) disk, diskLinks, ctx);
        } else if (disk instanceof VirtualCdrom) {
            handleVirtualDeviceUpdate(matchedDs, DiskType.CDROM, disk, diskLinks, ctx);
        } else if (disk instanceof VirtualFloppy) {
            handleVirtualDeviceUpdate(matchedDs, DiskType.FLOPPY, disk, diskLinks, ctx);
        } else {
            continue;
        }
    }
    state.diskLinks = diskLinks;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:27,代码来源:VSphereAdapterInstanceService.java


示例10: getSCSIController

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
protected VirtualSCSIController getSCSIController(VirtualMachine machine) {
    // 仮想マシンにあるSCSIコントローラのうち、BusNumberが0のものを取得する
    VirtualSCSIController scsiController = null;
    for (VirtualDevice device : machine.getConfig().getHardware().getDevice()) {
        if (device instanceof VirtualSCSIController) {
            VirtualSCSIController scsiController2 = VirtualSCSIController.class.cast(device);
            if (scsiController2.getBusNumber() == 0) {
                scsiController = scsiController2;
                break;
            }
        }
    }

    if (scsiController == null) {
        // SCSIコントローラが見つからない場合
        // TODO: SCSIコントローラを作る?
        throw new AutoException("EPROCESS-000517", 0);
    }

    return scsiController;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:22,代码来源:VmwareProcessClient.java


示例11: getVirtualDisk

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
protected VirtualDisk getVirtualDisk(VirtualMachine machine, Integer scsiId) {
    // SCSIコントローラを取得
    VirtualSCSIController scsiController = getSCSIController(machine);

    // SCSIコントローラとSCSI IDが一致するディスクを取得
    VirtualDisk disk = null;
    for (VirtualDevice device : machine.getConfig().getHardware().getDevice()) {
        if (device instanceof VirtualDisk) {
            VirtualDisk tmpDisk = VirtualDisk.class.cast(device);
            if (tmpDisk.getControllerKey() != null && tmpDisk.getControllerKey().equals(scsiController.getKey())) {
                if (tmpDisk.getUnitNumber() != null && tmpDisk.getUnitNumber().equals(scsiId)) {
                    disk = tmpDisk;
                    break;
                }
            }
        }
    }

    if (disk == null) {
        // VirtualDiskが見つからない場合
        throw new AutoException("EPROCESS-000518", scsiId);
    }

    return disk;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:26,代码来源:VmwareProcessClient.java


示例12: findHardDisk

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
public VirtualDisk findHardDisk(String diskName) 
{
  VirtualDevice[] devices = getAllVirtualDevices();
  
  for(int i=0; i<devices.length; i++) 
  {
    if(devices[i] instanceof VirtualDisk) 
    {
      VirtualDisk vDisk = (VirtualDisk)devices[i];
      if(diskName.equalsIgnoreCase(vDisk.getDeviceInfo().getLabel())) 
      {
        return vDisk;
      }
    }
  }
  return null;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:18,代码来源:VirtualMachineDeviceManager.java


示例13: getVirtualDevicesOfType

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T extends VirtualDevice> List<T> getVirtualDevicesOfType(Class<T> clazz) 
{
  List<T> result = new ArrayList<T>();
  
  VirtualDevice[] devices = getAllVirtualDevices();
  
  for(VirtualDevice dev : devices)
  {
    if(clazz.isInstance(dev)) // dynamic equivalent of instanceof operator
    {
      result.add((T)dev);
    }
  }
  return result;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:17,代码来源:VirtualMachineDeviceManager.java


示例14: getDeviceByBackingFileName

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
public VirtualDevice getDeviceByBackingFileName(String name)
{
  if(name==null)
  {
    throw new IllegalArgumentException("name must not be null!");
  }
    
  VirtualDevice[] devices = this.getAllVirtualDevices(); 

  for(VirtualDevice device : devices)
  {
    VirtualDeviceBackingInfo bi = device.getBacking();
    if(bi instanceof VirtualDeviceFileBackingInfo)
    {
      String fileName = ((VirtualDeviceFileBackingInfo)bi).getFileName();
      if(name.equals(fileName))
        return device;
    }
   }
   return null;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:22,代码来源:VirtualMachineDeviceManager.java


示例15: createAddCdConfigSpec

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


示例16: getDefaultDevices

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
static VirtualDevice[] getDefaultDevices(VirtualMachine vm) 
throws Exception 
{
  VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
  EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser(); 
  ManagedObjectReference hmor = vmRuntimeInfo.getHost();
  VirtualMachineConfigOption cfgOpt = envBrowser.queryConfigOption(null, new HostSystem(vm.getServerConnection(), hmor));
  VirtualDevice[] defaultDevs = null;
  if (cfgOpt != null) 
  {
    defaultDevs = cfgOpt.getDefaultDevice();
    if (defaultDevs == null) 
    {
      throw new Exception("No Datastore found in ComputeResource");
    }
  }
  else
  {
    throw new Exception("No VirtualHardwareInfo found in ComputeResource");
  }
  return defaultDevs;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:23,代码来源:VmCdOp.java


示例17: getNicSpecs

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


示例18: tearDownDevices

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


示例19: getScsiDiskControllerKey

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
public int getScsiDiskControllerKey(String diskController) throws Exception {
    List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().
            getDynamicProperty(_mor, "config.hardware.device");

    if (devices != null && devices.size() > 0) {
        for (VirtualDevice device : devices) {
            if ((DiskControllerType.getType(diskController) == DiskControllerType.lsilogic || DiskControllerType.getType(diskController) == DiskControllerType.scsi)
                    && device instanceof VirtualLsiLogicController) {
                return ((VirtualLsiLogicController)device).getKey();
            } else if ((DiskControllerType.getType(diskController) == DiskControllerType.lsisas1068 || DiskControllerType.getType(diskController) == DiskControllerType.scsi)
                    && device instanceof VirtualLsiLogicSASController) {
                return ((VirtualLsiLogicSASController)device).getKey();
            } else if ((DiskControllerType.getType(diskController) == DiskControllerType.pvscsi || DiskControllerType.getType(diskController) == DiskControllerType.scsi)
                    && device instanceof ParaVirtualSCSIController) {
                return ((ParaVirtualSCSIController)device).getKey();
            } else if ((DiskControllerType.getType(diskController) == DiskControllerType.buslogic || DiskControllerType.getType(diskController) == DiskControllerType.scsi)
                    && device instanceof VirtualBusLogicController) {
                return ((VirtualBusLogicController)device).getKey();
            }
        }
    }

    assert (false);
    throw new IllegalStateException("Scsi disk controller of type " + diskController + " not found among configured devices.");
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:26,代码来源:VirtualMachineMO.java


示例20: getScsiDiskControllerKeyNoException

import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
public int getScsiDiskControllerKeyNoException(String diskController) throws Exception {
    List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().
            getDynamicProperty(_mor, "config.hardware.device");

    if (devices != null && devices.size() > 0) {
        for (VirtualDevice device : devices) {
            if ((DiskControllerType.getType(diskController) == DiskControllerType.lsilogic || DiskControllerType.getType(diskController) == DiskControllerType.scsi)
                    && device instanceof VirtualLsiLogicController) {
                return ((VirtualLsiLogicController)device).getKey();
            } else if ((DiskControllerType.getType(diskController) == DiskControllerType.lsisas1068 || DiskControllerType.getType(diskController) == DiskControllerType.scsi)
                    && device instanceof VirtualLsiLogicSASController) {
                return ((VirtualLsiLogicSASController)device).getKey();
            } else if ((DiskControllerType.getType(diskController) == DiskControllerType.pvscsi || DiskControllerType.getType(diskController) == DiskControllerType.scsi)
                    && device instanceof ParaVirtualSCSIController) {
                return ((ParaVirtualSCSIController)device).getKey();
            } else if ((DiskControllerType.getType(diskController) == DiskControllerType.buslogic || DiskControllerType.getType(diskController) == DiskControllerType.scsi)
                    && device instanceof VirtualBusLogicController) {
                return ((VirtualBusLogicController)device).getKey();
            }
        }
    }
    return -1;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:24,代码来源:VirtualMachineMO.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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