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

项目:cloudstack    文件:VirtualMachineMO.java   
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.");
}
项目:cloudstack    文件:VirtualMachineMO.java   
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;
}
项目:cloudstack    文件:VirtualMachineMO.java   
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.");
        }
    }
}
项目:cloudstack    文件:VirtualMachineMO.java   
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");
        }
    }
}
项目:cloudstack    文件:VirtualMachineMO.java   
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.");
        }
    }
}
项目:photon-model    文件:InstanceClient.java   
private VirtualDevice createScsiController() {
    VirtualLsiLogicController scsiCtrl = new VirtualLsiLogicController();
    scsiCtrl.setBusNumber(0);
    scsiCtrl.setKey(-1);
    scsiCtrl.setSharedBus(VirtualSCSISharing.NO_SHARING);

    return scsiCtrl;
}
项目:vijava    文件:CreateVM.java   
static VirtualDeviceConfigSpec createScsiSpec(int cKey)
{
  VirtualDeviceConfigSpec scsiSpec = 
    new VirtualDeviceConfigSpec();
  scsiSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
  VirtualLsiLogicController scsiCtrl = 
      new VirtualLsiLogicController();
  scsiCtrl.setKey(cKey);
  scsiCtrl.setBusNumber(0);
  scsiCtrl.setSharedBus(VirtualSCSISharing.noSharing);
  scsiSpec.setDevice(scsiCtrl);
  return scsiSpec;
}
项目:cloudstack    文件:VirtualMachineMO.java   
private int getLsiLogicDeviceControllerKeyNoException() 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 VirtualLsiLogicController) {
                return device.getKey();
            }
        }
    }

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

    int scsiControllerCount = 0;
    int busNum = -1;
    DiskControllerType controllerType = DiskControllerType.lsilogic;
    if (devices != null && devices.size() > 0) {
        for (VirtualDevice device : devices) {
            if (device instanceof VirtualSCSIController) {
                scsiControllerCount++;
                int deviceBus = ((VirtualSCSIController)device).getBusNumber();
                if (busNum < deviceBus) {
                    busNum = deviceBus;
                }
                if (device instanceof VirtualLsiLogicController) {
                    controllerType = DiskControllerType.lsilogic;
                } else if (device instanceof VirtualLsiLogicSASController) {
                    controllerType = DiskControllerType.lsisas1068;
                } else if (device instanceof VirtualBusLogicController) {
                    controllerType = DiskControllerType.buslogic;
                } else if (device instanceof ParaVirtualSCSIController) {
                    controllerType = DiskControllerType.pvscsi;
                }
            }
        }
    }

    return new Ternary<Integer, Integer, DiskControllerType>(scsiControllerCount, busNum, controllerType);
}
项目:cloudstack    文件:VirtualMachineMOTest.java   
@Test
public void TestEnsureLsiLogicDeviceControllers() {
    try {
        when(client.getDynamicProperty(any(ManagedObjectReference.class), any(String.class))).thenReturn(getVirtualScSiDeviceList(VirtualLsiLogicController.class));
        vmMo.ensureLsiLogicDeviceControllers(1, 0);
    }
    catch (Exception e) {
        fail("Received exception when success expected: " + e.getMessage());
    }

}
项目:cloudstack    文件:HypervisorHostHelper.java   
public static VirtualMachineMO createWorkerVM(VmwareHypervisorHost hyperHost, DatastoreMO dsMo, String vmName) throws Exception {

        // Allow worker VM to float within cluster so that we will have better chance to
        // create it successfully
        ManagedObjectReference morCluster = hyperHost.getHyperHostCluster();
        if (morCluster != null)
            hyperHost = new ClusterMO(hyperHost.getContext(), morCluster);

        VirtualMachineMO workingVM = null;
        VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
        vmConfig.setName(vmName);
        vmConfig.setMemoryMB((long)4);
        vmConfig.setNumCPUs(1);
        vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.value());
        VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
        fileInfo.setVmPathName(dsMo.getDatastoreRootPath());
        vmConfig.setFiles(fileInfo);

        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 (hyperHost.createVm(vmConfig)) {
            // Ugly work-around, it takes time for newly created VM to appear
            for (int i = 0; i < 10 && workingVM == null; i++) {
                workingVM = hyperHost.findVmOnHyperHost(vmName);

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    s_logger.debug("[ignored] interupted while waiting to config vm.");
                }
            }
        }

        if (workingVM != null) {
            workingVM.setCustomFieldValue(CustomFieldConstants.CLOUD_WORKER, "true");
            String workerTag = String.format("%d-%s", System.currentTimeMillis(), hyperHost.getContext().getStockObject("noderuninfo"));
            workingVM.setCustomFieldValue(CustomFieldConstants.CLOUD_WORKER_TAG, workerTag);
        }
        return workingVM;
    }