Esempio n. 1
0
 @Override
 protected void verify(Disk model, Disk transform) {
   assertNotNull(transform);
   assertEquals(model.getId(), transform.getId());
   assertEquals(model.getImageId(), transform.getImageId());
   assertEquals(model.getFormat(), transform.getFormat());
   assertEquals(model.getInterface(), transform.getInterface());
   assertEquals(model.isActive(), transform.isActive());
   assertEquals(model.isReadOnly(), transform.isReadOnly());
   assertEquals(model.getDescription(), transform.getDescription());
   assertEquals(model.getLogicalName(), transform.getLogicalName());
   assertNotNull(model.getSnapshot());
   assertEquals(model.getSnapshot().getId(), transform.getSnapshot().getId());
   assertEquals(
       "unexpected status", model.getStatus().getState(), transform.getStatus().getState());
   assertEquals("unexpected sparse", model.isSparse(), transform.isSparse());
   assertEquals("unexpected bootable", model.isBootable(), transform.isBootable());
   assertEquals(
       "unexpected propagate errors", model.isPropagateErrors(), transform.isPropagateErrors());
   assertEquals(
       "unexpected wipe after delete", model.isWipeAfterDelete(), transform.isWipeAfterDelete());
   assertEquals("unexpected shareable", model.isShareable(), transform.isShareable());
 }
  private Response attachDiskToVm(Disk disk) {
    boolean isDiskActive = BooleanUtils.toBooleanDefaultIfNull(disk.isActive(), false);
    boolean isDiskReadOnly = BooleanUtils.toBooleanDefaultIfNull(disk.isReadOnly(), false);
    AttachDetachVmDiskParameters params =
        new AttachDetachVmDiskParameters(
            parentId,
            Guid.createGuidFromStringDefaultEmpty(disk.getId()),
            isDiskActive,
            isDiskReadOnly);

    if (disk.isSetSnapshot()) {
      validateParameters(disk, "snapshot.id");
      params.setSnapshotId(asGuid(disk.getSnapshot().getId()));
    }

    return performAction(VdcActionType.AttachDiskToVm, params);
  }
 @Override
 protected VdcActionParametersBase getAddParameters(
     org.ovirt.engine.core.common.businessentities.Disk entity, Disk disk) {
   AddDiskParameters parameters = new AddDiskParameters(parentId, entity);
   if (disk.isSetStorageDomains()
       && disk.getStorageDomains().getStorageDomains().get(0).isSetId()) {
     parameters.setStorageDomainId(
         asGuid(disk.getStorageDomains().getStorageDomains().get(0).getId()));
   } else if (disk.isSetStorageDomains()
       && disk.getStorageDomains().getStorageDomains().get(0).isSetName()) {
     Guid storageDomainId =
         getStorageDomainId(disk.getStorageDomains().getStorageDomains().get(0).getName());
     if (storageDomainId == null) {
       notFound(StorageDomain.class);
     } else {
       parameters.setStorageDomainId(storageDomainId);
     }
   }
   if (disk.isSetActive()) {
     parameters.setPlugDiskToVm(disk.isActive());
   }
   return parameters;
 }