private static DiskImage createPreallocDiskImage() {
   DiskImage image = new DiskImage();
   image.setVolumeType(VolumeType.Preallocated);
   image.setDiskInterface(DiskInterface.IDE);
   image.setSizeInGigabytes(5);
   return image;
 }
 /** The following method will create a Shareable DiskImage with a specified format */
 private DiskImage createShareableDisk(VolumeFormat volumeFormat) {
   DiskImage disk = createDiskImage();
   disk.setvolumeFormat(volumeFormat);
   disk.setShareable(true);
   disk.setDiskInterface(DiskInterface.VirtIO);
   return disk;
 }
 /** The following method will create a new DiskImage */
 private DiskImage createDiskImage() {
   DiskImage disk = new DiskImage();
   disk.setId(diskImageGuid);
   disk.setSize(100000L);
   disk.setDiskInterface(DiskInterface.VirtIO);
   disk.setStorageIds(new ArrayList<>(Collections.singleton(sdId)));
   disk.setStoragePoolId(spId);
   disk.setDescription(RandomUtils.instance().nextString(10));
   return disk;
 }
  @Test
  public void testUpdateOvfDiskNotSupported() {
    DiskImage updatedDisk = createDiskImage();
    updatedDisk.setReadOnly(true);
    updatedDisk.setDiskInterface(DiskInterface.IDE);

    DiskImage diskFromDB = createDiskImage();
    diskFromDB.setReadOnly(false);
    diskFromDB.setDiskInterface(DiskInterface.IDE);
    diskFromDB.setContentType(DiskContentType.OVF_STORE);

    when(diskDao.get(diskImageGuid)).thenReturn(diskFromDB);

    initializeCommand(new UpdateVmDiskParameters(vmId, diskImageGuid, updatedDisk));

    when(diskValidator.isDiskUsedAsOvfStore()).thenCallRealMethod();

    CanDoActionTestUtils.runAndAssertCanDoActionFailure(
        command, EngineMessage.ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED);
  }
 private static DiskImage createVirtIoScsiDiskImage() {
   DiskImage image = new DiskImage();
   image.setDiskInterface(DiskInterface.VirtIO_SCSI);
   return image;
 }
 private static DiskImage createShareableDiskImage() {
   DiskImage image = new DiskImage();
   image.setShareable(true);
   image.setDiskInterface(DiskInterface.IDE);
   return image;
 }
 private static DiskImage createDiskImage(long sizeInGigabytes) {
   DiskImage image = new DiskImage();
   image.setSizeInGigabytes(sizeInGigabytes);
   image.setDiskInterface(DiskInterface.IDE);
   return image;
 }
 private static DiskImage createSparseDiskImage() {
   DiskImage image = new DiskImage();
   image.setVolumeType(VolumeType.Sparse);
   image.setDiskInterface(DiskInterface.IDE);
   return image;
 }
 /** @return Valid parameters for the command. */
 private static AddDiskParameters createParameters() {
   DiskImage image = new DiskImage();
   image.setDiskInterface(DiskInterface.IDE);
   AddDiskParameters parameters = new AddDiskParameters(Guid.newGuid(), image);
   return parameters;
 }