Search in sources :

Example 31 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class ExistingVmModelBehavior method initialize.

@Override
public void initialize() {
    super.initialize();
    toggleAutoSetVmHostname();
    getModel().getVmInitEnabled().setEntity(getVm().getVmInit() != null);
    getModel().getVmInitModel().init(getVm().getStaticData());
    getModel().getVmType().setIsChangeable(true);
    getModel().getIsSoundcardEnabled().setIsChangeable(true);
    getModel().getInstanceTypes().setIsChangeable(!vm.isRunning());
    getModel().getLabelList().setIsAvailable(true);
    getModel().getVmId().setIsAvailable(true);
    getModel().getVmId().setIsChangeable(false);
    loadDataCenter();
    instanceTypeManager = new ExistingVmInstanceTypeManager(getModel(), vm);
    if (vm.getVmPoolId() != null) {
        instanceTypeManager.setAlwaysEnabledFieldUpdate(true);
    }
    Frontend.getInstance().runQuery(QueryType.GetVmNumaNodesByVmId, new IdQueryParameters(vm.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
        List<VmNumaNode> nodes = returnValue.getReturnValue();
        getModel().setVmNumaNodes(nodes);
        getModel().updateNodeCount(nodes.size());
    }));
    // load dedicated host names into host names list
    if (getVm().getDedicatedVmForVdsList().size() > 0) {
        Frontend.getInstance().runQuery(QueryType.GetAllHostNamesPinnedToVmById, new IdQueryParameters(vm.getId()), asyncQuery((QueryReturnValue returnValue) -> setDedicatedHostsNames((List<String>) returnValue.getReturnValue())));
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) CommentVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommentVmBaseToUnitBuilder) Map(java.util.Map) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Version(org.ovirt.engine.core.compat.Version) InstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.InstanceTypeManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) EnumSet(java.util.EnumSet) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmActionByVmOriginTypeValidator(org.ovirt.engine.core.common.validation.VmActionByVmOriginTypeValidator) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) StringHelper(org.ovirt.engine.core.compat.StringHelper) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) CommonCompatibilityVersionUtils(org.ovirt.engine.core.common.utils.CommonCompatibilityVersionUtils) ExistingVmInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingVmInstanceTypeManager) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ExistingVmInstanceTypeManager(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingVmInstanceTypeManager) ArrayList(java.util.ArrayList) List(java.util.List)

Example 32 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class AddVmCommand method addVmNumaNodes.

private void addVmNumaNodes() {
    List<VmNumaNode> numaNodes = getParameters().getVm().getvNumaNodeList();
    if (numaNodes.isEmpty()) {
        return;
    }
    VmNumaNodeOperationParameters params = new VmNumaNodeOperationParameters(getParameters().getVm(), numaNodes);
    ActionReturnValue returnValueBase = backend.runInternalAction(ActionType.AddVmNumaNodes, params);
    if (!returnValueBase.getSucceeded()) {
        auditLogDirector.log(this, AuditLogType.NUMA_ADD_VM_NUMA_NODE_FAILED);
    }
}
Also used : VmNumaNodeOperationParameters(org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Example 33 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class NumaValidator method validateNumaCompatibility.

/**
 * Check if a VM can run on specific hostNumaNodes with the provided numa configuration. The numa nodes for
 * validation need to be passed in separately because the numa nodes are not necessarily part of the VM when the
 * validation takes place.
 *
 * @param vm            with numa nodes
 * @param vmNumaNodes   to use for validation
 * @param hostNumaNodes from a host
 * @return weather the vm can run on the hostNumaNodes or not
 */
public ValidationResult validateNumaCompatibility(final VM vm, final List<VmNumaNode> vmNumaNodes, final List<VdsNumaNode> hostNumaNodes) {
    if (hostNumaNodes == null || hostNumaNodes.isEmpty()) {
        return new ValidationResult(EngineMessage.VM_NUMA_PINNED_VDS_NODE_EMPTY);
    }
    if (hostNumaNodes.size() == 1) {
        // One node is equal to no NUMA node architecture present
        return new ValidationResult(EngineMessage.HOST_NUMA_NOT_SUPPORTED);
    }
    final HashMap<Integer, VdsNumaNode> hostNodeMap = new HashMap<>();
    for (VdsNumaNode hostNumaNode : hostNumaNodes) {
        hostNodeMap.put(hostNumaNode.getIndex(), hostNumaNode);
    }
    boolean memStrict = vm.getNumaTuneMode() == NumaTuneMode.STRICT;
    for (VmNumaNode vmNumaNode : vmNumaNodes) {
        for (Integer pinnedIndex : vmNumaNode.getVdsNumaNodeList()) {
            if (pinnedIndex == null) {
                return new ValidationResult(EngineMessage.VM_NUMA_NODE_PINNED_INDEX_ERROR);
            }
            if (!hostNodeMap.containsKey(pinnedIndex)) {
                return new ValidationResult(EngineMessage.VM_NUMA_NODE_HOST_NODE_INVALID_INDEX, String.format("$vdsNodeIndex %d", pinnedIndex));
            }
            if (memStrict) {
                final VdsNumaNode hostNumaNode = hostNodeMap.get(pinnedIndex);
                if (vmNumaNode.getMemTotal() > hostNumaNode.getMemTotal()) {
                    return new ValidationResult(EngineMessage.VM_NUMA_NODE_MEMORY_ERROR);
                }
            }
        }
    }
    return ValidationResult.VALID;
}
Also used : VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) HashMap(java.util.HashMap) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 34 with VmNumaNode

use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.

the class InClusterUpgradeValidator method checkVmReadyForUpgrade.

protected List<String> checkVmReadyForUpgrade(final VM vm) {
    requireNonNull(vm);
    final List<String> errors = new ArrayList<>();
    if (vm.getStatus().isSuspended()) {
        errors.addAll(toVmEngineMessage(vm, EngineMessage.CLUSTER_UPGRADE_DETAIL_VM_SUSPENDED));
    }
    if (!StringUtils.isEmpty(vm.getCpuPinning())) {
        errors.addAll(toVmEngineMessage(vm, EngineMessage.CLUSTER_UPGRADE_DETAIL_VM_CPUS_PINNED));
    }
    for (VmNumaNode vmNumaNode : vm.getvNumaNodeList()) {
        if (!vmNumaNode.getVdsNumaNodeList().isEmpty()) {
            errors.addAll(toVmEngineMessage(vm, EngineMessage.CLUSTER_UPGRADE_DETAIL_VM_NUMA_PINNED));
            break;
        }
    }
    if (MigrationSupport.MIGRATABLE != vm.getMigrationSupport()) {
        errors.addAll(toVmEngineMessage(vm, EngineMessage.CLUSTER_UPGRADE_DETAIL_VM_NOT_MIGRATABLE));
    }
    // TODO use a more efficient way, this does a db call per VM
    if (hostDeviceManager.checkVmNeedsDirectPassthrough(vm)) {
        errors.addAll(toVmEngineMessage(vm, EngineMessage.CLUSTER_UPGRADE_DETAIL_VM_NEEDS_PASSTHROUGH));
    }
    return errors;
}
Also used : VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) ArrayList(java.util.ArrayList)

Aggregations

VmNumaNode (org.ovirt.engine.core.common.businessentities.VmNumaNode)34 ArrayList (java.util.ArrayList)17 Guid (org.ovirt.engine.core.compat.Guid)9 HashMap (java.util.HashMap)7 List (java.util.List)5 Map (java.util.Map)5 VM (org.ovirt.engine.core.common.businessentities.VM)5 VdsNumaNode (org.ovirt.engine.core.common.businessentities.VdsNumaNode)5 Test (org.junit.Test)4 VmNumaNodeOperationParameters (org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters)4 Arrays (java.util.Arrays)3 Pair (org.ovirt.engine.core.common.utils.Pair)3 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)3 LinkedHashSet (java.util.LinkedHashSet)2 Collectors (java.util.stream.Collectors)2 Named (javax.inject.Named)2 Singleton (javax.inject.Singleton)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1