Eli Mesika has uploaded a new change for review.

Change subject: core:we are fencing a host when putting it in...
......................................................................

core:we are fencing a host when putting it in...

we are fencing a host when putting it in maintenance after failed reinstall.

There are two commands that handle Host Maintenance

1) MaintenanceVdsCommand
2) MaintenanceNumberOfVdssCommand

In 1) there is handling in canDoAction that prevents the operation for
InstalledFailed status while this handling is omitted from 2)

I would expect that 2) will contain all validation checks done by 1) and
the best will be that they will call the same validation code. but this
is not the case right now.

To keep my change minimal and risk-less, I will have to copy the
relevant validation block from 1) code to 2)

Change-Id: I1ed67cb14b31597d147cee3a64056e3486f51d26
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=906389
Signed-off-by: Eli Mesika <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
1 file changed, 40 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/13746/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
index d20e0ec..d53df5e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceNumberOfVdssCommand.java
@@ -144,41 +144,51 @@
                 VDS vds = vdssToMaintenance.get(vdsId);
                 if (vds != null) {
                     List<VM> vms = getVmDAO().getAllRunningForVds(vdsId);
-                    if (vms.size() > 0) {
-                        vdsWithRunningVMs.add(vdsId);
+                    if ((vds.getStatus() != VDSStatus.Maintenance) && 
(vds.getStatus() != VDSStatus.NonResponsive)
+                            && (vds.getStatus() != VDSStatus.Up) && 
(vds.getStatus() != VDSStatus.Error)
+                            && (vds.getStatus() != 
VDSStatus.PreparingForMaintenance)
+                            && (vds.getStatus() != VDSStatus.Down)) {
+                        result = false;
+                        
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_VDS_IS_NOT_OPERATIONAL.toString());
                     }
-                    _vdsGroupIds.add(vds.getVdsGroupId());
-                    List<String> nonMigratableVmDescriptionsToFrontEnd = new 
ArrayList<String>();
-                    for (VM vm : vms) {
-                        if (vm.getMigrationSupport() != 
MigrationSupport.MIGRATABLE) {
-                            
nonMigratableVmDescriptionsToFrontEnd.add(vm.getName());
+                    else {
+                        if (vms.size() > 0) {
+                            vdsWithRunningVMs.add(vdsId);
                         }
-                    }
+                        _vdsGroupIds.add(vds.getVdsGroupId());
+                        List<String> nonMigratableVmDescriptionsToFrontEnd = 
new ArrayList<String>();
+                        for (VM vm : vms) {
+                            if (vm.getMigrationSupport() != 
MigrationSupport.MIGRATABLE) {
+                                
nonMigratableVmDescriptionsToFrontEnd.add(vm.getName());
+                            }
+                        }
 
-                    if (nonMigratableVmDescriptionsToFrontEnd.size() > 0) {
-                        hostsWithNonMigratableVms.add(vds.getName());
-                        
nonMigratableVms.addAll(nonMigratableVmDescriptionsToFrontEnd);
+                        if (nonMigratableVmDescriptionsToFrontEnd.size() > 0) {
+                            hostsWithNonMigratableVms.add(vds.getName());
+                            
nonMigratableVms.addAll(nonMigratableVmDescriptionsToFrontEnd);
 
-                        // The non migratable VM names will be comma separated
-                        log.error(String.format("VDS %1$s contains non 
migratable VMs", vdsId));
-                        result = false;
+                            // The non migratable VM names will be comma 
separated
+                            log.error(String.format("VDS %1$s contains non 
migratable VMs", vdsId));
+                            result = false;
 
-                    } else if (vds.getStatus() == VDSStatus.Maintenance) {
-                        
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_VDS_IS_IN_MAINTENANCE);
-                        result = false;
-                    } else if (vds.getSpmStatus() == VdsSpmStatus.Contending) {
-                        
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_SPM_CONTENDING);
-                        result = false;
-                    } else if (vds.getStatus() == VDSStatus.NonResponsive && 
vds.getVmCount() > 0) {
-                        result = false;
-                        hostNotRespondingList.add(vds.getName());
-                    } else if (vds.getStatus() == VDSStatus.NonResponsive && 
vds.getSpmStatus() != VdsSpmStatus.None) {
-                        result = false;
-                        
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_VDS_IS_NOT_RESPONDING_AND_IS_SPM);
-                    } else if (vds.getSpmStatus() == VdsSpmStatus.SPM && 
vds.getStatus() == VDSStatus.Up &&
-                            
getAsyncTaskDao().getAsyncTaskIdsByStoragePoolId(vds.getStoragePoolId()).size() 
> 0) {
-                        
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_SPM_WITH_RUNNING_TASKS);
-                        result = false;
+                        } else if (vds.getStatus() == VDSStatus.Maintenance) {
+                            
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_VDS_IS_IN_MAINTENANCE);
+                            result = false;
+                        } else if (vds.getSpmStatus() == 
VdsSpmStatus.Contending) {
+                            
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_SPM_CONTENDING);
+                            result = false;
+                        } else if (vds.getStatus() == VDSStatus.NonResponsive 
&& vds.getVmCount() > 0) {
+                            result = false;
+                            hostNotRespondingList.add(vds.getName());
+                        } else if (vds.getStatus() == VDSStatus.NonResponsive
+                                && vds.getSpmStatus() != VdsSpmStatus.None) {
+                            result = false;
+                            
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_VDS_IS_NOT_RESPONDING_AND_IS_SPM);
+                        } else if (vds.getSpmStatus() == VdsSpmStatus.SPM && 
vds.getStatus() == VDSStatus.Up &&
+                                
getAsyncTaskDao().getAsyncTaskIdsByStoragePoolId(vds.getStoragePoolId()).size() 
> 0) {
+                            
addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_MAINTENANCE_SPM_WITH_RUNNING_TASKS);
+                            result = false;
+                        }
                     }
                 }
             }


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

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

Reply via email to