use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VmManager method estimateOverhead.
private int estimateOverhead(VmStatic vmStatic) {
// Prepare VM object using the available bits and pieces
VM compose = new VM(vmStatic, new VmDynamic(), new VmStatistics(), clusterArchitecture, clusterCompatibilityVersion);
// Load device list, TODO ignores unmanaged devices for now
Map<Guid, VmDevice> devices = vmDeviceDao.getVmDeviceByVmId(vmId).stream().filter(VmDevice::isManaged).collect(Collectors.toMap(d -> d.getId().getDeviceId(), Function.identity()));
vmStatic.setManagedDeviceMap(devices);
return vmOverheadCalculator.getTotalRequiredMemoryInMb(compose);
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class AffinityGroupCRUDCommand method validateVms.
private boolean validateVms() {
List<Guid> vmIds = getParameters().getAffinityGroup().getVmIds();
if (vmIds.isEmpty()) {
return true;
}
Map<Guid, VmStatic> vms = vmStaticDao.getByIds(vmIds).stream().collect(Collectors.toMap(VmBase::getId, vm -> vm));
Set<Guid> vmSet = new HashSet<>();
for (Guid vmId : vmIds) {
VmStatic vmStatic = vms.get(vmId);
if (vmStatic == null) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_INVALID_ENTITY_FOR_AFFINITY_GROUP, String.format("$entity %s", Entity_VM));
}
if (!Objects.equals(vmStatic.getClusterId(), getClusterId())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_ENTITY_NOT_IN_AFFINITY_GROUP_CLUSTER, String.format("$entity %s", Entity_VM));
}
if (vmSet.contains(vmStatic.getId())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_DUPLICATE_ENTITY_IN_AFFINITY_GROUP, String.format("$entity %s", Entity_VM));
}
vmSet.add(vmStatic.getId());
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class CommonVmPoolCommandTestAbstract method getVmStatic.
private VmStatic getVmStatic() {
VmStatic vmStatic = new VmStatic();
vmStatic.setOsId(OsRepository.DEFAULT_X86_OS);
vmStatic.setNumOfMonitors(1);
vmStatic.setMemSizeMb(300);
vmStatic.setMaxMemorySizeMb(MAX_MEMORY_SIZE);
vmStatic.setStateless(false);
vmStatic.setVmtGuid(vmTemplateId);
return vmStatic;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class AddVmTemplateCommandTest method setupDedicatedHostForVmAndTemplate.
private void setupDedicatedHostForVmAndTemplate(boolean setDefaultHostForTemplate) {
Guid hostId = Guid.newGuid();
vm.setDedicatedVmForVdsList(Collections.singletonList(hostId));
AddVmTemplateParameters parameters = new AddVmTemplateParameters();
VmStatic vmStatic = new VmStatic();
vmStatic.setDedicatedVmForVdsList(setDefaultHostForTemplate ? Collections.singletonList(hostId) : Collections.emptyList());
parameters.setMasterVm(vmStatic);
parameters.setTemplateType(VmEntityType.TEMPLATE);
doReturn(parameters).when(cmd).getParameters();
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class TemplateMapper method map.
@Mapping(from = Template.class, to = VmStatic.class)
public static VmStatic map(Template model, VmStatic incoming) {
VmStatic staticVm = incoming != null ? incoming : new VmStatic();
mapVmBaseModelToEntity(staticVm, model);
if (model.isSetInitialization()) {
staticVm.setVmInit(InitializationMapper.map(model.getInitialization(), staticVm.getVmInit()));
}
if (model.isSetDomain() && model.getDomain().isSetName()) {
if (staticVm.getVmInit() == null) {
staticVm.setVmInit(new VmInit());
}
staticVm.getVmInit().setDomain(model.getDomain().getName());
}
return staticVm;
}
Aggregations