Search in sources :

Example 1 with VMStatus

use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.

the class VmAnalyzer method handOverVm.

private void handOverVm() {
    Guid dstHostId = dbVm.getMigratingToVds();
    // when the destination VDS is NonResponsive put the VM to Unknown like the rest of its VMs
    VMStatus newVmStatus = isVdsNonResponsive(dstHostId) ? VMStatus.Unknown : VMStatus.MigratingTo;
    dbVm.setRunOnVds(dstHostId);
    logVmHandOver(dstHostId, newVmStatus);
    resourceManager.internalSetVmStatus(dbVm, newVmStatus);
    saveDynamic(dbVm);
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus)

Example 2 with VMStatus

use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.

the class RunVmCommand method createVm.

protected VMStatus createVm() {
    updateCdPath();
    if (!StringUtils.isEmpty(getParameters().getFloppyPath())) {
        getVm().setFloppyPath(cdPathWindowsToLinux(getParameters().getFloppyPath()));
    }
    // Set path for initrd and kernel image.
    if (!StringUtils.isEmpty(getVm().getInitrdUrl())) {
        getVm().setInitrdUrl(getIsoPrefixFilePath(getVm().getInitrdUrl()));
    }
    if (!StringUtils.isEmpty(getVm().getKernelUrl())) {
        getVm().setKernelUrl(getIsoPrefixFilePath(getVm().getKernelUrl()));
    }
    initParametersForExternalNetworks(getVds(), false);
    VMStatus vmStatus = (VMStatus) getVdsBroker().runAsyncVdsCommand(VDSCommandType.Create, buildCreateVmParameters(), this).getReturnValue();
    // Don't use the memory from the active snapshot anymore if there's a chance that disks were changed
    memoryFromSnapshotUsed = vmStatus.isRunning() || vmStatus == VMStatus.RestoringState;
    // After VM was create (or not), we can remove the quota vds group memory.
    return vmStatus;
}
Also used : VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus)

Example 3 with VMStatus

use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.

the class VmHandler method init.

/**
 * Initialize list containers, for identity and permission check. The initialization should be executed
 * before calling ObjectIdentityChecker.
 *
 * @see Backend#initHandlers
 */
@PostConstruct
public void init() {
    Class<?>[] inspectedClassNames = new Class<?>[] { VmBase.class, VM.class, VmStatic.class, VmDynamic.class, VmManagementParametersBase.class };
    updateVmsStatic = new ObjectIdentityChecker(VmHandler.class, Arrays.asList(inspectedClassNames));
    for (Pair<EditableDeviceOnVmStatusField, Field> pair : BaseHandler.extractAnnotatedFields(EditableDeviceOnVmStatusField.class, inspectedClassNames)) {
        updateVmsStatic.addField(Arrays.asList(pair.getFirst().statuses()), pair.getSecond().getName());
    }
    for (Pair<TransientField, Field> pair : BaseHandler.extractAnnotatedFields(TransientField.class, inspectedClassNames)) {
        updateVmsStatic.addTransientFields(pair.getSecond().getName());
    }
    for (Pair<EditableVmField, Field> pair : BaseHandler.extractAnnotatedFields(EditableVmField.class, inspectedClassNames)) {
        EditableVmField annotation = pair.getFirst();
        List<VMStatus> statusList = Arrays.asList(annotation.onStatuses());
        String fieldName = pair.getSecond().getName();
        if (statusList.isEmpty()) {
            updateVmsStatic.addPermittedFields(fieldName);
        } else {
            updateVmsStatic.addField(statusList, fieldName);
            if (!annotation.hotSettableOnStatus().getStates().isEmpty()) {
                updateVmsStatic.addHotsetField(fieldName, annotation.hotSettableOnStatus().getStates());
            }
        }
        if (annotation.onHostedEngine()) {
            updateVmsStatic.addHostedEngineFields(fieldName);
        }
    }
}
Also used : VmBase(org.ovirt.engine.core.common.businessentities.VmBase) EditableDeviceOnVmStatusField(org.ovirt.engine.core.common.businessentities.EditableDeviceOnVmStatusField) Field(java.lang.reflect.Field) TransientField(org.ovirt.engine.core.common.businessentities.TransientField) EditableVmField(org.ovirt.engine.core.common.businessentities.EditableVmField) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) TransientField(org.ovirt.engine.core.common.businessentities.TransientField) ObjectIdentityChecker(org.ovirt.engine.core.utils.ObjectIdentityChecker) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) EditableDeviceOnVmStatusField(org.ovirt.engine.core.common.businessentities.EditableDeviceOnVmStatusField) EditableVmField(org.ovirt.engine.core.common.businessentities.EditableVmField) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PostConstruct(javax.annotation.PostConstruct)

Example 4 with VMStatus

use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.

the class VmOperationCommandBase method getRunningOnVds.

/**
 * This method checks if the virtual machine is running in some host. It also
 * has the side effect of storing the reference to the host inside the command.
 *
 * @return <code>true</code> if the virtual machine is running in a any host,
 *   <code>false</code> otherwise
 */
protected boolean getRunningOnVds() {
    // We will need the virtual machine and the status, so it is worth saving references:
    final VM vm = getVm();
    final VMStatus status = vm.getStatus();
    // there is no need to find the id of the host:
    if (!status.isRunningOrPaused() && status != VMStatus.NotResponding) {
        return false;
    }
    // Find the id of the host where the machine is running:
    Guid hostId = vm.getRunOnVds();
    if (hostId == null) {
        log.warn("Strange, according to the status '{}' virtual machine '{}' should be running in a host but it isn't.", status, vm.getId());
        return false;
    }
    // Find the reference to the host using the id that we got before (setting
    // the host to null is required in order to make sure that the host is
    // reloaded from the database):
    setVdsId(new Guid(hostId.toString()));
    setVds(null);
    if (getVds() == null) {
        log.warn("Strange, virtual machine '{}' is is running in host '{}' but that host can't be found.", vm.getId(), hostId);
        return false;
    }
    // a host:
    return true;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus)

Example 5 with VMStatus

use of org.ovirt.engine.core.common.businessentities.VMStatus in project ovirt-engine by oVirt.

the class VmTemplateHandler method init.

/**
 * Initialize list containers, for identity and permission check. The initialization should be executed
 * before calling ObjectIdentityChecker.
 *
 * @see Backend#initHandlers()
 */
@PostConstruct
public void init() {
    final Class<?>[] inspectedClassNames = new Class<?>[] { VmBase.class, VmTemplate.class };
    updateVmTemplate = new ObjectIdentityChecker(VmTemplateHandler.class);
    for (Pair<EditableVmTemplateField, Field> pair : BaseHandler.extractAnnotatedFields(EditableVmTemplateField.class, inspectedClassNames)) {
        String fieldName = pair.getSecond().getName();
        updateVmTemplate.addPermittedFields(fieldName);
    }
    for (Pair<EditableVmField, Field> pair : BaseHandler.extractAnnotatedFields(EditableVmField.class, inspectedClassNames)) {
        EditableVmField annotation = pair.getFirst();
        List<VMStatus> statusList = Arrays.asList(annotation.onStatuses());
        String fieldName = pair.getSecond().getName();
        if (statusList.isEmpty()) {
            updateVmTemplate.addPermittedFields(fieldName);
        }
    }
}
Also used : VmBase(org.ovirt.engine.core.common.businessentities.VmBase) EditableVmTemplateField(org.ovirt.engine.core.common.businessentities.EditableVmTemplateField) EditableVmField(org.ovirt.engine.core.common.businessentities.EditableVmField) Field(java.lang.reflect.Field) EditableVmTemplateField(org.ovirt.engine.core.common.businessentities.EditableVmTemplateField) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ObjectIdentityChecker(org.ovirt.engine.core.utils.ObjectIdentityChecker) EditableVmField(org.ovirt.engine.core.common.businessentities.EditableVmField) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PostConstruct(javax.annotation.PostConstruct)

Aggregations

VMStatus (org.ovirt.engine.core.common.businessentities.VMStatus)8 VM (org.ovirt.engine.core.common.businessentities.VM)3 Field (java.lang.reflect.Field)2 PostConstruct (javax.annotation.PostConstruct)2 EditableVmField (org.ovirt.engine.core.common.businessentities.EditableVmField)2 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)2 Guid (org.ovirt.engine.core.compat.Guid)2 ObjectIdentityChecker (org.ovirt.engine.core.utils.ObjectIdentityChecker)2 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 AbstractImagePrototype (com.google.gwt.user.client.ui.AbstractImagePrototype)1 VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)1 EditableDeviceOnVmStatusField (org.ovirt.engine.core.common.businessentities.EditableDeviceOnVmStatusField)1 EditableVmTemplateField (org.ovirt.engine.core.common.businessentities.EditableVmTemplateField)1 TransientField (org.ovirt.engine.core.common.businessentities.TransientField)1 VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1