Java 类com.vmware.vim25.VirtualIDEController 实例源码

项目:vijava    文件:VirtualMachineDeviceManager.java   
private static int getMaxNodesPerControllerOfType(VirtualController controller) 
{
  int count = 0;

  if ( VirtualSCSIController.class.isInstance(controller) )
  {
    // The actual device nodes of SCSI controller are 16
    // but one of them is reserved for the controller itself
    // so this means that the maximum free nodes are 15.
    count = 16;
  }
  else if (VirtualIDEController.class.isInstance(controller)) 
  {
    count = 2;
  }
  else 
  {
    throw new RuntimeException("Unknown controller type - " + controller.getDeviceInfo().getLabel());
  }
  return count;
}
项目:cloudstack    文件:VirtualMachineMO.java   
public int getIDEControllerKey(int ideUnitNumber) throws Exception {
    List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().
        getDynamicProperty(_mor, "config.hardware.device");

    int requiredIdeController = ideUnitNumber / VmwareHelper.MAX_IDE_CONTROLLER_COUNT;

    int ideControllerCount = 0;
    if(devices != null && devices.size() > 0) {
        for(VirtualDevice device : devices) {
            if(device instanceof VirtualIDEController) {
                if (ideControllerCount == requiredIdeController) {
                    return ((VirtualIDEController)device).getKey();
                }
                ideControllerCount++;
            }
        }
    }

    assert(false);
    throw new Exception("IDE Controller Not Found");
}
项目:photon-model    文件:ClientUtils.java   
public static VirtualIDEController getFirstIdeController(ArrayOfVirtualDevice devices) {
    for (VirtualDevice dev : devices.getVirtualDevice()) {
        if (dev instanceof VirtualIDEController) {
            return (VirtualIDEController) dev;
        }
    }

    throw new IllegalStateException("No IDE controller found");
}
项目:vijava    文件:VmCdOp.java   
static VirtualDevice getIDEController(VirtualMachine vm) 
  throws Exception 
{
  VirtualDevice ideController = null;
  VirtualDevice [] defaultDevices = getDefaultDevices(vm);
  for (int i = 0; i < defaultDevices.length; i++) 
  {
    if (defaultDevices[i] instanceof VirtualIDEController) 
    {
      ideController = defaultDevices[i];             
      break;
    }
  }
  return ideController;
}
项目:cloudstack    文件:VirtualMachineMO.java   
private String getDeviceBusName(List<VirtualDevice> allDevices, VirtualDevice theDevice) throws Exception {
    for (VirtualDevice device : allDevices) {
        if (device.getKey() == theDevice.getControllerKey().intValue()) {
            if (device instanceof VirtualIDEController) {
                return String.format("ide%d:%d", ((VirtualIDEController)device).getBusNumber(), theDevice.getUnitNumber());
            } else if (device instanceof VirtualSCSIController) {
                return String.format("scsi%d:%d", ((VirtualSCSIController)device).getBusNumber(), theDevice.getUnitNumber());
            } else {
                throw new Exception("Device controller is not supported yet");
            }
        }
    }
    throw new Exception("Unable to find device controller");
}
项目:cloudstack    文件:VirtualMachineMO.java   
public int tryGetIDEDeviceControllerKey() throws Exception {
    List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");

    if (devices != null && devices.size() > 0) {
        for (VirtualDevice device : devices) {
            if (device instanceof VirtualIDEController) {
                return ((VirtualIDEController)device).getKey();
            }
        }
    }

    return -1;
}
项目:cloudstack    文件:VirtualMachineMO.java   
public int getIDEDeviceControllerKey() throws Exception {
    List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");

    if (devices != null && devices.size() > 0) {
        for (VirtualDevice device : devices) {
            if (device instanceof VirtualIDEController) {
                return ((VirtualIDEController)device).getKey();
            }
        }
    }

    assert (false);
    throw new Exception("IDE Controller Not Found");
}
项目:cloudstack    文件:VirtualMachineMO.java   
public int getNumberOfIDEDevices() throws Exception {
    int ideDeviceCount = 0;
    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 VirtualIDEController) {
                ideDeviceCount += ((VirtualIDEController)device).getDevice().size();
            }
        }
    }
    return ideDeviceCount;
}
项目:cloudstack    文件:VMwareUtil.java   
public static String getDeviceBusName(List<VirtualDevice> allDevices, VirtualDisk disk) throws Exception {
    for (VirtualDevice device : allDevices) {
        if (device.getKey() == disk.getControllerKey()) {
            if (device instanceof VirtualIDEController) {
                return String.format("ide%d:%d", ((VirtualIDEController)device).getBusNumber(), disk.getUnitNumber());
            } else if (device instanceof VirtualSCSIController) {
                return String.format("scsi%d:%d", ((VirtualSCSIController)device).getBusNumber(), disk.getUnitNumber());
            } else {
                throw new Exception("The device controller is not supported.");
            }
        }
    }

    throw new Exception("The device controller could not be located.");
}