Vered Volansky has uploaded a new change for review.

Change subject: core: cleanup-removed member parameters in methods
......................................................................

core: cleanup-removed member parameters in methods

In RunVmValidator - data members were passed to methods, while they were
the only arguments sent to those methods. Passing them is redundant and
now removed. Now the data members are used directly in the methods.

Change-Id: Id04ff827d1202e8e6207d2ca13cf7d337942153d
Signed-off-by: Vered Volansky <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java
1 file changed, 31 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/03/33803/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java
index c6e4eb6..5a5f73d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java
@@ -104,28 +104,28 @@
         if (vm.getStatus() == VMStatus.Paused) {
             // if the VM is paused, we should only check the VDS status
             // as the rest of the checks were already checked before
-            return validate(validateVdsStatus(vm), messages);
+            return validate(validateVdsStatus(), messages);
         }
 
         return
-                validateVmProperties(vm, runVmParam.getCustomProperties(), 
messages) &&
-                validate(validateBootSequence(vm, 
runVmParam.getBootSequence(), getVmDisks(), activeIsoDomainId), messages) &&
+                validateVmProperties(runVmParam.getCustomProperties(), 
messages) &&
+                validate(validateBootSequence(runVmParam.getBootSequence(), 
getVmDisks()), messages) &&
                 validate(validateDisplayType(), messages) &&
                 validate(new VmValidator(vm).vmNotLocked(), messages) &&
                 
validate(getSnapshotValidator().vmNotDuringSnapshot(vm.getId()), messages) &&
-                validate(validateVmStatusUsingMatrix(vm), messages) &&
-                validate(validateStoragePoolUp(vm, storagePool, 
getVmImageDisks()), messages) &&
-                validate(validateIsoPath(vm, runVmParam.getDiskPath(), 
runVmParam.getFloppyPath(), activeIsoDomainId), messages)  &&
-                validate(vmDuringInitialization(vm), messages) &&
-                validate(validateStatelessVm(vm, getVmDisks(), 
runVmParam.getRunAsStateless()), messages) &&
-                validate(validateStorageDomains(vm, isInternalExecution, 
getVmImageDisks()), messages) &&
-                validate(validateImagesForRunVm(vm, getVmImageDisks()), 
messages) &&
-                validate(validateMemorySize(vm), messages) &&
+                validate(validateVmStatusUsingMatrix(), messages) &&
+                validate(validateStoragePoolUp(storagePool, 
getVmImageDisks()), messages) &&
+                validate(validateIsoPath(runVmParam.getDiskPath(), 
runVmParam.getFloppyPath()), messages)  &&
+                validate(vmDuringInitialization(), messages) &&
+                validate(validateStatelessVm(getVmDisks(), 
runVmParam.getRunAsStateless()), messages) &&
+                validate(validateStorageDomains(getVmImageDisks()), messages) 
&&
+                validate(validateImagesForRunVm(getVmImageDisks()), messages) 
&&
+                validate(validateMemorySize(), messages) &&
                 SchedulingManager.getInstance().canSchedule(
                         vdsGroup, vm, vdsBlackList, vdsWhiteList, destVds, 
messages);
     }
 
-    protected ValidationResult validateMemorySize(VM vm) {
+    protected ValidationResult validateMemorySize() {
         final ConfigValues configKey = 
getOsRepository().get64bitOss().contains(vm.getOs())
                 ? ConfigValues.VM64BitMaxMemorySizeInMB
                 : ConfigValues.VM32BitMaxMemorySizeInMB;
@@ -141,12 +141,12 @@
      * @return true if all VM network interfaces are valid
      */
     public ValidationResult validateNetworkInterfaces() {
-        ValidationResult validationResult = validateInterfacesConfigured(vm);
+        ValidationResult validationResult = validateInterfacesConfigured();
         if (!validationResult.isValid()) {
             return validationResult;
         }
 
-        validationResult = validateInterfacesAttachedToClusterNetworks(vm, 
getClusterNetworksNames(), getInterfaceNetworkNames());
+        validationResult = 
validateInterfacesAttachedToClusterNetworks(getClusterNetworksNames(), 
getInterfaceNetworkNames());
         if (!validationResult.isValid()) {
             return validationResult;
         }
@@ -174,7 +174,7 @@
         return ValidationResult.VALID;
     }
 
-    protected boolean validateVmProperties(VM vm, String 
runOnceCustomProperties, List<String> messages) {
+    protected boolean validateVmProperties(String runOnceCustomProperties, 
List<String> messages) {
         String customProperties = runOnceCustomProperties != null ?
                 runOnceCustomProperties : vm.getCustomProperties();
         List<ValidationError> validationErrors =
@@ -190,8 +190,8 @@
         return true;
     }
 
-    protected ValidationResult validateBootSequence(VM vm, BootSequence 
runOnceBootSequence,
-            List<Disk> vmDisks, Guid activeIsoDomainId) {
+    protected ValidationResult validateBootSequence(BootSequence 
runOnceBootSequence,
+            List<Disk> vmDisks) {
         BootSequence bootSequence = runOnceBootSequence != null ?
                 runOnceBootSequence : vm.getDefaultBootSequence();
         // Block from running a VM with no HDD when its first boot device is
@@ -219,16 +219,11 @@
     /**
      * Check storage domains. Storage domain status and disk space are checked 
only for non-HA VMs.
      *
-     * @param vm
-     *            The VM to run
-     * @param isInternalExecution
-     *            Command is internal?
      * @param vmImages
      *            The VM's image disks
      * @return <code>true</code> if the VM can be run, <code>false</code> if 
not
      */
-    protected ValidationResult validateStorageDomains(VM vm, boolean 
isInternalExecution,
-            List<DiskImage> vmImages) {
+    protected ValidationResult validateStorageDomains(List<DiskImage> 
vmImages) {
         if (vmImages.isEmpty()) {
             return ValidationResult.VALID;
         }
@@ -256,7 +251,7 @@
     /**
      * Check isValid only if VM is not HA VM
      */
-    protected ValidationResult validateImagesForRunVm(VM vm, List<DiskImage> 
vmDisks) {
+    protected ValidationResult validateImagesForRunVm(List<DiskImage> vmDisks) 
{
         if (vmDisks.isEmpty()) {
             return ValidationResult.VALID;
         }
@@ -265,7 +260,7 @@
                 new DiskImagesValidator(vmDisks).diskImagesNotLocked() : 
ValidationResult.VALID;
     }
 
-    protected ValidationResult validateIsoPath(VM vm, String diskPath, String 
floppyPath, Guid activeIsoDomainId) {
+    protected ValidationResult validateIsoPath(String diskPath, String 
floppyPath) {
         if (vm.isAutoStartup()) {
             return ValidationResult.VALID;
         }
@@ -278,18 +273,18 @@
             return new 
ValidationResult(VdcBllMessages.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO);
         }
 
-        if (!StringUtils.isEmpty(diskPath) && !isRepoImageExists(diskPath, 
activeIsoDomainId, ImageFileType.ISO)) {
+        if (!StringUtils.isEmpty(diskPath) && !isRepoImageExists(diskPath, 
ImageFileType.ISO)) {
             return new 
ValidationResult(VdcBllMessages.ERROR_CANNOT_FIND_ISO_IMAGE_PATH);
         }
 
-        if (!StringUtils.isEmpty(floppyPath) && !isRepoImageExists(floppyPath, 
activeIsoDomainId, ImageFileType.Floppy)) {
+        if (!StringUtils.isEmpty(floppyPath) && !isRepoImageExists(floppyPath, 
ImageFileType.Floppy)) {
             return new 
ValidationResult(VdcBllMessages.ERROR_CANNOT_FIND_FLOPPY_IMAGE_PATH);
         }
 
         return ValidationResult.VALID;
     }
 
-    protected ValidationResult vmDuringInitialization(VM vm) {
+    protected ValidationResult vmDuringInitialization() {
         if (vm.isRunning() || vm.getStatus() == VMStatus.NotResponding ||
                 isVmDuringInitiating(vm)) {
             return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING);
@@ -298,7 +293,7 @@
         return ValidationResult.VALID;
     }
 
-    protected ValidationResult validateVdsStatus(VM vm) {
+    protected ValidationResult validateVdsStatus() {
         if (vm.getStatus() == VMStatus.Paused && vm.getRunOnVds() != null &&
                 getVdsDynamic(vm.getRunOnVds()).getStatus() != VDSStatus.Up) {
             return new ValidationResult(
@@ -309,7 +304,7 @@
         return ValidationResult.VALID;
     }
 
-    protected ValidationResult validateStatelessVm(VM vm, List<Disk> 
plugDisks, Boolean stateless) {
+    protected ValidationResult validateStatelessVm(List<Disk> plugDisks, 
Boolean stateless) {
         // if the VM is not stateless, there is nothing to check
         if (stateless != null ? !stateless : !vm.isStateless()) {
             return ValidationResult.VALID;
@@ -333,7 +328,7 @@
         return ValidationResult.VALID;
     }
 
-    protected ValidationResult validateVmStatusUsingMatrix(VM vm) {
+    protected ValidationResult validateVmStatusUsingMatrix() {
         if (!VdcActionUtils.canExecute(Arrays.asList(vm), VM.class,
                 VdcActionType.RunVm)) {
             return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL, 
LocalizedVmStatus.from(vm.getStatus()));
@@ -360,7 +355,7 @@
         return ValidationResult.VALID;
     }
 
-    protected ValidationResult validateStoragePoolUp(VM vm, StoragePool 
storagePool, List<DiskImage> vmImages) {
+    protected ValidationResult validateStoragePoolUp(StoragePool storagePool, 
List<DiskImage> vmImages) {
         if (vmImages.isEmpty() || vm.isAutoStartup()) {
             return ValidationResult.VALID;
         }
@@ -375,7 +370,7 @@
      * @return true if all VM network interfaces are attached to existing 
cluster networks, or to no network (when
      *         network linking is supported).
      */
-    protected ValidationResult validateInterfacesConfigured(VM vm) {
+    protected ValidationResult validateInterfacesConfigured() {
         for (VmNetworkInterface nic : vm.getInterfaces()) {
             if (nic.getVnicProfileId() == null) {
                 return 
FeatureSupported.networkLinking(vm.getVdsGroupCompatibilityVersion()) ?
@@ -392,7 +387,7 @@
      *            VM interface network names
      * @return true if all VM network interfaces are attached to existing 
cluster networks
      */
-    protected ValidationResult validateInterfacesAttachedToClusterNetworks(VM 
vm,
+    protected ValidationResult validateInterfacesAttachedToClusterNetworks(
             final Set<String> clusterNetworkNames, final Set<String> 
interfaceNetworkNames) {
 
         Set<String> result = new HashSet<>(interfaceNetworkNames);
@@ -473,7 +468,8 @@
         return DbFacade.getInstance().getDiskDao();
     }
 
-    private boolean isRepoImageExists(String repoImagePath, Guid 
storageDomainId, ImageFileType imageFileType) {
+    private boolean isRepoImageExists(String repoImagePath, ImageFileType 
imageFileType) {
+        Guid storageDomainId = activeIsoDomainId;
         VdcQueryReturnValue ret = getBackend().runInternalQuery(
                 VdcQueryType.GetImagesList,
                 new GetImagesListParameters(storageDomainId, imageFileType));


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id04ff827d1202e8e6207d2ca13cf7d337942153d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vered Volansky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to