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


Java VirtualDevice.getBacking方法代码示例

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


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

示例1: 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

示例2: 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

示例3: getVirtualMachineMacAddress

import com.vmware.vim25.VirtualDevice; //导入方法依赖的package包/类
protected static String getVirtualMachineMacAddress(
        VirtualMachineConfigInfo vmConfigInfo,
        DistributedVirtualPortgroup portGroup) {
    VirtualDevice devices[] = vmConfigInfo.getHardware().getDevice();
    for (VirtualDevice device : devices) {
        // Assuming only one interface
        if (device instanceof VirtualEthernetCard) {
            VirtualDeviceBackingInfo backingInfo =
                    device.getBacking();

            if (backingInfo == null)
                continue;

            // Is it backed by the distributed virtual port group?
            if (backingInfo instanceof
                VirtualEthernetCardDistributedVirtualPortBackingInfo) {
                VirtualEthernetCardDistributedVirtualPortBackingInfo
                dvpBackingInfo =
                (VirtualEthernetCardDistributedVirtualPortBackingInfo)
                backingInfo;
                if ((dvpBackingInfo.getPort() == null) ||
                    (dvpBackingInfo.getPort().getPortgroupKey() == null))
                    continue;

                if (dvpBackingInfo.getPort().getPortgroupKey().
                        equals(portGroup.getKey())) {
                    String vmMac = ((VirtualEthernetCard) device).
                            getMacAddress();
                    return vmMac;
                }
            }
        }
    }
    s_logger.error("dvPg: " + portGroup.getName() + " vmConfig: " +
            vmConfigInfo + " MAC Address NOT found");
    return null;
}
 
开发者ID:Juniper,项目名称:contrail-vcenter-plugin,代码行数:38,代码来源:VCenterDB.java

示例4: getIsoDevice

import com.vmware.vim25.VirtualDevice; //导入方法依赖的package包/类
public VirtualDevice getIsoDevice(String filename) 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(device instanceof VirtualCdrom && device.getBacking() instanceof VirtualCdromIsoBackingInfo &&
                    ((VirtualCdromIsoBackingInfo)device.getBacking()).getFileName().equals(filename)) {
                return device;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:14,代码来源:VirtualMachineMO.java

示例5: attachDisk

import com.vmware.vim25.VirtualDevice; //导入方法依赖的package包/类
public void attachDisk(String[] vmdkDatastorePathChain, ManagedObjectReference morDs, String diskController) throws Exception {

        if(s_logger.isTraceEnabled())
            s_logger.trace("vCenter API trace - attachDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: "
                            + new Gson().toJson(vmdkDatastorePathChain) + ", datastore: " + morDs.getValue());
        int controllerKey = 0;
        int unitNumber = 0;

        if (DiskControllerType.getType(diskController) == DiskControllerType.ide) {
            // IDE virtual disk cannot be added if VM is running
            if (getPowerState() == VirtualMachinePowerState.POWERED_ON) {
                throw new Exception("Adding a virtual disk over IDE controller is not supported while VM is running in VMware hypervisor. Please re-try when VM is not running.");
            }
            // Get next available unit number and controller key
            int ideDeviceCount = getNumberOfIDEDevices();
            if (ideDeviceCount >= VmwareHelper.MAX_IDE_CONTROLLER_COUNT * VmwareHelper.MAX_ALLOWED_DEVICES_IDE_CONTROLLER) {
                throw new Exception("Maximum limit of  devices supported on IDE controllers [" + VmwareHelper.MAX_IDE_CONTROLLER_COUNT
                        * VmwareHelper.MAX_ALLOWED_DEVICES_IDE_CONTROLLER + "] is reached.");
            }
            controllerKey = getIDEControllerKey(ideDeviceCount);
            unitNumber = getFreeUnitNumberOnIDEController(controllerKey);
        } else {
            controllerKey = getScsiDiskControllerKey(diskController);
            unitNumber = -1;
        }
        synchronized (_mor.getValue().intern()) {
            VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, null, controllerKey, vmdkDatastorePathChain, morDs, unitNumber, 1);
            controllerKey = newDisk.getControllerKey();
            unitNumber = newDisk.getUnitNumber();
            VirtualDiskFlatVer2BackingInfo backingInfo = (VirtualDiskFlatVer2BackingInfo)newDisk.getBacking();
            String vmdkFileName = backingInfo.getFileName();
            DiskControllerType diskControllerType = DiskControllerType.getType(diskController);
            VmdkAdapterType vmdkAdapterType = VmdkAdapterType.getAdapterType(diskControllerType);
            if (vmdkAdapterType == VmdkAdapterType.none) {
                String message = "Failed to attach disk due to invalid vmdk adapter type for vmdk file [" +
                    vmdkFileName + "] with controller : " + diskControllerType;
                s_logger.debug(message);
                throw new Exception(message);
            }
            updateVmdkAdapter(vmdkFileName, vmdkAdapterType.toString());
            VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
            VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();

            deviceConfigSpec.setDevice(newDisk);
            deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);

            reConfigSpec.getDeviceChange().add(deviceConfigSpec);

            ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
            boolean result = _context.getVimClient().waitForTask(morTask);

            if (!result) {
                if (s_logger.isTraceEnabled())
                    s_logger.trace("vCenter API trace - attachDisk() done(failed)");
                throw new Exception("Failed to attach disk due to " + TaskMO.getTaskFailureInfo(_context, morTask));
            }

            _context.waitForTaskProgressDone(morTask);
        }

        if(s_logger.isTraceEnabled())
            s_logger.trace("vCenter API trace - attachDisk() done(successfully)");
    }
 
开发者ID:apache,项目名称:cloudstack,代码行数:64,代码来源:VirtualMachineMO.java

示例6: detachAllDisksExcept

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

    VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
    List<String> detachedDiskFiles = new ArrayList<String>();

    for (VirtualDevice device : devices) {
        if (device instanceof VirtualDisk) {
            VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();

            VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)device.getBacking();

            DatastoreFile dsBackingFile = new DatastoreFile(diskBackingInfo.getFileName());
            String backingBaseName = dsBackingFile.getFileBaseName();
            String deviceNumbering = getDeviceBusName(devices, device);
            if (backingBaseName.equalsIgnoreCase(vmdkBaseName) || (deviceBusName != null && deviceBusName.equals(deviceNumbering))) {
                continue;
            } else {
                s_logger.info("Detach " + diskBackingInfo.getFileName() + " from " + getName());

                detachedDiskFiles.add(diskBackingInfo.getFileName());

                deviceConfigSpec.setDevice(device);
                deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.REMOVE);

                reConfigSpec.getDeviceChange().add(deviceConfigSpec);
            }
        }
    }

    if (detachedDiskFiles.size() > 0) {
        ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
        boolean result = _context.getVimClient().waitForTask(morTask);
        if (result) {
            _context.waitForTaskProgressDone(morTask);
        } else {
            s_logger.warn("Unable to reconfigure the VM to detach disks");
            throw new Exception("Unable to reconfigure the VM to detach disks");
        }
    }

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


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