Search in sources :

Example 16 with IdQueryParameters

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

the class ExistingNonClusterModelBehavior method doBuild.

public void doBuild() {
    buildModel(entity, (source, destination) -> {
        Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(entity.getId()), new AsyncQuery<>((QueryReturnValue returnValue) -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
        getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), entity.getId());
        getInstance().getWatchdogByVmId(new AsyncQuery<QueryReturnValue>(returnValue -> {
            @SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
            for (VmWatchdog watchdog : watchdogs) {
                getModel().getWatchdogAction().setSelectedItem(watchdog.getAction());
                getModel().getWatchdogModel().setSelectedItem(watchdog.getModel());
            }
        }), entity.getId());
        Frontend.getInstance().runQuery(QueryType.GetRngDevice, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
            List<VmDevice> rngDevices = returnValue.getReturnValue();
            getModel().getIsRngEnabled().setEntity(!rngDevices.isEmpty());
            if (!rngDevices.isEmpty()) {
                VmRngDevice rngDevice = new VmRngDevice(rngDevices.get(0));
                getModel().setRngDevice(rngDevice);
            }
        }));
        getModel().getEmulatedMachine().setSelectedItem(entity.getCustomEmulatedMachine());
        getModel().getCustomCpu().setSelectedItem(entity.getCustomCpuName());
        getModel().getMigrationMode().setSelectedItem(entity.getMigrationSupport());
        postBuild();
    });
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) QueryType(org.ovirt.engine.core.common.queries.QueryType) AsyncDataProvider.getInstance(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider.getInstance) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashSet(java.util.HashSet) HwOnlyVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.HwOnlyVmBaseToUnitBuilder) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Collection(java.util.Collection) List(java.util.List) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 17 with IdQueryParameters

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

the class VmInstanceTypeManager method updateNetworkInterfacesByTemplate.

public void updateNetworkInterfacesByTemplate(VmBase vmBase) {
    QueryType queryType = (vmBase instanceof VmTemplate) ? QueryType.GetTemplateInterfacesByTemplateId : QueryType.GetVmInterfacesByVmId;
    AsyncQuery<QueryReturnValue> query = new AsyncQuery<>(returnValue -> {
        if (returnValue == null) {
            return;
        }
        List<VmNetworkInterface> nics = returnValue.getReturnValue();
        updateNetworkInterfaces(getNetworkProfileBehavior(), nics);
    });
    Frontend.getInstance().runQuery(queryType, new IdQueryParameters(vmBase.getId()), query);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 18 with IdQueryParameters

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

the class GlusterStorageSyncCommand method executeCommand.

@Override
protected void executeCommand() {
    // Get list of running VMs that have disks on storage domain
    List<VM> vms = runInternalQuery(QueryType.GetVmsByStorageDomain, new IdQueryParameters(getStorageDomain().getId())).getReturnValue();
    // Snapshot the VMs
    Map<Guid, Guid> vmIdSnapshotIdMap = new HashMap<>();
    for (VM vm : vms) {
        try {
            Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.CreateSnapshotForVm, getCreateSnapshotParameters(vm), cloneContextAndDetachFromParent());
            vmIdSnapshotIdMap.put(vm.getId(), future.get().getActionReturnValue());
        } catch (InterruptedException | ExecutionException e) {
            log.error("Error creating VM snapshot for VM with id '{}', name '{}' for DR sync", vm.getId(), vm.getName(), e.getMessage());
            log.debug("Exception", e);
            endWithFailure();
            getParameters().setTaskGroupSuccess(false);
        }
    }
    getParameters().setVmIdSnapshotIds(vmIdSnapshotIdMap);
    getParameters().setNextStep(DRStep.GEO_REP);
    persistCommandIfNeeded();
    setSucceeded(true);
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) ExecutionException(java.util.concurrent.ExecutionException)

Example 19 with IdQueryParameters

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

the class GetVmsPinnedToHostQueryTest method testExecuteQuery.

@Test
public void testExecuteQuery() {
    VM expectedResult = new VM();
    expectedResult.setId(Guid.newGuid());
    IdQueryParameters paramsMock = getQueryParameters();
    when(paramsMock.getId()).thenReturn(Guid.newGuid());
    when(vmDao.getAllPinnedToHost(any(Guid.class))).thenReturn(Collections.singletonList(expectedResult));
    getQuery().executeQueryCommand();
    List<VM> result = getQuery().getQueryReturnValue().getReturnValue();
    assertNotNull(result);
    assertEquals(1, result.size());
    assertEquals("Wrong VM returned", expectedResult, result.get(0));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 20 with IdQueryParameters

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

the class GetVmConfigurationBySnapshotQueryTest method setupQueryBySnapshotId.

private GetVmConfigurationBySnapshotQuery<IdQueryParameters> setupQueryBySnapshotId(Guid snapshotId) {
    IdQueryParameters queryParams = getQueryParameters();
    when(queryParams.getId()).thenReturn(snapshotId);
    return getQuery();
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters)

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