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();
});
}
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);
}
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);
}
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));
}
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();
}
Aggregations