use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class VmHandler method getVmInitWithoutPasswordByIds.
public List<VmInit> getVmInitWithoutPasswordByIds(List<Guid> ids) {
List<VmInit> all = vmInitDao.getVmInitByIds(ids);
for (VmInit vmInit : all) {
vmInit.setPasswordAlreadyStored(!StringUtils.isEmpty(vmInit.getRootPassword()));
vmInit.setRootPassword(null);
}
return all;
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class BackendVmsResource method mapCollection.
protected Vms mapCollection(List<org.ovirt.engine.core.common.businessentities.VM> entities) {
Set<String> details = DetailHelper.getDetails(httpHeaders, uriInfo);
boolean includeData = details.contains(DetailHelper.MAIN);
boolean includeSize = details.contains("size");
List<Guid> vmIds = entities.stream().map(VM::getId).collect(Collectors.toList());
if (includeData) {
// Fill VmInit for entities - the search query no join the VmInit to Vm
IdsQueryParameters params = new IdsQueryParameters();
params.setId(vmIds);
QueryReturnValue queryReturnValue = runQuery(QueryType.GetVmsInit, params);
if (queryReturnValue.getSucceeded() && queryReturnValue.getReturnValue() != null) {
List<VmInit> vmInits = queryReturnValue.getReturnValue();
Map<Guid, VmInit> initMap = Entities.businessEntitiesById(vmInits);
for (org.ovirt.engine.core.common.businessentities.VM vm : entities) {
vm.setVmInit(initMap.get(vm.getId()));
}
}
}
Vms collection = new Vms();
if (includeData) {
// optimization of DB access: retrieve GraphicsDevices for all VMs at once
Map<Guid, List<GraphicsDevice>> vmsGraphicsDevices = DisplayHelper.getGraphicsDevicesForMultipleEntities(this, vmIds);
for (org.ovirt.engine.core.common.businessentities.VM entity : entities) {
Vm vm = map(entity);
DisplayHelper.adjustDisplayData(this, vm, vmsGraphicsDevices, false);
removeRestrictedInfo(vm);
collection.getVms().add(addLinks(populate(vm, entity)));
}
}
if (includeSize) {
collection.setSize((long) entities.size());
}
return collection;
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class BackendTemplatesResource method mapCollection.
protected Templates mapCollection(List<VmTemplate> entities) {
Set<String> details = DetailHelper.getDetails(httpHeaders, uriInfo);
boolean includeData = details.contains(DetailHelper.MAIN);
boolean includeSize = details.contains("size");
if (includeData) {
// Fill VmInit for entities - the search query no join the VmInit to Templates
IdsQueryParameters params = new IdsQueryParameters();
List<Guid> ids = entities.stream().map(VmTemplate::getId).collect(Collectors.toList());
params.setId(ids);
QueryReturnValue queryReturnValue = runQuery(QueryType.GetVmsInit, params);
if (queryReturnValue.getSucceeded() && queryReturnValue.getReturnValue() != null) {
List<VmInit> vmInits = queryReturnValue.getReturnValue();
Map<Guid, VmInit> initMap = Entities.businessEntitiesById(vmInits);
for (VmTemplate template : entities) {
template.setVmInit(initMap.get(template.getId()));
}
}
}
Templates collection = new Templates();
if (includeData) {
for (VmTemplate entity : entities) {
Template template = map(entity);
collection.getTemplates().add(addLinks(populate(template, entity)));
DisplayHelper.adjustDisplayData(this, template);
}
}
if (includeSize) {
collection.setSize((long) entities.size());
}
return collection;
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class VmInitDaoTest method testGetWithInvalidId.
/**
* Ensures that get requires a valid id.
*/
@Test
public void testGetWithInvalidId() {
VmInit result = vmInitDao.get(Guid.newGuid());
assertNull(result);
}
use of org.ovirt.engine.core.common.businessentities.VmInit in project ovirt-engine by oVirt.
the class VmInitDaoTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
vmInitDao = dbFacade.getVmInitDao();
vmInit = new VmInit();
vmInit.setId(EXISTING_VM);
}
Aggregations