Shubhendu Tripathi has uploaded a new change for review. Change subject: engine: Query to get list of cluster with nodes ......................................................................
engine: Query to get list of cluster with nodes Introduced a BLL query to get the list of clusters which have nodes attached with. Change-Id: I5c06388ec88436518ce2e8bd3855d64ba66400b7 Bug-Url: https://bugzilla.redhat.com/1202391 Signed-off-by: Shubhendu Tripathi <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllVdsGroupsHavingHostsQuery.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/VdsGroupDAO.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java M packaging/dbscripts/vds_groups_sp.sql 5 files changed, 42 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/96/40396/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllVdsGroupsHavingHostsQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllVdsGroupsHavingHostsQuery.java new file mode 100644 index 0000000..55e5200 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllVdsGroupsHavingHostsQuery.java @@ -0,0 +1,15 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.common.queries.VdcQueryParametersBase; + +public class GetAllVdsGroupsHavingHostsQuery<P extends VdcQueryParametersBase> extends QueriesCommandBase<P> { + + public GetAllVdsGroupsHavingHostsQuery(P parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + setReturnValue(getDbFacade().getVdsGroupDao().getClustersHavingHosts()); + } +} 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 f727f32..7e21378 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 @@ -262,6 +262,7 @@ GetDataCentersWithPermittedActionOnClusters(VdcQueryAuthType.User), GetClustersWithPermittedAction(VdcQueryAuthType.User), GetVmTemplatesWithPermittedAction(VdcQueryAuthType.User), + GetAllVdsGroupsHavingHosts, // Storage GetStorageDomainById(VdcQueryAuthType.User), diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAO.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAO.java index b376f56..221c573 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAO.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAO.java @@ -157,6 +157,13 @@ List<VDSGroup> getClustersWithPermittedAction(Guid userId, ActionGroup actionGroup); /** + * Retrieves clusters having valid hosts added to them + * + * @return list of clusters + */ + List<VDSGroup> getClustersHavingHosts(); + + /** * Sets the cluster's emulated machine value * @param vdsGroupId * @param emulatedMachine diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java index fb34942..7e1bf3e 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java @@ -168,6 +168,15 @@ } @Override + public List<VDSGroup> getClustersHavingHosts() { + MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource(); + + return getCallsHandler().executeReadList("GetVdsGroupsHavingHosts", + VdsGroupRowMapper.instance, + parameterSource); + } + + @Override public void setEmulatedMachine(Guid vdsGroupId, String emulatedMachine, boolean detectEmulatedMachine) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("vds_group_id", vdsGroupId) diff --git a/packaging/dbscripts/vds_groups_sp.sql b/packaging/dbscripts/vds_groups_sp.sql index b891792..ade9cfb 100644 --- a/packaging/dbscripts/vds_groups_sp.sql +++ b/packaging/dbscripts/vds_groups_sp.sql @@ -258,6 +258,16 @@ END; $procedure$ LANGUAGE plpgsql; +-- This SP returns all clusters which have valid hosts attached to them +Create or replace FUNCTION GetVdsGroupsHavingHosts() RETURNS SETOF vds_groups_view STABLE + AS $procedure$ +BEGIN + RETURN QUERY SELECT vds_groups_view.* + FROM vds_groups_view + WHERE EXISTS (SELECT * from vds_static WHERE vds_group_id = vds_groups_view.vds_group_id); +END; $procedure$ +LANGUAGE plpgsql; + --This SP updates the vds_group emulated machine and the detection mode Create or replace FUNCTION UpdateVdsGroupEmulatedMachine(v_vds_group_id UUID, v_emulated_machine varchar(40), v_detect_emulated_machine BOOLEAN) RETURNS VOID AS $procedure$ -- To view, visit https://gerrit.ovirt.org/40396 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c06388ec88436518ce2e8bd3855d64ba66400b7 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shubhendu Tripathi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
