Arik Hadas has uploaded a new change for review. Change subject: core: Move status check methods from VM to VMStatus ......................................................................
core: Move status check methods from VM to VMStatus VM class contained methods which only check the value of the status of the VM, to see if it's one of several values that reflect some state of the VM. these methods should be places in VMStatus class (without being static methods) - instance of VMStatus should be able to return whether it reflects certain state of the VM, instead of using the previous methods. While moving those methods to VMStatus, they were renamed such that they'll be less confusing (isStatusUp is not a good name for a method that returns true even if the status is not UP for example). The method VM#isStatusUpOrPausedOrSuspended is removed as it wasn't used anywhere. The method VM#isStatusUp was renamed to VM#isRunning, to describe itself better. Change-Id: I82b4f109751773ff2d46407ccea26ea0be2661f5 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeFloppyCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PauseVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmOperationCommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/GetVmsAndNetworkInterfacesByNetworkIdQuery.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/SetVmStatusVDSCommand.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/resources/ResourcesModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java 20 files changed, 86 insertions(+), 66 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/10795/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java index 63faa1a..e8692e3 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java @@ -3,7 +3,6 @@ import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.action.ChangeDiskCommandParameters; -import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.vdscommands.ChangeDiskVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.compat.backendcompat.Path; @@ -27,7 +26,7 @@ @Override protected boolean canDoAction() { boolean retValue = true; - if (!VM.isStatusUpOrPaused(getVm().getStatus())) { + if (!getVm().getStatus().isStatusOfRunningOrPausedVM()) { setSucceeded(false); retValue = false; addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeFloppyCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeFloppyCommand.java index e227857..a656e1b 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeFloppyCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeFloppyCommand.java @@ -2,7 +2,6 @@ import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.action.ChangeDiskCommandParameters; -import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.vdscommands.ChangeDiskVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.compat.StringHelper; @@ -25,7 +24,7 @@ @Override protected void Perform() { - if (VM.isStatusUpOrPaused(getVm().getStatus())) { + if (getVm().getStatus().isStatusOfRunningOrPausedVM()) { setActionReturnValue(Backend .getInstance() .getResourceManager() diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java index b3be3a8..38de1ca 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java @@ -160,7 +160,7 @@ if (taskGroupSucceeded) { getSnapshotDao().updateStatus(createdSnapshotId, SnapshotStatus.OK); - if (getParameters().getParentCommand() != VdcActionType.RunVm && getVm() != null && getVm().isStatusUp() + if (getParameters().getParentCommand() != VdcActionType.RunVm && getVm() != null && getVm().isRunning() && getVm().getRunOnVds() != null) { performLiveSnapshot(createdSnapshotId); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java index 914c295..138c1cb 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java @@ -13,7 +13,6 @@ import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType; import org.ovirt.engine.core.common.businessentities.StorageDomainType; -import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VolumeFormat; import org.ovirt.engine.core.common.businessentities.VolumeType; @@ -79,7 +78,7 @@ // Set the VM to null, to fetch it again from the DB ,instead from the cache. // We want to get the VM state from the DB, to avoid multi requests for VM hibernation. setVm(null); - if (VM.isStatusUp(getVm().getStatus())) { + if (getVm().getStatus().isStatusOfRunningVM()) { TransactionSupport.executeInNewTransaction( new TransactionMethod<Object>() { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java index 7768c24..19b908f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java @@ -195,7 +195,7 @@ } else if (vm.getStatus() == VMStatus.Paused) { retValue = false; reasons.add(VdcBllMessages.MIGRATE_PAUSED_VM_IS_UNSUPPORTED.name()); - } else if (!VM.isStatusQualifyToMigrate(vm.getStatus())) { + } else if (!vm.getStatus().isStatusOfQualifyToMigrateVM()) { retValue = false; reasons.add(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NOT_RUNNING.name()); } else if (getDestinationVds() != null && getDestinationVds().getstatus() != VDSStatus.Up) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PauseVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PauseVmCommand.java index b69c166..38f3eee 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PauseVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/PauseVmCommand.java @@ -17,7 +17,7 @@ @Override protected void Perform() { - if (VM.isStatusUp(getVm().getStatus())) { + if (getVm().getStatus().isStatusOfRunningVM()) { setActionReturnValue(Backend.getInstance().getResourceManager() .RunVdsCommand(VDSCommandType.Pause, new PauseVDSCommandParameters(getVdsId(), getVmId())) .getReturnValue()); @@ -44,7 +44,7 @@ || vm.getStatus() == VMStatus.NotResponding) { retValue = false; message.add(VdcBllMessages.ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL.toString()); - } else if (!VM.isStatusUp(vm.getStatus())) { + } else if (!vm.getStatus().isStatusOfRunningVM()) { retValue = false; message.add(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NOT_RUNNING.toString()); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java index 85e2836..73ceb01 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java @@ -115,7 +115,7 @@ public static boolean IsVmRunning(Guid vmId) { VM vm = DbFacade.getInstance().getVmDao().get(vmId); if (vm != null) { - return VM.isStatusUpOrPaused(vm.getStatus()) || vm.getStatus() == VMStatus.Unknown; + return vm.getStatus().isStatusOfRunningOrPausedVM() || vm.getStatus() == VMStatus.Unknown; } return false; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java index 4204f55..2062eed 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java @@ -41,7 +41,6 @@ import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.VDS; -import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.storage_domains; import org.ovirt.engine.core.common.errors.VdcBLLException; @@ -223,7 +222,7 @@ } setActionReturnValue(status); - if (VM.isStatusUp(status) || status == VMStatus.RestoringState) { + if (status.isStatusOfRunningVM() || status == VMStatus.RestoringState) { setSucceeded(true); } else { // Try to rerun Vm on different vds diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java index a71b9a7..1af6392 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java @@ -11,7 +11,6 @@ import org.ovirt.engine.core.bll.utils.PermissionSubject; import org.ovirt.engine.core.common.action.VmOperationParameterBase; import org.ovirt.engine.core.common.businessentities.DiskImage; -import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VmDynamic; import org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters; @@ -52,7 +51,7 @@ if (getVm() == null) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_NOT_FOUND); - } else if (!VM.isStatusUp(getVm().getStatus()) && getVm().getStatus() != VMStatus.Paused + } else if (!getVm().getStatus().isStatusOfRunningVM() && getVm().getStatus() != VMStatus.Paused && getVm().getStatus() != VMStatus.NotResponding && getVm().getStatus() != VMStatus.Suspended) { if (getVm().getStatus() == VMStatus.SavingState || getVm().getStatus() == VMStatus.RestoringState) { retValue = false; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmOperationCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmOperationCommandBase.java index af5d883..ade2938 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmOperationCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmOperationCommandBase.java @@ -51,7 +51,7 @@ // If the status of the machine implies that it is not running in a host then // there is no need to find the id of the host: - if (!VM.isStatusUpOrPaused(status) && status != VMStatus.NotResponding) { + if (!status.isStatusOfRunningOrPausedVM() && status != VMStatus.NotResponding) { return false; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java index 539fd0a..c2fcd69 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java @@ -121,7 +121,7 @@ .RunVdsCommand(VDSCommandType.IsVmDuringInitiating, new IsVmDuringInitiatingVDSCommandParameters(vm.getId())) .getReturnValue()).booleanValue(); - if (vm.isStatusUp() || (vm.getStatus() == VMStatus.NotResponding) || isVmDuringInit) { + if (vm.isRunning() || (vm.getStatus() == VMStatus.NotResponding) || isVmDuringInit) { retValue = false; message.add(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING.toString()); } else if (vm.getStatus() == VMStatus.Paused && vm.getRunOnVds() != null) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/GetVmsAndNetworkInterfacesByNetworkIdQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/GetVmsAndNetworkInterfacesByNetworkIdQuery.java index f62be8f..2fd7548 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/GetVmsAndNetworkInterfacesByNetworkIdQuery.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/GetVmsAndNetworkInterfacesByNetworkIdQuery.java @@ -34,7 +34,7 @@ new ArrayList<PairQueryable<VmNetworkInterface, VM>>(); for (VmNetworkInterface vmNetworkInterface : vmNetworkInterfaceList) { VM vm = vmsById.get(vmNetworkInterface.getVmId()); - if (getParameters().getRunningVms() == null || getParameters().getRunningVms().equals(vm.isStatusUp())) { + if (getParameters().getRunningVms() == null || getParameters().getRunningVms().equals(vm.isRunning())) { vmInterfaceVmPairs.add(new PairQueryable<VmNetworkInterface, VM>(vmNetworkInterface, vm)); } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java index 92fda10..686243e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java @@ -26,7 +26,7 @@ public ValidationResult vmNotRunningStateless() { if (DbFacade.getInstance().getSnapshotDao().exists(vm.getId(), SnapshotType.STATELESS)) { - VdcBllMessages message = vm.isStatusUp() ? VdcBllMessages.ACTION_TYPE_FAILED_VM_RUNNING_STATELESS : + VdcBllMessages message = vm.isRunning() ? VdcBllMessages.ACTION_TYPE_FAILED_VM_RUNNING_STATELESS : VdcBllMessages.ACTION_TYPE_FAILED_VM_HAS_STATELESS_SNAPSHOT_LEFTOVER; return new ValidationResult(message); } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java index f467558..ce9d207 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java @@ -1059,10 +1059,6 @@ } } - public boolean isStatusUp() { - return isStatusUp(getStatus()); - } - private boolean useSysPrep; public boolean useSysPrep() { @@ -1075,33 +1071,6 @@ public boolean isFirstRun() { return vmStatic.isFirstRun(); - } - - public static boolean isStatusUp(VMStatus st) { - return (st == VMStatus.Up || st == VMStatus.PoweredDown || st == VMStatus.PoweringDown - || st == VMStatus.PoweringUp || st == VMStatus.MigratingFrom || st == VMStatus.WaitForLaunch || st == VMStatus.RebootInProgress); - - } - - public static boolean isStatusUpOrPaused(VMStatus st) { - return (isStatusUp(st) || st == VMStatus.Paused || st == VMStatus.SavingState || st == VMStatus.RestoringState); - - } - - public static boolean isStatusQualifyToMigrate(VMStatus st) { - return (st == VMStatus.Up || st == VMStatus.PoweringUp || st == VMStatus.Paused || st == VMStatus.RebootInProgress); - } - - public static boolean isStatusUpOrPausedOrSuspended(VMStatus st) { - return (isStatusUpOrPaused(st) || st == VMStatus.Suspended); - } - - public static boolean isStatusDown(VMStatus st) { - return (st == VMStatus.Down || st == VMStatus.Suspended || st == VMStatus.ImageLocked || st == VMStatus.ImageIllegal); - } - - public static boolean isGuestUp(VMStatus st) { - return (st == VMStatus.Up || st == VMStatus.PoweringDown || st == VMStatus.PoweredDown || st == VMStatus.PoweringUp); } private double _actualDiskWithSnapthotsSize = 0; @@ -1533,4 +1502,8 @@ public boolean isDown() { return getStatus() == VMStatus.Down; } + + public boolean isRunning() { + return getStatus().isStatusOfRunningVM(); + } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java index fdfd8b2..55dd332 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VMStatus.java @@ -22,26 +22,78 @@ ImageLocked(15), PoweringDown(16); - private int intValue; - private static java.util.HashMap<Integer, VMStatus> mappings = new HashMap<Integer, VMStatus>(); + private int value; + private static HashMap<Integer, VMStatus> valueToStatus = new HashMap<Integer, VMStatus>(); static { for (VMStatus status : values()) { - mappings.put(status.getValue(), status); + valueToStatus.put(status.getValue(), status); } } private VMStatus(int value) { - intValue = value; + this.value = value; } @Override public int getValue() { - return intValue; + return value; } public static VMStatus forValue(int value) { - return mappings.get(value); + return valueToStatus.get(value); } + /** + * This method reflects whether it's a VM status in which the guest is up + * + * @return true if this status indicates that the guest is up, otherwise false + */ + public boolean isStatusOfGuestUp() { + return this == Up || this == PoweringDown || this == PoweredDown || this == PoweringUp; + } + + /** + * This method reflects whether the VM is surely not running in this status + * + * <p>Note: There might be cases in which the VM is not running and this method + * returns false + * + * @return true if this status indicates that the VM is not running for sure, otherwise false + */ + public boolean isStatusOfNotRunningVM() { + return this == Down || this == Suspended || this == ImageLocked || this == ImageIllegal; + } + + /** + * This method reflects whether the VM is qualify to migration in this status + * + * @return true if this status indicates that the VM is qualify to migration, otherwise false + */ + public boolean isStatusOfQualifyToMigrateVM() { + return this == Up || this == PoweringUp || this == Paused || this == RebootInProgress; + } + + /** + * This method reflects whether the VM is surely running or paused in this status + * + * @see #isStatusOfRunningVM() + * @return true if this status indicates that the VM is paused or running for sure, otherwise false + */ + public boolean isStatusOfRunningOrPausedVM() { + return this.isStatusOfRunningVM() || this == Paused || this == SavingState || this == RestoringState; + } + + /** + * This method reflects whether the VM is surely running in this status + * + * <p>Note: There might be cases in which the VM is running and this method + * returns false + * + * @return true if this status indicates that the VM is running for sure, otherwise false + */ + public boolean isStatusOfRunningVM() { + return this == Up || this == PoweredDown || this == PoweringDown + || this == PoweringUp || this == MigratingFrom || this == WaitForLaunch || this == RebootInProgress; + } } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java index d1346d8..bbae9e7 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/ResourceManager.java @@ -73,7 +73,7 @@ // Cleanup all vms dynamic data. This is defencive code on power crash List<VM> vms = DbFacade.getInstance().getVmDao().getAll(); for (VM vm : vms) { - if (!VM.isStatusDown(vm.getStatus())) { + if (!vm.getStatus().isStatusOfNotRunningVM()) { // check if vm should be suspended if (vm.getStatus() == VMStatus.SavingState) { InternalSetVmStatus(vm, VMStatus.Suspended); @@ -252,12 +252,12 @@ vm.setStatus(status); vm.setExitStatus(exitStaus); vm.setExitMessage(exitMessage); - boolean isVmStatusDown = VM.isStatusDown(status); + boolean isVmNotRunning = status.isStatusOfNotRunningVM(); - if (isVmStatusDown || status == VMStatus.Unknown) { + if (isVmNotRunning || status == VMStatus.Unknown) { resetVmAttributes(vm); - if (isVmStatusDown) { + if (isVmNotRunning) { vm.setRunOnVds(null); vm.setVmPauseStatus(VmPauseStatus.NONE); } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/SetVmStatusVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/SetVmStatusVDSCommand.java index fcfd9a0..e1eaa18 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/SetVmStatusVDSCommand.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/SetVmStatusVDSCommand.java @@ -21,7 +21,7 @@ SetVmStatusVDSCommandParameters parameters = getParameters(); VmDynamic vmDynamic = DbFacade.getInstance().getVmDynamicDao().get(parameters.getVmId()); vmDynamic.setstatus(parameters.getStatus()); - if (VM.isStatusDown(parameters.getStatus())) { + if (parameters.getStatus().isStatusOfNotRunningVM()) { ResourceManager.getInstance().RemoveAsyncRunningVm(parameters.getVmId()); VmStatistics vmStatistics = DbFacade.getInstance().getVmStatisticsDao().get(parameters.getVmId()); VM vm = new VM(null, vmDynamic, vmStatistics); diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java index 60ac63f..41c1a94 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java @@ -277,7 +277,7 @@ _vmDict = getDbFacade().getVmDao().getAllRunningByVds(_vds.getId()); for (VM vm : _vmDict.values()) { - if (vm.isStatusUp() && vm.getStatus() != VMStatus.Up) { + if (vm.isRunning() && vm.getStatus() != VMStatus.Up) { runningVmsInTransition++; } } @@ -1496,7 +1496,7 @@ private void afterMigrationFrom(VmDynamic runningVm, VM vmToUpdate) { VMStatus oldVmStatus = vmToUpdate.getStatus(); - if (oldVmStatus == VMStatus.MigratingFrom && VM.isGuestUp(runningVm.getstatus())) { + if (oldVmStatus == VMStatus.MigratingFrom && runningVm.getstatus().isStatusOfGuestUp()) { _vmsToRerun.add(runningVm.getId()); log.infoFormat("adding VM {0} to re-run list", runningVm.getId()); vmToUpdate.setMigratingToVds(null); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/resources/ResourcesModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/resources/ResourcesModel.java index c8c1222..ec4563d 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/resources/ResourcesModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/resources/ResourcesModel.java @@ -273,7 +273,7 @@ definedCPUs += vm.getNumOfCpus(); definedMemory += vm.getVmMemSizeMb(); - if (vm.isStatusUp()) + if (vm.isRunning()) { runningVMs++; usedCPUs += vm.getNumOfCpus(); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java index 48499ec..bda6d5f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java @@ -125,7 +125,7 @@ getModel().getIsHighlyAvailable().setEntity(vm.isAutoStartup()); getModel().getTotalCPUCores().setEntity(Integer.toString(vm.getNumOfCpus())); - getModel().getTotalCPUCores().setIsChangable(!vm.isStatusUp()); + getModel().getTotalCPUCores().setIsChangable(!vm.isRunning()); getModel().getIsStateless().setEntity(vm.isStateless()); getModel().getIsStateless().setIsAvailable(vm.getVmPoolId() == null); @@ -134,7 +134,7 @@ getModel().getIsDeleteProtected().setEntity(vm.isDeleteProtected()); getModel().getNumOfSockets().setSelectedItem(vm.getNumOfSockets()); - getModel().getNumOfSockets().setIsChangable(!vm.isStatusUp()); + getModel().getNumOfSockets().setIsChangable(!vm.isRunning()); getModel().getKernel_parameters().setEntity(vm.getKernelParams()); getModel().getKernel_path().setEntity(vm.getKernelUrl()); -- To view, visit http://gerrit.ovirt.org/10795 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I82b4f109751773ff2d46407ccea26ea0be2661f5 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
