Jason Liao has uploaded a new change for review. Change subject: engine: NUMA feature queries and actions extends ......................................................................
engine: NUMA feature queries and actions extends Add validation for add/update/remove VM NUMA node. Add transaction command in add/edit VM command. Change-Id: I9c299405ec5d82ada713ed3d220554bf3055c145 Signed-off-by: Jason Liao <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/AddVmNumaNodesCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/RemoveVmNumaNodesCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/UpdateVmNumaNodesCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java 4 files changed, 63 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/27617/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/AddVmNumaNodesCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/AddVmNumaNodesCommand.java index f1c9246..a112f40 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/AddVmNumaNodesCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/AddVmNumaNodesCommand.java @@ -10,6 +10,7 @@ import org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters; import org.ovirt.engine.core.common.businessentities.VdsNumaNode; import org.ovirt.engine.core.common.businessentities.VmNumaNode; +import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.compat.Guid; @@ -54,6 +55,31 @@ } @Override + protected boolean canDoAction() { + Guid vdsId = getVm().getDedicatedVmForVds(); + if (vdsId == null) { + return failCanDoAction(VdcBllMessages.VM_NUMA_PINNED_VDS_NOT_EXIST); + } + List<VdsNumaNode> vdsNumaNodes = new ArrayList<VdsNumaNode>(); + vdsNumaNodes = getDbFacade().getVdsNumaNodeDAO().getAllVdsNumaNodeByVdsId(vdsId); + List<VmNumaNode> vmNumaNodes = getParameters().getVmNumaNodeList(); + for (VmNumaNode vmNumaNode : vmNumaNodes) { + for (Pair<Guid, Pair<Boolean, Integer>> pair : vmNumaNode.getVdsNumaNodeList()) { + int index = pair.getSecond().getSecond(); + for (VdsNumaNode vdsNumaNode : vdsNumaNodes) { + if (vdsNumaNode.getIndex() == index) { + if (vmNumaNode.getMemTotal() > vdsNumaNode.getMemTotal()) { + return failCanDoAction(VdcBllMessages.VM_NUMA_NODE_MEMRORY_ERROR); + } + break; + } + } + } + } + return true; + } + + @Override public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissionList = new ArrayList<PermissionSubject>(); permissionList.add(new PermissionSubject(getParameters().getVmId(), diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/RemoveVmNumaNodesCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/RemoveVmNumaNodesCommand.java index b99fb84..12a9b8f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/RemoveVmNumaNodesCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/RemoveVmNumaNodesCommand.java @@ -9,6 +9,7 @@ import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters; import org.ovirt.engine.core.common.businessentities.VmNumaNode; +import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.compat.Guid; public class RemoveVmNumaNodesCommand<T extends VmNumaNodeOperationParameters> extends VmCommand<T> { @@ -34,6 +35,14 @@ } @Override + protected boolean canDoAction() { + if (getVm() == null) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_NOT_FOUND); + } + return true; + } + + @Override public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissionList = new ArrayList<PermissionSubject>(); permissionList.add(new PermissionSubject(getParameters().getVmId(), diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/UpdateVmNumaNodesCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/UpdateVmNumaNodesCommand.java index 2bfff5f..6599d5c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/UpdateVmNumaNodesCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/numa/vm/UpdateVmNumaNodesCommand.java @@ -10,6 +10,7 @@ import org.ovirt.engine.core.common.action.VmNumaNodeOperationParameters; import org.ovirt.engine.core.common.businessentities.VdsNumaNode; import org.ovirt.engine.core.common.businessentities.VmNumaNode; +import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.compat.Guid; @@ -51,6 +52,31 @@ } @Override + protected boolean canDoAction() { + Guid vdsId = getVm().getDedicatedVmForVds(); + if (vdsId == null) { + return failCanDoAction(VdcBllMessages.VM_NUMA_PINNED_VDS_NOT_EXIST); + } + List<VdsNumaNode> vdsNumaNodes = new ArrayList<VdsNumaNode>(); + vdsNumaNodes = getDbFacade().getVdsNumaNodeDAO().getAllVdsNumaNodeByVdsId(vdsId); + List<VmNumaNode> vmNumaNodes = getParameters().getVmNumaNodeList(); + for (VmNumaNode vmNumaNode : vmNumaNodes) { + for (Pair<Guid, Pair<Boolean, Integer>> pair : vmNumaNode.getVdsNumaNodeList()) { + int index = pair.getSecond().getSecond(); + for (VdsNumaNode vdsNumaNode : vdsNumaNodes) { + if (vdsNumaNode.getIndex() == index) { + if (vmNumaNode.getMemTotal() > vdsNumaNode.getMemTotal()) { + return failCanDoAction(VdcBllMessages.VM_NUMA_NODE_MEMRORY_ERROR); + } + break; + } + } + } + } + return true; + } + + @Override public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissionList = new ArrayList<PermissionSubject>(); permissionList.add(new PermissionSubject(getParameters().getVmId(), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index d238f35..c4fc36b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -366,6 +366,8 @@ VM_PINNING_PCPU_DOES_NOT_EXIST(ErrorType.BAD_PARAMETERS), VM_PINNING_DUPLICATE_DEFINITION(ErrorType.BAD_PARAMETERS), VM_PINNING_PINNED_TO_NO_CPU(ErrorType.BAD_PARAMETERS), + VM_NUMA_PINNED_VDS_NOT_EXIST(ErrorType.BAD_PARAMETERS), + VM_NUMA_NODE_MEMRORY_ERROR(ErrorType.BAD_PARAMETERS), CANNOT_PREIEW_CURRENT_IMAGE(ErrorType.BAD_PARAMETERS), VM_CANNOT_SUSPENDE_HAS_RUNNING_TASKS(ErrorType.CONFLICT), VM_CANNOT_REMOVE_HAS_RUNNING_TASKS(ErrorType.CONFLICT), -- To view, visit http://gerrit.ovirt.org/27617 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9c299405ec5d82ada713ed3d220554bf3055c145 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Jason Liao <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
