Allon Mureinik has posted comments on this change.

Change subject: core: handle 'source' domains when adding a vm from template
......................................................................


Patch Set 2: Code-Review-1

(4 comments)

http://gerrit.ovirt.org/#/c/26262/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java:

Line 422:         if (!verifySourceDomains() || 
!buildAndCheckDestStorageDomains()) {
Line 423:             return false;
Line 424:         }
Line 425: 
Line 426:         chooseDisksSourceDomains();
I don't think the CDA is the best place to decide such behavior...
Line 427: 
Line 428:         // otherwise..
Line 429:         storageToDisksMap =
Line 430:                 
ImagesHandler.buildStorageToDiskMap(getImagesToCheckDestinationStorageDomains(),


http://gerrit.ovirt.org/#/c/26262/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskImagesValidator.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/DiskImagesValidator.java:

Line 188:         return ValidationResult.VALID;
Line 189:     }
Line 190: 
Line 191:     /**
Line 192:      * checks that the given disks has no derived disks on the given 
storage domain. if the provided storage domain id
Capitals at the beginning of sentences.
Line 193:      * is null, it will be checked that there are no derived disks on 
any storage domain.
Line 194:      */
Line 195:     public Pair<ValidationResult, Map<Guid, Set<Guid>>> 
diskImagesOnAnyApplicableDomains(Map<Guid, StorageDomain> storageDomains,
Line 196:             Set<StorageDomainStatus> applicableStatuses,


Line 193:      * is null, it will be checked that there are no derived disks on 
any storage domain.
Line 194:      */
Line 195:     public Pair<ValidationResult, Map<Guid, Set<Guid>>> 
diskImagesOnAnyApplicableDomains(Map<Guid, StorageDomain> storageDomains,
Line 196:             Set<StorageDomainStatus> applicableStatuses,
Line 197:             VdcBllMessages message) {
There is too much logic here - the fact that you need to return a pair proves 
it.

This method should move to ImagesHandler and return just the Map.
Once you have that, you can easily validate it (perhaps even with a method 
here).
Line 198: 
Line 199:         List<String> disksInfo = new LinkedList<>();
Line 200:         Map<Guid, Set<Guid>> legitDomainsForDisks = new HashMap<>();
Line 201: 


Line 205:             for (Guid storageDomainID : diskImage.getStorageIds()) {
Line 206:                 StorageDomain domain = 
storageDomains.get(storageDomainID);
Line 207: 
Line 208:                 if (domain == null || domain.getStatus() == null) {
Line 209:                     throw new RuntimeException("Wrong data provided 
to validator");
Seriously?
Line 210:                 }
Line 211: 
Line 212:                 if (applicableStatuses.contains(domain.getStatus())) {
Line 213:                     MultiValueMapUtils.addToMap(diskImage.getId(),


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8d02cfded41a3588dc944d9dfcd5a3eec88c45ab
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <lara...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Tal Nisan <tni...@redhat.com>
Gerrit-Reviewer: Vered Volansky <vvola...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to