Moti Asayag has posted comments on this change.

Change subject: core: move network validations on run vm to RunVmValidator
......................................................................


Patch Set 1:

(3 comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java
Line 292:         }
Line 293:         return map;
Line 294:     }
Line 295: 
Line 296:     protected NetworkDao getNetworkDAO() {
s/getNetworkDAO/getNetworkDao
Line 297:         return DbFacade.getInstance().getNetworkDao();
Line 298:     }
Line 299: 
Line 300:     protected VdsDAO getVdsDao() {


Line 392: 
Line 393:     /**
Line 394:      * @return true if all VM network interfaces are valid
Line 395:      */
Line 396:     public ValidationResult validateNetworkInterfaces(VM vm) {
I see that all the public method expects a VM as a parameter, why not to create 
it a member of the validator class instead of having this class stateless? 

It seems that the c'tor of RunVmValidator should get a VM on which all of the 
validation should be executed.

This might be a bit out of scope of this patch - so i don't mind that a patch 
will be added as a follow patch to this one.
Line 397:         Map<String, VmNetworkInterface> interfaceNetworkMap = 
Entities.vmInterfacesByNetworkName(vm.getInterfaces());
Line 398:         Set<String> interfaceNetworkNames = 
interfaceNetworkMap.keySet();
Line 399:         List<Network> clusterNetworks = 
getNetworkDAO().getAllForCluster(vm.getVdsGroupId());
Line 400:         Set<String> clusterNetworksNames = 
Entities.objectNames(clusterNetworks);


Line 398:         Set<String> interfaceNetworkNames = 
interfaceNetworkMap.keySet();
Line 399:         List<Network> clusterNetworks = 
getNetworkDAO().getAllForCluster(vm.getVdsGroupId());
Line 400:         Set<String> clusterNetworksNames = 
Entities.objectNames(clusterNetworks);
Line 401: 
Line 402:         ValidationResult validationResult = 
isVmInterfacesConfigured(vm);
the nature of this validator class is to perform specific validations instead a 
exposing a method which encapsulated several validations.
In that way we can test each validation separately.

I'd modify all the private methods which their value is being validated into 
public (preferably with a test).

Originally the method was written like this so the fetched entities from the 
database will be reused, but it shouldn't be a problem storing them in the 
class level and use them from the various methods called by this one.

This method could remain for convenience.
Line 403:         if (!validationResult.isValid()) {
Line 404:             return validationResult;
Line 405:         }
Line 406: 


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I6aff70b45617e90deac826f2a873c1604c9a4241
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <aha...@redhat.com>
Gerrit-Reviewer: Moti Asayag <masa...@redhat.com>
Gerrit-Reviewer: Omer Frenkel <ofren...@redhat.com>
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