use of org.ovirt.engine.core.common.queries.GetEntitiesWithPermittedActionParameters in project ovirt-engine by oVirt.
the class AsyncDataProvider method getClustersWithPermittedAction.
public void getClustersWithPermittedAction(AsyncQuery<List<Cluster>> aQuery, ActionGroup actionGroup, final boolean supportsVirtService, final boolean supportsGlusterService) {
aQuery.converterCallback = source -> {
if (source != null) {
ArrayList<Cluster> list = (ArrayList<Cluster>) source;
return getClusterByServiceList(list, supportsVirtService, supportsGlusterService);
}
return new ArrayList<>();
};
GetEntitiesWithPermittedActionParameters getEntitiesWithPermittedActionParameters = new GetEntitiesWithPermittedActionParameters();
getEntitiesWithPermittedActionParameters.setActionGroup(actionGroup);
Frontend.getInstance().runQuery(QueryType.GetClustersWithPermittedAction, getEntitiesWithPermittedActionParameters, aQuery);
}
use of org.ovirt.engine.core.common.queries.GetEntitiesWithPermittedActionParameters in project ovirt-engine by oVirt.
the class VMConsoleProxyServlet method availableConsoles.
private List<Map<String, String>> availableConsoles(String userIdAsString) {
List<Map<String, String>> jsonVms = new ArrayList<>();
Guid userGuid = null;
try {
if (StringUtils.isNotEmpty(userIdAsString)) {
userGuid = Guid.createGuidFromString(userIdAsString);
}
} catch (IllegalArgumentException e) {
log.debug("Could not read User GUID");
}
if (userGuid != null) {
ActionReturnValue loginResult = backend.runInternalAction(ActionType.LoginOnBehalf, new LoginOnBehalfParameters(userGuid));
if (!loginResult.getSucceeded()) {
throw new RuntimeException("Unable to create session using LoginOnBehalf");
}
String engineSessionId = loginResult.getActionReturnValue();
try {
QueryReturnValue retVms = backend.runInternalQuery(QueryType.GetAllVmsForUserAndActionGroup, new GetEntitiesWithPermittedActionParameters(ActionGroup.CONNECT_TO_SERIAL_CONSOLE), new EngineContext().withSessionId(engineSessionId));
if (retVms != null) {
List<VM> vmsList = retVms.getReturnValue();
for (VM vm : vmsList) {
Map<String, String> jsonVm = new HashMap<>();
if (vm.getRunOnVds() != null) {
// TODO: avoid one query per loop. Bulk query?
QueryReturnValue retValue = backend.runInternalQuery(QueryType.GetVdsByVdsId, new IdQueryParameters(vm.getRunOnVds()));
if (retValue != null && retValue.getReturnValue() != null) {
VDS vds = retValue.getReturnValue();
jsonVm.put("vmid", vm.getId().toString());
jsonVm.put("vmname", vm.getName());
jsonVm.put("host", vds.getHostName());
/* there is only one serial console, no need and no way to distinguish them */
jsonVm.put("console", "default");
jsonVms.add(jsonVm);
}
}
}
}
} finally {
backend.runInternalAction(ActionType.LogoutSession, new ActionParametersBase(engineSessionId));
}
}
return jsonVms;
}
Aggregations