コード例 #1
0
  @Test
  public void canAddVmWithVirtioScsiControllerNotSupportedOs() {
    VM vm = createVm();
    AddVmFromTemplateCommand<AddVmParameters> cmd = createVmFromTemplateCommand(vm);
    cluster = createCluster();
    vm.setClusterId(cluster.getId());

    mockStorageDomainDaoGetForStoragePool();
    mockVmTemplateDaoReturnVmTemplate();
    mockVerifyAddVM(cmd);
    mockConfig();
    mockMaxPciSlots();
    mockStorageDomainDaoGetAllStoragesForPool(20);
    mockUninterestingMethods(cmd);
    mockDisplayTypes(vm.getOs());
    mockGraphicsDevices(vm.getId());
    doReturn(true).when(cmd).checkCpuSockets();

    doReturn(cluster).when(cmd).getCluster();
    doReturn(createStoragePool()).when(cmd).getStoragePool();
    cmd.getParameters().setVirtioScsiEnabled(true);
    when(osRepository.isSoundDeviceEnabled(any(Integer.class), any(Version.class)))
        .thenReturn(true);
    when(osRepository.getArchitectureFromOS(any(Integer.class)))
        .thenReturn(ArchitectureType.x86_64);
    when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class)))
        .thenReturn(new ArrayList<>(Collections.singletonList("VirtIO")));
    mockGetAllSnapshots(cmd);

    cmd.initEffectiveCompatibilityVersion();
    ValidateTestUtils.runAndAssertValidateFailure(
        cmd, EngineMessage.ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_DOES_NOT_SUPPORT_VIRTIO_SCSI);
  }
コード例 #2
0
  protected void mockInterfaceList() {
    SimpleDependencyInjector.getInstance().bind(OsRepository.class, osRepository);

    ArrayList<String> diskInterfaces =
        new ArrayList<>(Arrays.asList(new String[] {"IDE", "VirtIO", "VirtIO_SCSI"}));

    when(osRepository.getDiskInterfaces(anyInt(), any(Version.class))).thenReturn(diskInterfaces);
  }
コード例 #3
0
 @Test
 public void isVirtioScsiEnabledDefaultedToTrue() {
   AddVmCommand<AddVmParameters> cmd = setupCanAddVmTests(0);
   Cluster cluster = createCluster();
   doReturn(cluster).when(cmd).getCluster();
   cmd.getParameters().getVm().setClusterId(cluster.getId());
   cmd.initEffectiveCompatibilityVersion();
   when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class)))
       .thenReturn(new ArrayList<>(Collections.singletonList("VirtIO_SCSI")));
   assertTrue(
       "isVirtioScsiEnabled hasn't been defaulted to true on cluster >= 3.3.",
       cmd.isVirtioScsiEnabled());
 }
コード例 #4
0
  @Test
  public void testLunDiskWithSgioCanBeAdded() {
    LunDisk disk = createISCSILunDisk();
    disk.setDiskInterface(DiskInterface.VirtIO_SCSI);
    disk.setSgio(ScsiGenericIO.UNFILTERED);

    AddDiskParameters parameters = createParameters();
    parameters.setDiskInfo(disk);
    initializeCommand(Guid.newGuid(), parameters);

    VM vm = mockVm();
    vm.setVdsGroupCompatibilityVersion(Version.v3_3);
    mockMaxPciSlots();

    when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class)))
        .thenReturn(new ArrayList<>(Arrays.asList("VirtIO_SCSI")));

    DiskValidator diskValidator = spyDiskValidator(disk);
    doReturn(true).when(diskValidator).isVirtioScsiControllerAttached(any(Guid.class));

    mockInterfaceList();

    CanDoActionTestUtils.runAndAssertCanDoActionSuccess(command);
  }
コード例 #5
0
  @Test
  public void testVirtIoScsiNotSupportedByOs() {
    DiskImage disk = createVirtIoScsiDiskImage();
    AddDiskParameters parameters = createParameters();
    parameters.setDiskInfo(disk);

    Guid storageId = Guid.newGuid();
    initializeCommand(storageId, parameters);
    mockStorageDomain(storageId);
    mockStoragePoolIsoMap();

    VM vm = mockVm();
    vm.setVdsGroupCompatibilityVersion(Version.v3_3);
    mockMaxPciSlots();

    when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class)))
        .thenReturn(new ArrayList<>(Arrays.asList("VirtIO")));

    DiskValidator diskValidator = spyDiskValidator(disk);
    doReturn(true).when(diskValidator).isVirtioScsiControllerAttached(any(Guid.class));

    CanDoActionTestUtils.runAndAssertCanDoActionFailure(
        command, EngineMessage.ACTION_TYPE_FAILED_GUEST_OS_VERSION_IS_NOT_SUPPORTED);
  }
コード例 #6
0
  protected void mockInterfaceList() {
    ArrayList<String> diskInterfaces =
        new ArrayList<>(Arrays.asList(new String[] {"IDE", "VirtIO", "VirtIO_SCSI"}));

    when(osRepository.getDiskInterfaces(anyInt(), any(Version.class))).thenReturn(diskInterfaces);
  }