Roy Golan has uploaded a new change for review. Change subject: core: cluster emulation mode - add procedure to set emulatedMachine ......................................................................
core: cluster emulation mode - add procedure to set emulatedMachine Added a procedure to update only the emulated_machine value on a vds_group Change-Id: I7bc4709713078bcd8184ee6d03396522b60c5068 Signed-off-by: Roy Golan <[email protected]> --- M backend/manager/dbscripts/vds_groups_sp.sql 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 backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsGroupDAOTest.java 4 files changed, 38 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/08/15908/1 diff --git a/backend/manager/dbscripts/vds_groups_sp.sql b/backend/manager/dbscripts/vds_groups_sp.sql index ba7c4a9..1a07396 100644 --- a/backend/manager/dbscripts/vds_groups_sp.sql +++ b/backend/manager/dbscripts/vds_groups_sp.sql @@ -199,4 +199,11 @@ END; $procedure$ LANGUAGE plpgsql; +--This SP updates the vds_group emulated machine +Create or replace FUNCTION UpdateVdsGroupEmulatedMachine(v_vds_group_id UUID, v_emulated_machine varchar(40)) RETURNS VOID + AS $procedure$ +BEGIN + UPDATE vds_groups set emulated_machine = v_emulated_machine where vds_group_id = v_vds_group_id; +END; $procedure$ +LANGUAGE plpgsql; 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 6acb5a5..6aba8b6 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 @@ -135,4 +135,11 @@ * @return list of clusters */ List<VDSGroup> getClustersWithPermittedAction(Guid userId, ActionGroup actionGroup); + + /** + * Sets the cluster's emulated machine value + * @param vdsGroupId + * @param emulatedMachine + */ + void setEmulatedMachine(Guid vdsGroupId, String 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 c136426..f4452fa 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 @@ -128,6 +128,15 @@ parameterSource); } + @Override + public void setEmulatedMachine(Guid vdsGroupId, String emulatedMachine) { + MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() + .addValue("vds_group_id", vdsGroupId) + .addValue("emulated_machine", emulatedMachine); + + getCallsHandler().executeModification("UpdateVdsGroupEmulatedMachine", parameterSource); + } + private MapSqlParameterSource getVdsGroupParamSource(VDSGroup group) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("description", group.getdescription()) diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsGroupDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsGroupDAOTest.java index 87ac2bc..b6b586f 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsGroupDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsGroupDAOTest.java @@ -3,15 +3,16 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.util.List; import org.junit.Test; +import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; -import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.Version; @@ -335,6 +336,19 @@ assertNull(result); } + @Test + public void testUpdateEmulatedMachine() { + String preUpdate = existingVdsGroup.getEmulatedMachine(); + String updatedValue = "pc-version-1.2.3"; + + assertNotSame(preUpdate, updatedValue); + + existingVdsGroup.setEmulatedMachine(updatedValue); + dao.setEmulatedMachine(existingVdsGroup.getId(), updatedValue); + + assertEquals(updatedValue, dao.get(existingVdsGroup.getId()).getEmulatedMachine()); + } + /** * Asserts the result from {@link VdsGroupDAO#getAll()} is correct without filtering * -- To view, visit http://gerrit.ovirt.org/15908 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7bc4709713078bcd8184ee6d03396522b60c5068 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Roy Golan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
