Vered Volansky has posted comments on this change.

Change subject: core: Verifying storage space for AddDiskCommand
......................................................................


Patch Set 2:

(10 comments)

....................................................
Commit Message
Line 4: Commit:     Vered Volansky <[email protected]>
Line 5: CommitDate: 2013-12-04 14:31:27 +0200
Line 6: 
Line 7: core: Verifying storage space for AddDiskCommand
Line 8: 
Done
Line 9: Added hasSpaceForNewDisk(s) in StorageDomainValidator. Added test -
Line 10: StorageDomainValidatorFreeSpaceTest.
Line 11: Applied use in AddDiskCommand (former use is buggy).
Line 12: 


Line 8: 
Line 9: Added hasSpaceForNewDisk(s) in StorageDomainValidator. Added test -
Line 10: StorageDomainValidatorFreeSpaceTest.
Line 11: Applied use in AddDiskCommand (former use is buggy).
Line 12: 
Done
Line 13: Bug-url: https://bugzilla.redhat.com/960934
Line 14: Change-Id: I1a33502683ec77fba09efffba1438beb552082f7


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddDiskCommand.java
Line 154
Line 155
Line 156
Line 157
Line 158
Yes, I forgot to get back to that when it finally worked. Amending.


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/StorageDomainValidator.java
Line 80:     private static Integer getLowDiskSpaceThreshold() {
Line 81:         return Config.<Integer> 
GetValue(ConfigValues.FreeSpaceCriticalLowInGB);
Line 82:     }
Line 83: 
Line 84:     public ValidationResult hasSpaceForNewDisks(List<DiskImage> 
diskImages) {
Done
Line 85:         double availableSize = 
storageDomain.getAvailableDiskSizeInBytes();
Line 86:         double totalSizeForDisks = 0.0;
Line 87: 
Line 88:         for (DiskImage diskImage : diskImages) {


Line 87: 
Line 88:         for (DiskImage diskImage : diskImages) {
Line 89:             double diskCapacity = diskImage.getSize();
Line 90:             double sizeForDisk = diskCapacity;
Line 91: 
Agreed, added as a remark for clarity.
Line 92:             if (diskImage.getVolumeFormat() == VolumeFormat.COW) {
Line 93:                 if (storageDomain.getStorageType().isFileDomain()) {
Line 94:                     sizeForDisk = EMPTY_QCOW_HEADER_SIZE;
Line 95:                 } else {


Line 104:         return validateRequiredSpace(availableSize, 
totalSizeForDisks);
Line 105:     }
Line 106: 
Line 107:     public ValidationResult hasSpaceForNewDisk(DiskImage diskImage) {
Line 108:         return 
hasSpaceForNewDisks(Collections.singletonList(diskImage));
Done
Line 109:     }
Line 110: 
Line 111:     private ValidationResult validateRequiredSpace(double 
availableSize, double sizeToCompare) {
Line 112:         if (availableSize >= sizeToCompare) {


Line 113:             return ValidationResult.VALID;
Line 114:         }
Line 115: 
Line 116:         return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_TARGET_STORAGE_DOMAIN,
Line 117:                 storageName());
Agreed
Line 118:     }
Line 119: 
Line 120:     public static Map<StorageDomain, Integer> 
getSpaceRequirementsForStorageDomains(Collection<DiskImage> images,
Line 121:             Map<Guid, StorageDomain> storageDomains, Map<Guid, 
DiskImage> imageToDestinationDomainMap) {


....................................................
File 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddDiskToVmCommandTest.java
Line 365:         
when(snapshotsValidator.vmNotInPreview(any(Guid.class))).thenReturn(ValidationResult.VALID);
Line 366:         return snapshotsValidator;
Line 367:     }
Line 368: 
Line 369:     private StorageDomainValidator 
mockStorageDomainValidatorWithoutSpace() {
Done
Line 370:         StorageDomainValidator storageDomainValidator = 
mock(StorageDomainValidator.class);
Line 371:         
when(storageDomainValidator.hasSpaceForNewDisk(any(DiskImage.class))).thenReturn(
Line 372:                 new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_TARGET_STORAGE_DOMAIN));
Line 373:         
when(storageDomainValidator.isDomainExistAndActive()).thenReturn(ValidationResult.VALID);


Line 373:         
when(storageDomainValidator.isDomainExistAndActive()).thenReturn(ValidationResult.VALID);
Line 374:         return storageDomainValidator;
Line 375:     }
Line 376: 
Line 377:     private StorageDomainValidator 
mockStorageDomainValidatorWithSpace() {
Done
Line 378:         StorageDomainValidator storageDomainValidator = 
mock(StorageDomainValidator.class);
Line 379:         
when(storageDomainValidator.hasSpaceForNewDisk(any(DiskImage.class))).thenReturn(ValidationResult.VALID);
Line 380:         
when(storageDomainValidator.isDomainExistAndActive()).thenReturn(ValidationResult.VALID);
Line 381:         return storageDomainValidator;


....................................................
File 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/StorageDomainValidatorFreeSpaceTest.java
Line 25:     private boolean isValidForNew;
Line 26: 
Line 27:     public StorageDomainValidatorFreeSpaceTest(DiskImage disk,
Line 28:             StorageDomain sd,
Line 29:             boolean isValidForNew) {
Maybe you'd like it better now, checkstyle was fine before as well.
Line 30:         this.disk = disk;
Line 31:         this.sd = sd;
Line 32:         this.isValidForNew = isValidForNew;
Line 33:     }


-- 
To view, visit http://gerrit.ovirt.org/15377
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I1a33502683ec77fba09efffba1438beb552082f7
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vered Volansky <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Liron Ar <[email protected]>
Gerrit-Reviewer: Sergey Gotliv <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: Vered Volansky <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to