Tomas Jelinek has uploaded a new change for review. Change subject: core: Warning when deleting an instance type which is attached to a VM ......................................................................
core: Warning when deleting an instance type which is attached to a VM Backend part - adds a query to get all the VMs which are based on an instance type. Change-Id: I5ed11ee1b543bda00f41b00c5726a907eaf498de Signed-off-by: Tomas Jelinek <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVmsByInstanceTypeIdQuery.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAO.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java M packaging/dbscripts/vms_sp.sql 5 files changed, 49 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/27004/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVmsByInstanceTypeIdQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVmsByInstanceTypeIdQuery.java new file mode 100644 index 0000000..09b8072 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVmsByInstanceTypeIdQuery.java @@ -0,0 +1,19 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.common.queries.IdQueryParameters; + +/** + * A query to retrieve all the VMs connected to a given instance type. + */ +public class GetVmsByInstanceTypeIdQuery<P extends IdQueryParameters> extends QueriesCommandBase<P> { + public GetVmsByInstanceTypeIdQuery(P parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + getQueryReturnValue().setReturnValue(getDbFacade() + .getVmDao() + .getVmsListByInstanceType(getParameters().getId())); + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index 9a657dc..6bb4068 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -10,6 +10,7 @@ GetAllVms(VdcQueryAuthType.User), GetVmsRunningOnOrMigratingToVds, GetVmsByStorageDomain, + GetVmsByInstanceTypeId, GetVmCustomProperties(VdcQueryAuthType.User), GetVmConfigurationBySnapshot(VdcQueryAuthType.User), GetVmFromConfiguration(VdcQueryAuthType.User), diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAO.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAO.java index d2e110c..6c65b30 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAO.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAO.java @@ -77,6 +77,13 @@ List<VM> getVmsListForDisk(Guid id, boolean includeVmsSnapshotAttachedTo); /** + * Retrieves a list of VMs for the specified instance type id. + * + * @return A {@link List} of the VMs connected to the given instance type. + */ + List<VM> getVmsListByInstanceType(Guid id); + + /** * Retrieves a list of VMs for the specified disk id. * * @param disk diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java index 829861c..18464a9 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java @@ -89,6 +89,14 @@ return result; } + @Override + public List<VM> getVmsListByInstanceType(Guid id) { + return getCallsHandler().executeReadList("GetVmsByInstanceTypeId", + VMRowMapper.instance, + getCustomMapSqlParameterSource() + .addValue("instance_type_id", id)); + } + public List<Pair<VM, VmDevice>> getVmsWithPlugInfo(Guid id) { return getCallsHandler().executeReadList ("GetVmsByDiskId", diff --git a/packaging/dbscripts/vms_sp.sql b/packaging/dbscripts/vms_sp.sql index b751d7a..fb85a0b 100644 --- a/packaging/dbscripts/vms_sp.sql +++ b/packaging/dbscripts/vms_sp.sql @@ -917,6 +917,20 @@ +Create or replace FUNCTION GetVmsByInstanceTypeId(v_instance_type_id UUID) RETURNS SETOF vms STABLE + AS $procedure$ +BEGIN +RETURN QUERY select vms.* from vms + WHERE instance_type_id = v_instance_type_id; +END; $procedure$ +LANGUAGE plpgsql; + + + + + + + Create or replace FUNCTION GetVmsByUserIdWithGroupsAndUserRoles(v_user_id UUID) RETURNS SETOF vms STABLE AS $procedure$ BEGIN -- To view, visit http://gerrit.ovirt.org/27004 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5ed11ee1b543bda00f41b00c5726a907eaf498de Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
