Search in sources :

Example 91 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class UpdateVmCommand method updateRngDevice.

private void updateRngDevice() {
    if (!getParameters().isUpdateRngDevice()) {
        return;
    }
    QueryReturnValue query = runInternalQuery(QueryType.GetRngDevice, new IdQueryParameters(getParameters().getVmId()));
    List<VmRngDevice> rngDevs = query.getReturnValue();
    ActionReturnValue rngCommandResult = null;
    if (rngDevs.isEmpty()) {
        if (getParameters().getRngDevice() != null) {
            RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
            rngCommandResult = runInternalAction(ActionType.AddRngDevice, params, cloneContextAndDetachFromParent());
        }
    } else {
        if (getParameters().getRngDevice() == null) {
            RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), true);
            rngCommandResult = runInternalAction(ActionType.RemoveRngDevice, params, cloneContextAndDetachFromParent());
        } else {
            RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
            params.getRngDevice().setDeviceId(rngDevs.get(0).getDeviceId());
            rngCommandResult = runInternalAction(ActionType.UpdateRngDevice, params, cloneContextAndDetachFromParent());
        }
    }
    if (rngCommandResult != null && !rngCommandResult.getSucceeded()) {
        log.error("Updating RNG device of VM {} ({}) failed. Old RNG device = {}. New RNG device = {}.", getVm().getName(), getVm().getId(), rngDevs.isEmpty() ? null : rngDevs.get(0), getParameters().getRngDevice());
    }
}
Also used : RngDeviceParameters(org.ovirt.engine.core.common.action.RngDeviceParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 92 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class UpdateVmPoolCommand method isUpdateVmRequired.

private boolean isUpdateVmRequired(List<VM> vmsInPool) {
    if (vmsInPool == null || vmsInPool.isEmpty()) {
        return false;
    }
    // Check one VM in order to decide if template version was changed
    VM poolVm = vmsInPool.get(0);
    // old template version (based on current vm data)
    Guid currentTemplateVersion = null;
    // old latest status
    boolean isCurrentLatest = false;
    if (poolVm.isNextRunConfigurationExists()) {
        QueryReturnValue qRetNextRun = backend.runInternalQuery(QueryType.GetVmNextRunConfiguration, new IdQueryParameters(poolVm.getId()));
        if (qRetNextRun.getSucceeded()) {
            final VM nextRunVm = qRetNextRun.getReturnValue();
            if (nextRunVm != null) {
                // template version was changed, the cause still needs to be checked
                currentTemplateVersion = nextRunVm.getVmtGuid();
                isCurrentLatest = nextRunVm.isUseLatestVersion();
            }
        }
    } else {
        currentTemplateVersion = poolVm.getVmtGuid();
        isCurrentLatest = poolVm.isUseLatestVersion();
    }
    boolean isLatestPropertyChanged = isCurrentLatest != getParameters().getVmStaticData().isUseLatestVersion();
    // template ID changed but latest is not set, as it would cause false-positives
    boolean isTemplateIdChanged = false;
    Guid newPoolTemplateVersion = getParameters().getVmStaticData().getVmtGuid();
    if (newPoolTemplateVersion != null) {
        isTemplateIdChanged = !newPoolTemplateVersion.equals(currentTemplateVersion) && !isCurrentLatest;
    }
    return isLatestPropertyChanged || isTemplateIdChanged;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid)

Example 93 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class UpdateVmVersionCommand method buildAddVmParameters.

private AddVmParameters buildAddVmParameters() {
    AddVmParameters addVmParams = new AddVmParameters(getParameters().getVmStaticData());
    addVmParams.setPoolId(getParameters().getVmPoolId());
    addVmParams.setDiskInfoDestinationMap(buildDiskInfoDestinationMap());
    addVmParams.setConsoleEnabled(deviceExists(VmDeviceGeneralType.CONSOLE));
    addVmParams.setBalloonEnabled(deviceExists(VmDeviceGeneralType.BALLOON, VmDeviceType.MEMBALLOON));
    addVmParams.setSoundDeviceEnabled(deviceExists(VmDeviceGeneralType.SOUND));
    addVmParams.setVirtioScsiEnabled(deviceExists(VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI));
    List<VmWatchdog> watchdogs = runInternalQuery(QueryType.GetWatchdog, new IdQueryParameters(getVmTemplateId())).getReturnValue();
    if (!watchdogs.isEmpty()) {
        addVmParams.setWatchdog(watchdogs.get(0));
    }
    loadVmPayload(addVmParams);
    // then there is no session, so using the current user.
    if (StringUtils.isEmpty(getParameters().getSessionId())) {
        addVmParams.setParametersCurrentUser(getCurrentUser());
    } else {
        addVmParams.setSessionId(getParameters().getSessionId());
    }
    addVmParams.setDiskOperatorAuthzPrincipalDbId(getParameters().getPreviousDiskOperatorAuthzPrincipalDbId());
    // reset vm to not initialized
    addVmParams.getVmStaticData().setInitialized(false);
    return addVmParams;
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AddVmParameters(org.ovirt.engine.core.common.action.AddVmParameters) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog)

Example 94 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class GetAllDiskSnapshotsByStorageDomainIdQueryTest method testNoActiveImagesReturned.

@Test
public void testNoActiveImagesReturned() {
    IdQueryParameters params = getQueryParameters();
    when(params.getId()).thenReturn(storageDoaminId);
    GetAllDiskSnapshotsByStorageDomainIdQuery<IdQueryParameters> query = getQuery();
    query.executeQueryCommand();
    List<DiskImage> diskImages = query.getQueryReturnValue().getReturnValue();
    // Assert the no active images are returned
    assertTrue("Active images shouldn't be returned", diskImages.stream().noneMatch(DiskImage::getActive));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test) AbstractQueryTest(org.ovirt.engine.core.bll.AbstractQueryTest)

Example 95 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class BackendClusterFeatureHelper method getEnabledFeature.

public static SupportedAdditionalClusterFeature getEnabledFeature(BackendResource resource, Guid clusterId, Guid id) {
    Set<SupportedAdditionalClusterFeature> addlFeatures = resource.getOptionalEntity(Set.class, QueryType.GetClusterFeaturesByClusterId, new IdQueryParameters(clusterId), clusterId.toString(), false);
    SupportedAdditionalClusterFeature feature = Optional.ofNullable(addlFeatures).orElse(Collections.emptySet()).stream().filter(f -> f.getFeature().getId().equals(id) && f.isEnabled()).findFirst().orElse(null);
    return feature;
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) SupportedAdditionalClusterFeature(org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature)

Aggregations

IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)268 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)89 Guid (org.ovirt.engine.core.compat.Guid)80 ArrayList (java.util.ArrayList)68 StorageDomainsAndStoragePoolIdQueryParameters (org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters)62 QueryType (org.ovirt.engine.core.common.queries.QueryType)59 List (java.util.List)47 Frontend (org.ovirt.engine.ui.frontend.Frontend)45 VM (org.ovirt.engine.core.common.businessentities.VM)42 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)36 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)35 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)26 Collection (java.util.Collection)25 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)25 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)25 Test (org.junit.Test)24 VDS (org.ovirt.engine.core.common.businessentities.VDS)24 HashMap (java.util.HashMap)22 ActionType (org.ovirt.engine.core.common.action.ActionType)21 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)19