Daniel Erez has uploaded a new change for review. Change subject: core: SnapshotDao - added getAllByStorageDomain method ......................................................................
core: SnapshotDao - added getAllByStorageDomain method SnapshotDao/DbFacadeImpl: * Added getAllByStorageDomain method. snapshot_sp.sql: * Added GetAllSnapshotsByStorageDomainId stored procedure. Change-Id: I13a5d3493be9f26caa0d6f4e15a9c6c9d308cfd9 Signed-off-by: Daniel Erez <[email protected]> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDao.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDaoDbFacadeImpl.java M packaging/dbscripts/snapshots_sp.sql 3 files changed, 32 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/26321/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDao.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDao.java index ff5a87e..625261b 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDao.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDao.java @@ -131,6 +131,15 @@ List<Snapshot> getAll(Guid vmId, Guid userId, boolean isFiltered); /** + * Get all the snapshots with disks on the specified storage domain. + * + * @param storageId + * The Storage Domain ID. + * @return the list of snapshots. + */ + List<Snapshot> getAllByStorageDomain(Guid storageId); + + /** * Check if there exists a snapshot of the given type for the VM. * * @param vmId diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDaoDbFacadeImpl.java index 4abefb1..f3ece87 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/SnapshotDaoDbFacadeImpl.java @@ -122,6 +122,16 @@ } @Override + public List<Snapshot> getAllByStorageDomain(Guid storageId) { + MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() + .addValue("storage_id", storageId); + + return getCallsHandler().executeReadList("GetAllSnapshotsByStorageDomainId", + createEntityRowMapper(), + parameterSource); + } + + @Override public boolean exists(Guid vmId, SnapshotType type) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("vm_id", vmId) diff --git a/packaging/dbscripts/snapshots_sp.sql b/packaging/dbscripts/snapshots_sp.sql index a270966..3f90633 100644 --- a/packaging/dbscripts/snapshots_sp.sql +++ b/packaging/dbscripts/snapshots_sp.sql @@ -137,6 +137,19 @@ +Create or replace FUNCTION GetAllSnapshotsByStorageDomainId(v_storage_id UUID) RETURNS SETOF snapshots STABLE +AS $procedure$ +BEGIN + RETURN QUERY + SELECT snapshots.* + FROM snapshots + JOIN images ON snapshots.snapshot_id = images.vm_snapshot_id + JOIN image_storage_domain_map ON image_storage_domain_map.storage_domain_id = v_storage_id; +END; $procedure$ +LANGUAGE plpgsql; + + + Create or replace FUNCTION GetSnapshotByVmIdAndType( v_vm_id UUID, v_snapshot_type VARCHAR(32)) -- To view, visit http://gerrit.ovirt.org/26321 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I13a5d3493be9f26caa0d6f4e15a9c6c9d308cfd9 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Daniel Erez <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
