Moti Asayag has uploaded a new change for review. Change subject: engine: Add proc for updating a host available updates ......................................................................
engine: Add proc for updating a host available updates The stored procedure performs the exact minimal changes required for updating the availability of updates for the given host. Change-Id: Ie76af614aea740f6ccd5a1ce5d611be67f8827d1 Signed-off-by: Moti Asayag <[email protected]> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java M packaging/dbscripts/vds_sp.sql 4 files changed, 43 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/40833/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java index 045cb02..60f4dc9 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java @@ -50,4 +50,14 @@ * @return list of host ids */ List<Guid> getIdsOfHostsWithStatus(VDSStatus status); + + /** + * Updates the updateAvaiable flag of the given host + * + * @param id + * the ID of the updates host + * @param updateAvailable + * the new value to be updated + */ + void updateUpdateAvailable(Guid id, boolean updateAvailable); } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java index 26a7a27..768fd2d 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java @@ -311,4 +311,12 @@ .addValue("status", status.getValue())); } + @Override + public void updateUpdateAvailable(Guid id, boolean updateAvailable) { + MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() + .addValue("vds_guid", id) + .addValue("is_update_available", updateAvailable); + + getCallsHandler().executeModification("UpdateVdsDynamicIsUpdateAvailable", parameterSource); + } } diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java index 81ceb68..73633f6 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java @@ -1,6 +1,7 @@ package org.ovirt.engine.core.dao; 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; @@ -173,4 +174,14 @@ hostIds = dao.getIdsOfHostsWithStatus(VDSStatus.Maintenance); assertEquals(0, hostIds.size()); } + + @Test + public void testUpdateAvailableUpdates() { + VdsDynamic before = dao.get(existingVds.getId()); + assertFalse(before.isUpdateAvailable()); + before.setUpdateAvailable(true); + dao.updateUpdateAvailable(before.getId(), before.isUpdateAvailable()); + VdsDynamic after = dao.get(existingVds.getId()); + assertEquals(before.isUpdateAvailable(), after.isUpdateAvailable()); + } } diff --git a/packaging/dbscripts/vds_sp.sql b/packaging/dbscripts/vds_sp.sql index c8ef182..0caa770 100644 --- a/packaging/dbscripts/vds_sp.sql +++ b/packaging/dbscripts/vds_sp.sql @@ -896,6 +896,20 @@ END; $procedure$ LANGUAGE plpgsql; +Create or replace FUNCTION UpdateVdsDynamicIsUpdateAvailable( + v_vds_guid UUID, + v_is_update_available BOOLEAN) +RETURNS VOID + + AS $procedure$ +BEGIN + UPDATE vds_dynamic + SET + is_update_available = v_is_update_available + WHERE vds_id = v_vds_guid; +END; $procedure$ +LANGUAGE plpgsql; + Create or replace FUNCTION UpdatePartialVdsDynamicCalc( v_vds_guid UUID, v_vmCount INTEGER, -- To view, visit https://gerrit.ovirt.org/40833 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie76af614aea740f6ccd5a1ce5d611be67f8827d1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Moti Asayag <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
