use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.
the class SetVmTicketCommand method validate.
@Override
protected boolean validate() {
// Check that the virtual machine exists:
final VM vm = getVm();
if (vm == null) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_VM_NOT_FOUND);
return false;
}
if (!canRunActionOnNonManagedVm()) {
return false;
}
// Check that the virtual machine is in state that allows connections
// to the console:
final VMStatus status = vm.getStatus();
if (status != VMStatus.Up && status != VMStatus.Paused && status != VMStatus.PoweringUp && status != VMStatus.PoweringDown && status != VMStatus.RebootInProgress) {
return failVmStatusIllegal();
}
// subjects:
return true;
}
use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.
the class RunVmCommand method runVm.
protected void runVm() {
setActionReturnValue(VMStatus.Down);
if (getVdsToRunOn()) {
VMStatus status = null;
try {
acquireHostDevicesLock();
if (connectLunDisks(getVdsId()) && updateCinderDisksConnections()) {
if (!checkRequiredHostDevicesAvailability()) {
// (while the host-device lock wasn't being held) we need to bail here
throw new EngineException(EngineError.HOST_DEVICES_TAKEN_BY_OTHER_VM);
} else {
status = createVm();
ExecutionHandler.setAsyncJob(getExecutionContext(), true);
markHostDevicesAsUsed();
}
}
} catch (EngineException e) {
// re-throw it. otherwise, continue (the vm will be down and a re-run will be triggered)
switch(e.getErrorCode()) {
// should never get here with errorCode = 'Done' though
case Done:
case exist:
cleanupPassthroughVnics();
reportCompleted();
throw e;
// probably wrong xml format sent.
case VDS_NETWORK_ERROR:
case PROVIDER_FAILURE:
case HOST_DEVICES_TAKEN_BY_OTHER_VM:
runningFailed();
throw e;
default:
log.warn("Failed to run VM '{}': {}", getVmName(), e.getMessage());
}
} finally {
releaseHostDevicesLock();
freeLock();
}
setActionReturnValue(status);
if (status != null && (status.isRunning() || status == VMStatus.RestoringState)) {
setSucceeded(true);
} else {
// Try to rerun Vm on different vds no need to log the command because it is
// being logged inside the rerun
log.info("Trying to rerun VM '{}'", getVm().getName());
setCommandShouldBeLogged(false);
setSucceeded(true);
rerun();
}
} else {
runningFailed();
}
}
use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.
the class VmStatusCell method render.
@Override
public void render(Context context, VM vm, SafeHtmlBuilder sb, String id) {
// Nothing to render if no vm is provided:
if (vm == null) {
return;
}
// Find the image corresponding to the status of the vm:
VMStatus status = vm.getStatus();
ImageResource statusImage;
switch(status) {
case Up:
if (vm.isRunOnce()) {
statusImage = resources.runOnceUpImage();
} else {
statusImage = resources.vmStatusRunning();
}
break;
case SavingState:
statusImage = resources.vmStatusWait();
break;
case RestoringState:
statusImage = resources.vmStatusWait();
break;
case PoweringUp:
statusImage = resources.vmStatusStarting();
break;
case PoweringDown:
statusImage = resources.vmStatusPoweringDown();
break;
case RebootInProgress:
statusImage = resources.rebootInProgress();
break;
case WaitForLaunch:
statusImage = resources.waitForLaunch();
break;
case ImageLocked:
statusImage = resources.vmStatusWait();
break;
case MigratingFrom:
case MigratingTo:
statusImage = resources.migrationImage();
break;
case Suspended:
statusImage = resources.suspendedImage();
break;
case Paused:
statusImage = resources.pauseImage();
break;
case Unknown:
case Unassigned:
statusImage = resources.questionMarkImage();
break;
case NotResponding:
statusImage = resources.questionMarkImage();
break;
default:
statusImage = resources.downStatusImage();
break;
}
// Generate the HTML for status image
SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML());
if (vm.getLockInfo() != null && vm.getLockInfo().isExclusive()) {
ImageResource lockImageResource = resources.vmLocked();
// Get the image html
AbstractImagePrototype imagePrototype = AbstractImagePrototype.create(lockImageResource);
SafeHtml lockImageHtml = SafeHtmlUtils.fromTrustedString(imagePrototype.getHTML());
statusImageHtml = templates.lockedStatusTemplate(lockImageHtml, statusImageHtml);
}
if (VmStatusColumn.needsAlert(vm)) {
sb.append(templates.statusWithAlertTemplate(statusImageHtml, getAlertImageResource(vm), id, status.toString()));
} else {
sb.append(templates.statusTemplate(statusImageHtml, id, status.toString()));
}
}
Aggregations