Search in sources :

Example 51 with VmStatic

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);
}
Also used : VmStatisticsDao(org.ovirt.engine.core.dao.VmStatisticsDao) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Guid(org.ovirt.engine.core.compat.Guid) VmDynamicDao(org.ovirt.engine.core.dao.VmDynamicDao) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) Function(java.util.function.Function) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) Inject(javax.inject.Inject) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) VmNetworkStatisticsDao(org.ovirt.engine.core.dao.network.VmNetworkStatisticsDao) Map(java.util.Map) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) Version(org.ovirt.engine.core.compat.Version) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) ReentrantLock(java.util.concurrent.locks.ReentrantLock) VmOverheadCalculator(org.ovirt.engine.core.common.scheduling.VmOverheadCalculator) Collectors(java.util.stream.Collectors) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VdsmVm(org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm) PostConstruct(javax.annotation.PostConstruct) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid)

Example 52 with VmStatic

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;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) Guid(org.ovirt.engine.core.compat.Guid) AffinityRulesUtils(org.ovirt.engine.core.bll.scheduling.arem.AffinityRulesUtils) ArrayList(java.util.ArrayList) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) HashSet(java.util.HashSet) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) Map(java.util.Map) AffinityGroupDao(org.ovirt.engine.core.dao.scheduling.AffinityGroupDao) AffinityGroupCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.AffinityGroupCRUDParameters) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Iterator(java.util.Iterator) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Set(java.util.Set) CommandBase(org.ovirt.engine.core.bll.CommandBase) Collectors(java.util.stream.Collectors) VdsStaticDao(org.ovirt.engine.core.dao.VdsStaticDao) Objects(java.util.Objects) List(java.util.List) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) Collections(java.util.Collections) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet)

Example 53 with VmStatic

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;
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 54 with 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();
}
Also used : AddVmTemplateParameters(org.ovirt.engine.core.common.action.AddVmTemplateParameters) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Guid(org.ovirt.engine.core.compat.Guid)

Example 55 with VmStatic

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;
}
Also used : VmInit(org.ovirt.engine.core.common.businessentities.VmInit) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Aggregations

VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)87 Test (org.junit.Test)26 Guid (org.ovirt.engine.core.compat.Guid)15 VM (org.ovirt.engine.core.common.businessentities.VM)11 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)9 VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)8 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)8 Label (org.ovirt.engine.core.common.businessentities.Label)7 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Response (javax.ws.rs.core.Response)4 AddVmTemplateParameters (org.ovirt.engine.core.common.action.AddVmTemplateParameters)4 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)4 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)4 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 PostConstruct (javax.annotation.PostConstruct)3 Before (org.junit.Before)3