Oved Ourfali has uploaded a new change for review. Change subject: core: fix the fn_db_split_config_value db function and uses ......................................................................
core: fix the fn_db_split_config_value db function and uses Previous patch added the fn_db_split_config_value, to take general value, and update it with a newer one, splitting to versions. The previous implementation of the function updated the newest version to the input value, which will work well on upgrade, but not for new installations. New implementation of this function takes the version from which we need to split, and updates all the versions from it and byeond. Will work well for new installation (split general to the different versions), and for upgrades (new version, if there is one, will get the input value). Also, adding new supported secured spice channels (smartcard and usbredir), both to the config and to the config tool. Change-Id: I6964750ed0f57155e7c64a2a29ee0c21e2043410 Signed-off-by: Oved Ourfali <[email protected]> --- M backend/manager/dbscripts/common_sp.sql M backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java M backend/manager/tools/engine-config/src/main/resources/engine-config.properties 4 files changed, 16 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/73/7973/1 diff --git a/backend/manager/dbscripts/common_sp.sql b/backend/manager/dbscripts/common_sp.sql index 8aa83c2..83717e1 100644 --- a/backend/manager/dbscripts/common_sp.sql +++ b/backend/manager/dbscripts/common_sp.sql @@ -281,8 +281,8 @@ LANGUAGE plpgsql; -- This function splits a config value: given a config value with one row for 'general', it creates new options --- with the old value, for each version, except the newest version, which gets the input value -CREATE OR REPLACE FUNCTION fn_db_split_config_value(v_option_name character varying, v_old_option_value character varying, v_new_option_value character varying) +-- with the old value, for each version, except the v_update_from_version version and beyond, which gets the input value +CREATE OR REPLACE FUNCTION fn_db_split_config_value(v_option_name character varying, v_old_option_value character varying, v_new_option_value character varying, v_update_from_version character varying) RETURNS void AS $BODY$ declare @@ -292,10 +292,12 @@ v_index integer; v_count integer; v_total_count integer; +v_version_count integer; begin v_total_count := count(version) from vdc_options where option_name = v_option_name; v_old_value := option_value from vdc_options where option_name = v_option_name and version = 'general'; - if (v_total_count <= 1) then + v_version_count := count(distinct version) from vdc_options where version <> 'general'; + if (v_total_count <= v_version_count) then begin if (v_old_value IS NULL) then v_old_value := v_old_option_value; @@ -306,10 +308,13 @@ loop fetch v_cur into v_version; exit when not found; - if (v_index = v_count) then - insert into vdc_options (option_name, option_value, version) values (v_option_name, v_new_option_value, v_version); - else - insert into vdc_options (option_name, option_value, version) values (v_option_name, v_old_value, v_version); + -- We shouldn't update if already exists + if (not exists (select 1 from vdc_options where option_name = v_option_name and version = v_version)) then + if (v_version >= v_update_from_version) then + insert into vdc_options (option_name, option_value, version) values (v_option_name, v_new_option_value, v_version); + else + insert into vdc_options (option_name, option_value, version) values (v_option_name, v_old_value, v_version); + end if; end if; v_index := v_index +1; end loop; diff --git a/backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql b/backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql index 4f4115d..5eedf3b 100644 --- a/backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql +++ b/backend/manager/dbscripts/upgrade/pre_upgrade/0000_config.sql @@ -575,9 +575,9 @@ -- To ease this the fn_db_split_config_value can be used, input is the -- option_name, the old value and the new value. Result is creating one row for each old -- cluster level with the original value if exists, or the input old value --- and one row for the newest one, with the input value. +-- and from the update version and beyond, the input value. ------------------------------------------------------------------------------------ -select fn_db_split_config_value('SpiceSecureChannels','smain,sinputs','smain,sinputs,scursor,splayback,srecord,sdisplay'); +select fn_db_split_config_value('SpiceSecureChannels','smain,sinputs','smain,sinputs,scursor,splayback,srecord,sdisplay,susbredir,ssmartcard', '3.1'); ------------------------------------------------------------------------------------ -- Simple direct updates section diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java index 71ec451..dc6f8da 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java @@ -405,7 +405,7 @@ SearchesRefreshRateInSeconds(116), @Reloadable @TypeConverterAttribute(String.class) - @DefaultValueAttribute("smain,sinputs,scursor,splayback,srecord,sdisplay") + @DefaultValueAttribute("smain,sinputs,scursor,splayback,srecord,sdisplay,ssmartcard,susbredir") SpiceSecureChannels(117), @Deprecated @TypeConverterAttribute(Integer.class) diff --git a/backend/manager/tools/engine-config/src/main/resources/engine-config.properties b/backend/manager/tools/engine-config/src/main/resources/engine-config.properties index ab9994b..59deac9 100644 --- a/backend/manager/tools/engine-config/src/main/resources/engine-config.properties +++ b/backend/manager/tools/engine-config/src/main/resources/engine-config.properties @@ -115,7 +115,7 @@ SpiceReleaseCursorKeys.description="Keyboard keys combination that causes the mouse cursor to be released from its grab on SPICE" SpiceSecureChannels.description="SPICE Secure Channels" SpiceSecureChannels.type=StringMultiple -SpiceSecureChannels.validValues=smain,sinputs,scursor,splayback,srecord,sdisplay +SpiceSecureChannels.validValues=smain,sinputs,scursor,splayback,srecord,sdisplay,ssmartcard,susbredir SpiceToggleFullScreenKeys.description="Keyboard keys combination that toggles the full-screen state of SPICE client window" SpiceUsbAutoShare.description="Enable USB devices sharing by default in SPICE" SpiceUsbAutoShare.validValues=true,false -- To view, visit http://gerrit.ovirt.org/7973 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6964750ed0f57155e7c64a2a29ee0c21e2043410 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Oved Ourfali <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
