Shubhendu Tripathi has uploaded a new change for review. Change subject: gluster: WIP-DAO for volume snapshot maintenance ......................................................................
gluster: WIP-DAO for volume snapshot maintenance Introduced DAO for gluster volume snapshot maintenance. Change-Id: Id60902aad02b852773ad398aaac9bad8ed7793ab Signed-off-by: Shubhendu Tripathi <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterSnapshotStatus.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java A backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDao.java A backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDaoDbFacadeImpl.java M backend/manager/modules/dal/src/main/jdbc-resources/engine-daos.properties A backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDaoTest.java M backend/manager/modules/dal/src/test/resources/fixtures.xml A packaging/dbscripts/gluster_volume_snapshot_sp.sql R packaging/dbscripts/upgrade/03_04_0480_add_gluster_volume_snapshot_tables.sql R packaging/dbscripts/upgrade/03_04_0490_add_snapshot_enabled_flag_to_gluster_volumes.sql 10 files changed, 520 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/23372/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterSnapshotStatus.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterSnapshotStatus.java index b2b025e..8265d49 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterSnapshotStatus.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterSnapshotStatus.java @@ -6,4 +6,14 @@ IN_USE, RESTORED, DECOMMISSIONED; + + public static GlusterSnapshotStatus from(String status) { + for (GlusterSnapshotStatus snapshotStatus : values()) { + if (snapshotStatus.name().equals(status)) { + return snapshotStatus; + } + } + + return GlusterSnapshotStatus.UNKNOWN; + } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java index a9da479..35cf03d 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java @@ -107,6 +107,7 @@ import org.ovirt.engine.core.dao.gluster.GlusterServerServiceDao; import org.ovirt.engine.core.dao.gluster.GlusterServiceDao; import org.ovirt.engine.core.dao.gluster.GlusterVolumeDao; +import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao; import org.ovirt.engine.core.dao.network.InterfaceDao; import org.ovirt.engine.core.dao.network.NetworkClusterDao; import org.ovirt.engine.core.dao.network.NetworkDao; @@ -799,6 +800,15 @@ } /** + * Returns the singleton instance of {@link GlusterVolumeSnapshotDao} + * + * @return the dao + */ + public GlusterVolumeSnapshotDao getGlusterVolumeSnapshotDao() { + return getDao(GlusterVolumeSnapshotDao.class); + } + + /** * Returns the singleton instance of {@link GlusterVolumeDao}. * * @return the dao diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDao.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDao.java new file mode 100644 index 0000000..b7d8812 --- /dev/null +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDao.java @@ -0,0 +1,35 @@ +package org.ovirt.engine.core.dao.gluster; + +import java.util.Collection; +import java.util.List; + +import org.ovirt.engine.core.common.businessentities.gluster.GlusterSnapshotStatus; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dao.DAO; +import org.ovirt.engine.core.dao.SearchDAO; + +public interface GlusterVolumeSnapshotDao extends DAO, SearchDAO<GlusterVolumeSnapshotEntity> { + public void save(GlusterVolumeSnapshotEntity snapshot); + + public GlusterVolumeSnapshotEntity getById(Guid id); + + public GlusterVolumeSnapshotEntity getByName(Guid volumeId, String snapshotName); + + public List<GlusterVolumeSnapshotEntity> getByVolumeId(Guid volumeId); + + @Override + public List<GlusterVolumeSnapshotEntity> getAllWithQuery(String query); + + public void remove(Guid id); + + public void removeAll(Collection<Guid> ids); + + public void removeByVolumeId(Guid volumeId); + + public void removeByName(Guid volumeId, String snapshotName); + + public void updateSnapshotStatus(Guid snapshotId, GlusterSnapshotStatus status); + + public void updateSnapshotStatusByName(Guid volumeId, String snapshotName, GlusterSnapshotStatus status); +} diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDaoDbFacadeImpl.java new file mode 100644 index 0000000..a487106 --- /dev/null +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDaoDbFacadeImpl.java @@ -0,0 +1,156 @@ +package org.ovirt.engine.core.dao.gluster; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collection; +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterSnapshotStatus; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.common.utils.EnumUtils; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.compat.NotImplementedException; +import org.ovirt.engine.core.dal.dbbroker.MapSqlParameterMapper; +import org.ovirt.engine.core.dao.MassOperationsGenericDaoDbFacade; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; + +public class GlusterVolumeSnapshotDaoDbFacadeImpl extends MassOperationsGenericDaoDbFacade<GlusterVolumeSnapshotEntity, Guid> implements GlusterVolumeSnapshotDao { + private static final RowMapper<GlusterVolumeSnapshotEntity> snapshotRowMapper = + new GlusterVolumeSnapshotRowMapper(); + + public GlusterVolumeSnapshotDaoDbFacadeImpl() { + super("GlusterVolumeSnapshot"); + setProcedureNameForGet("GetGlusterVolumeSnapshotById"); + + } + + @Override + public void save(GlusterVolumeSnapshotEntity snapshot) { + getCallsHandler().executeModification("InsertGlusterVolumeSnapshot", createFullParametersMapper(snapshot)); + } + + @Override + public GlusterVolumeSnapshotEntity getById(Guid id) { + GlusterVolumeSnapshotEntity snapshot = + getCallsHandler().executeRead("GetGlusterVolumeSnapshotById", + snapshotRowMapper, + createSnapshotIdParams(id)); + return snapshot; + } + + @Override + public GlusterVolumeSnapshotEntity getByName(Guid volumeId, String snapshotName) { + GlusterVolumeSnapshotEntity snapshot = + getCallsHandler().executeRead("GetGlusterVolumeSnapshotByName", + snapshotRowMapper, + getCustomMapSqlParameterSource() + .addValue("reference_entity_id", volumeId) + .addValue("snapshot_name", snapshotName)); + + return snapshot; + } + + @Override + public List<GlusterVolumeSnapshotEntity> getByVolumeId(Guid volumeId) { + List<GlusterVolumeSnapshotEntity> snapshots = + getCallsHandler().executeReadList("GetGlusterVolumeSnapshotsByVolumeId", snapshotRowMapper, + getCustomMapSqlParameterSource().addValue("reference_entity_id", volumeId)); + return snapshots; + } + + @Override + public void remove(Guid id) { + getCallsHandler().executeModification("DeleteGlusterVolumeSnapshotByGuid", createSnapshotIdParams(id)); + } + + @Override + public void removeByVolumeId(Guid volumeId) { + getCallsHandler().executeModification("DeleteGlusterSnapshotsByVolumeId", + getCustomMapSqlParameterSource() + .addValue("reference_entity_id", volumeId)); + } + + @Override + public void removeByName(Guid volumeId, String snapshotName) { + getCallsHandler().executeModification("DeleteGlusterVolumeSnapshotByName", + getCustomMapSqlParameterSource() + .addValue("reference_entity_id", volumeId) + .addValue("snapshot_name", snapshotName)); + } + + @Override + public void removeAll(Collection<Guid> ids) { + getCallsHandler().executeModification("DeleteGlusterVolumesSnapshotByIds", + getCustomMapSqlParameterSource().addValue("snapshot_ids", StringUtils.join(ids, ','))); + } + + @Override + public void updateSnapshotStatus(Guid snapshotId, GlusterSnapshotStatus status) { + getCallsHandler().executeModification("UpdateGlusterVolumeSnapshotStatus", + createSnapshotIdParams(snapshotId).addValue("status", EnumUtils.nameOrNull(status))); + } + + @Override + public void updateSnapshotStatusByName(Guid volumeId, String snapshotName, GlusterSnapshotStatus status) { + getCallsHandler().executeModification("UpdateGlusterVolumeSnapshotStatusByName", + getCustomMapSqlParameterSource() + .addValue("reference_entity_id", volumeId) + .addValue("snapshot_name", snapshotName) + .addValue("status", EnumUtils.nameOrNull(status))); + } + + @Override + public List<GlusterVolumeSnapshotEntity> getAllWithQuery(String query) { + List<GlusterVolumeSnapshotEntity> snapshots = jdbcTemplate.query(query, snapshotRowMapper); + return snapshots; + } + + @Override + protected MapSqlParameterSource createFullParametersMapper(GlusterVolumeSnapshotEntity snapshot) { + return getCustomMapSqlParameterSource() + .addValue("snapshot_id", snapshot.getSnapshotId()) + .addValue("snapshot_name", snapshot.getSnapshotName()) + .addValue("reference_entity_id", snapshot.getReferenceEntityId()) + .addValue("created_at", snapshot.getCreatedAt()) + .addValue("description", snapshot.getDescription()) + .addValue("status", EnumUtils.nameOrNull(snapshot.getStatus())); + } + + private MapSqlParameterSource createSnapshotIdParams(Guid id) { + return getCustomMapSqlParameterSource().addValue("snapshot_id", id); + } + + @Override + protected MapSqlParameterSource createIdParameterMapper(Guid id) { + return createSnapshotIdParams(id); + } + + @Override + protected RowMapper<GlusterVolumeSnapshotEntity> createEntityRowMapper() { + return snapshotRowMapper; + } + + private static final class GlusterVolumeSnapshotRowMapper implements RowMapper<GlusterVolumeSnapshotEntity> { + @Override + public GlusterVolumeSnapshotEntity mapRow(ResultSet rs, int rowNum) + throws SQLException { + GlusterVolumeSnapshotEntity entity = new GlusterVolumeSnapshotEntity(); + entity.setSnapshotId(getGuidDefaultEmpty(rs, "snapshot_id")); + entity.setSnapshotName(rs.getString("snapshot_name")); + entity.setReferenceEntityId(getGuidDefaultEmpty(rs, "reference_entity_id")); + entity.setCreatedAt(rs.getTimestamp("created_at")); + entity.setDescription(rs.getString("description")); + entity.setStatus(GlusterSnapshotStatus.from(rs.getString("status"))); + return entity; + } + } + + @SuppressWarnings("deprecation") + @Override + public MapSqlParameterMapper<GlusterVolumeSnapshotEntity> getBatchMapper() { + // TODO: Implement this + throw new NotImplementedException("Unsupported operation"); + } +} diff --git a/backend/manager/modules/dal/src/main/jdbc-resources/engine-daos.properties b/backend/manager/modules/dal/src/main/jdbc-resources/engine-daos.properties index 906d13c..c871d2f 100644 --- a/backend/manager/modules/dal/src/main/jdbc-resources/engine-daos.properties +++ b/backend/manager/modules/dal/src/main/jdbc-resources/engine-daos.properties @@ -55,6 +55,7 @@ StepDao=org.ovirt.engine.core.dao.StepDaoDbFacadeImpl GlusterVolumeDao=org.ovirt.engine.core.dao.gluster.GlusterVolumeDaoDbFacadeImpl GlusterBrickDao=org.ovirt.engine.core.dao.gluster.GlusterBrickDaoDbFacadeImpl +GlusterVolumeSnapshotDao=org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDaoDbFacadeImpl GlusterOptionDao=org.ovirt.engine.core.dao.gluster.GlusterOptionDaoDbFacadeImpl ImageStorageDomainMapDao=org.ovirt.engine.core.dao.ImageStorageDomainMapDaoDbFacadeImpl VmAndTemplatesGenerationsDAO=org.ovirt.engine.core.dao.VmAndTemplatesGenerationsDbFacadeImpl diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDaoTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDaoTest.java new file mode 100644 index 0000000..37ef2d0 --- /dev/null +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterVolumeSnapshotDaoTest.java @@ -0,0 +1,155 @@ +package org.ovirt.engine.core.dao.gluster; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.junit.Test; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterSnapshotStatus; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dao.BaseDAOTestCase; + +public class GlusterVolumeSnapshotDaoTest extends BaseDAOTestCase { + private static final Guid VOLUME_ID = new Guid("0c3f45f6-3fe9-4b35-a30c-be0d1a835ea8"); + private static final Guid EXISTING_SNAPSHOT_ID = new Guid("0c3f45f6-3fe9-4b35-a30c-be0d1a835ea6"); + private static final Guid EXISTING_SNAPSHOT_ID_1 = new Guid("0c3f45f6-3fe9-4b35-a30c-be0d1a835ea7"); + private static final String EXISTING_SNAPSHOT_NAME_1 = "test-vol-distribute-1-snap2"; + private static final String NEW_SNAPSHOT_NAME = "test-vol-distribute-1-snap3"; + private GlusterVolumeSnapshotDao dao; + private GlusterVolumeSnapshotEntity existingSnapshot; + private GlusterVolumeSnapshotEntity existingSnapshot1; + private GlusterVolumeSnapshotEntity newSnapshot; + + @Override + public void setUp() throws Exception { + super.setUp(); + dao = dbFacade.getGlusterVolumeSnapshotDao(); + existingSnapshot = dao.getById(EXISTING_SNAPSHOT_ID); + existingSnapshot1 = dao.getById(EXISTING_SNAPSHOT_ID_1); + } + + @Test + public void testSaveAndGetById() { + GlusterVolumeSnapshotEntity snapshot = dao.getByName(VOLUME_ID, NEW_SNAPSHOT_NAME); + assertNull(snapshot); + + newSnapshot = insertTestSnapshot(); + snapshot = dao.getById(newSnapshot.getId()); + + assertNotNull(snapshot); + assertEquals(newSnapshot, snapshot); + } + + @Test + public void testGetByName() { + newSnapshot = insertTestSnapshot(); + GlusterVolumeSnapshotEntity snapshot = dao.getByName(VOLUME_ID, NEW_SNAPSHOT_NAME); + + assertNotNull(snapshot); + assertEquals(newSnapshot, snapshot); + } + + @Test + public void testGetByVolumeId() { + List<GlusterVolumeSnapshotEntity> snapshots = dao.getByVolumeId(VOLUME_ID); + + assertTrue(snapshots != null); + assertTrue(snapshots.size() == 2); + assertTrue(snapshots.contains(existingSnapshot)); + } + + @Test + public void testGetAllWithQuery() { + List<GlusterVolumeSnapshotEntity> snapshots = + dao.getAllWithQuery("select * from gluster_volume_snapshots"); + + assertTrue(snapshots != null); + assertTrue(snapshots.size() == 2); + } + + @Test + public void testRemove() { + dao.remove(EXISTING_SNAPSHOT_ID); + List<GlusterVolumeSnapshotEntity> snapshots = dao.getByVolumeId(VOLUME_ID); + + assertTrue(snapshots.size() == 1); + assertFalse(snapshots.contains(existingSnapshot)); + } + + @Test + public void testRemoveMultiple() { + List<Guid> idsToRemove = new ArrayList<Guid>(); + idsToRemove.add(EXISTING_SNAPSHOT_ID); + idsToRemove.add(EXISTING_SNAPSHOT_ID_1); + + dao.removeAll(idsToRemove); + List<GlusterVolumeSnapshotEntity> snapshots = dao.getByVolumeId(VOLUME_ID); + + assertTrue(snapshots.isEmpty()); + } + + @Test + public void testRemoveByName() { + dao.removeByName(VOLUME_ID, EXISTING_SNAPSHOT_NAME_1); + List<GlusterVolumeSnapshotEntity> snapshots = dao.getByVolumeId(VOLUME_ID); + + assertTrue(snapshots.size() == 1); + assertTrue(snapshots.contains(existingSnapshot)); + assertFalse(snapshots.contains(existingSnapshot1)); + } + + @Test + public void testRemoveByVolumeId() { + dao.removeByVolumeId(VOLUME_ID); + List<GlusterVolumeSnapshotEntity> snapshots = dao.getByVolumeId(VOLUME_ID); + assertTrue(snapshots.isEmpty()); + } + + @Test + public void testUpdateVolumeStatus() { + dao.updateSnapshotStatus(existingSnapshot.getSnapshotId(), GlusterSnapshotStatus.DECOMMISSIONED); + GlusterVolumeSnapshotEntity snapshot = dao.getById(existingSnapshot.getSnapshotId()); + + assertNotNull(snapshot); + + assertFalse(snapshot.equals(existingSnapshot)); + existingSnapshot.setStatus(GlusterSnapshotStatus.DECOMMISSIONED); + assertEquals(existingSnapshot, snapshot); + } + + @Test + public void testUpdateSnapshotStatusByName() { + dao.updateSnapshotStatusByName(existingSnapshot.getReferenceEntityId(), + existingSnapshot.getSnapshotName(), + GlusterSnapshotStatus.DECOMMISSIONED); + GlusterVolumeSnapshotEntity snapshot = dao.getById(existingSnapshot.getSnapshotId()); + + assertNotNull(snapshot); + + assertFalse(snapshot.equals(existingSnapshot)); + existingSnapshot.setStatus(GlusterSnapshotStatus.DECOMMISSIONED); + assertEquals(existingSnapshot, snapshot); + } + + private GlusterVolumeSnapshotEntity insertTestSnapshot() { + Guid snapshotId = Guid.newGuid(); + + GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity(); + snapshot.setSnapshotId(snapshotId); + snapshot.setSnapshotName(NEW_SNAPSHOT_NAME); + snapshot.setReferenceEntityId(VOLUME_ID); + snapshot.setCreatedAt(new Date()); + snapshot.setDescription("test-description"); + snapshot.setStatus(GlusterSnapshotStatus.from("IN_USE")); + + dao.save(snapshot); + return snapshot; + } +} diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index f966c3a..6a83488 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -5280,6 +5280,31 @@ <value>2010-11-29 15:57:10</value> </row> </table> + + <table name="gluster_volume_snapshots"> + <column>snapshot_id</column> + <column>snapshot_name</column> + <column>reference_entity_id</column> + <column>created_at</column> + <column>description</column> + <column>status</column> + <row> + <value>0c3f45f6-3fe9-4b35-a30c-be0d1a835ea6</value> + <value>test-vol-distribute-1-snap1</value> + <value>0c3f45f6-3fe9-4b35-a30c-be0d1a835ea8</value> + <value>2010-10-21 03:38:22</value> + <value></value> + <value>IN_USE</value> + </row> + <row> + <value>0c3f45f6-3fe9-4b35-a30c-be0d1a835ea7</value> + <value>test-vol-distribute-1-snap2</value> + <value>0c3f45f6-3fe9-4b35-a30c-be0d1a835ea8</value> + <value>2010-11-29 15:57:10</value> + <value></value> + <value>IN_USE</value> + </row> + </table> <table name="gluster_volume_bricks"> <column>id</column> diff --git a/packaging/dbscripts/gluster_volume_snapshot_sp.sql b/packaging/dbscripts/gluster_volume_snapshot_sp.sql new file mode 100644 index 0000000..b1ac761 --- /dev/null +++ b/packaging/dbscripts/gluster_volume_snapshot_sp.sql @@ -0,0 +1,128 @@ +/* ---------------------------------------------------------------- + Stored procedures for database operations on Gluster Volume Snapshot + related tables: + - gluster_volume_snapshots + - gluster_volume_snapshot_config +----------------------------------------------------------------*/ + +Create or replace FUNCTION InsertGlusterVolumeSnapshot(v_snapshot_id UUID, + v_snapshot_name VARCHAR(1000), + v_reference_entity_id UUID, + v_created_at TIMESTAMP WITH TIME ZONE, + v_description VARCHAR(1024), + v_status VARCHAR(32)) + RETURNS VOID + AS $procedure$ +BEGIN + INSERT INTO gluster_volume_snapshots (snapshot_id, snapshot_name, reference_entity_id, + created_at, description, status) + VALUES (v_snapshot_id, v_snapshot_name, v_reference_entity_id, v_created_at, + v_description, v_status); +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION GetGlusterVolumeSnapshotById(v_snapshot_id UUID) + RETURNS SETOF gluster_volume_snapshots STABLE + AS $procedure$ +BEGIN + RETURN QUERY SELECT * + FROM gluster_volume_snapshots + WHERE snapshot_id = v_snapshot_id; +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION GetGlusterVolumeSnapshotsByVolumeId(v_reference_entity_id UUID) +RETURNS SETOF gluster_volume_snapshots STABLE +AS $procedure$ +BEGIN + RETURN QUERY SELECT * + FROM gluster_volume_snapshots + WHERE reference_entity_id = v_reference_entity_id; +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION GetGlusterVolumeSnapshotByName(v_reference_entity_id UUID, + v_snapshot_name VARCHAR(1000)) +RETURNS SETOF gluster_volume_snapshots STABLE + AS $procedure$ +BEGIN + RETURN QUERY SELECT * + FROM gluster_volume_snapshots + WHERE reference_entity_id = v_reference_entity_id and snapshot_name = v_snapshot_name; +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION DeleteGlusterVolumeSnapshotByGuid(v_snapshot_id UUID) + RETURNS VOID + AS $procedure$ +BEGIN + DELETE FROM gluster_volume_snapshots + WHERE snapshot_id = v_snapshot_id; +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION DeleteGlusterSnapshotsByVolumeId(v_reference_entity_id UUID) + RETURNS VOID + AS $procedure$ +BEGIN + DELETE FROM gluster_volume_snapshots + WHERE reference_entity_id = v_reference_entity_id; +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION DeleteGlusterVolumeSnapshotByName(v_reference_entity_id UUID, + v_snapshot_name VARCHAR(1000)) + RETURNS VOID + AS $procedure$ +BEGIN + DELETE FROM gluster_volume_snapshots + WHERE reference_entity_id = v_reference_entity_id + AND snapshot_name = v_snapshot_name; +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION DeleteGlusterVolumesSnapshotByIds(v_snapshot_ids VARCHAR(5000)) + RETURNS VOID + AS $procedure$ +BEGIN +DELETE FROM gluster_volume_snapshots +WHERE snapshot_id in (select * from fnSplitterUuid(v_snapshot_ids)); +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION UpdateGlusterVolumeSnapshotStatus(v_snapshot_id UUID, + v_status VARCHAR(32)) + RETURNS VOID + AS $procedure$ +BEGIN + UPDATE gluster_volume_snapshots + SET status = v_status, + _update_date = LOCALTIMESTAMP + WHERE snapshot_id = v_snapshot_id; +END; $procedure$ +LANGUAGE plpgsql; + + +Create or replace FUNCTION UpdateGlusterVolumeSnapshotStatusByName(v_reference_entity_id UUID, + v_snapshot_name VARCHAR(1000), + v_status VARCHAR(32)) + RETURNS VOID + AS $procedure$ +BEGIN + UPDATE gluster_volume_snapshots + SET status = v_status, + _update_date = LOCALTIMESTAMP + WHERE reference_entity_id = v_reference_entity_id + AND snapshot_name = v_snapshot_name; +END; $procedure$ +LANGUAGE plpgsql; + + diff --git a/packaging/dbscripts/upgrade/03_04_0400_add_gluster_volume_snapshot_tables.sql b/packaging/dbscripts/upgrade/03_04_0480_add_gluster_volume_snapshot_tables.sql similarity index 100% rename from packaging/dbscripts/upgrade/03_04_0400_add_gluster_volume_snapshot_tables.sql rename to packaging/dbscripts/upgrade/03_04_0480_add_gluster_volume_snapshot_tables.sql diff --git a/packaging/dbscripts/upgrade/03_04_0410_add_snapshot_enabled_flag_to_gluster_volumes.sql b/packaging/dbscripts/upgrade/03_04_0490_add_snapshot_enabled_flag_to_gluster_volumes.sql similarity index 100% rename from packaging/dbscripts/upgrade/03_04_0410_add_snapshot_enabled_flag_to_gluster_volumes.sql rename to packaging/dbscripts/upgrade/03_04_0490_add_snapshot_enabled_flag_to_gluster_volumes.sql -- To view, visit http://gerrit.ovirt.org/23372 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id60902aad02b852773ad398aaac9bad8ed7793ab 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
