Juan Hernandez has uploaded a new change for review. Change subject: core: Don't use PosrgreSQL UUID extension ......................................................................
core: Don't use PosrgreSQL UUID extension Replace the calls to the uuid_generate_v1 function with a custom function uuid_generate_sequential that generates UUIDs from a sequence. Change-Id: I819e37224288b202d2126cec475ee1d97f83a925 Signed-off-by: Juan Hernandez <[email protected]> --- M backend/manager/dbscripts/bookmarks_sp.sql M backend/manager/dbscripts/business_entity_snapshot_sp.sql M backend/manager/dbscripts/common_sp.sql M backend/manager/dbscripts/create_db.sh M backend/manager/dbscripts/create_functions.sql M backend/manager/dbscripts/dbfunctions.sh M backend/manager/dbscripts/engine-db-install.sh M backend/manager/dbscripts/insert_data.sql M backend/manager/dbscripts/inst_sp.sql M backend/manager/dbscripts/tags_sp.sql M backend/manager/dbscripts/upgrade/03_00_0050_make_blank_template_pulic.sql M backend/manager/dbscripts/upgrade/03_00_0300_add_local_admin_user.sql M backend/manager/dbscripts/upgrade/03_01_0220_vm_device_upgrade_data.sql M backend/manager/dbscripts/upgrade/03_01_0370_vm_device_upgrade_data.sql M backend/manager/dbscripts/upgrade/03_01_0440_vm_device_upgrade_data.sql M backend/manager/dbscripts/upgrade/03_01_0520_quota_upgrade_script.sql M backend/manager/dbscripts/upgrade/03_01_0560_vm_device_upgrade_data.sql M backend/manager/dbscripts/upgrade/03_01_0600_migrate_images_to_snapshots.sql M backend/manager/dbscripts/upgrade/03_01_0730_add_empty_cd_to_vm.sql M backend/manager/dbscripts/upgrade/03_01_0740_add_vm_device_soundcard.sql M backend/manager/dbscripts/upgrade/03_01_0950_add_permissions_on_storage_to_users.sql M backend/manager/dbscripts/upgrade/03_01_1090_gluster_brick_option_id.sql A backend/manager/dbscripts/upgrade/pre_upgrade/0030_add_uuid_generator.sql M backend/manager/dbscripts/vds_groups_sp.sql M backend/manager/dbscripts/vds_sp.sql M backend/manager/dbscripts/vm_pools_sp.sql M packaging/fedora/setup/engine_validators.py M packaging/fedora/spec/ovirt-engine.spec.in 28 files changed, 66 insertions(+), 130 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/55/8955/1 diff --git a/backend/manager/dbscripts/bookmarks_sp.sql b/backend/manager/dbscripts/bookmarks_sp.sql index 6304a8d..86c968a 100644 --- a/backend/manager/dbscripts/bookmarks_sp.sql +++ b/backend/manager/dbscripts/bookmarks_sp.sql @@ -13,7 +13,7 @@ AS $procedure$ BEGIN INSERT INTO bookmarks(bookmark_Id,bookmark_name, bookmark_value) - VALUES(uuid_generate_v1(),v_bookmark_name, v_bookmark_value); + VALUES(uuid_generate_sequential(),v_bookmark_name, v_bookmark_value); END; $procedure$ LANGUAGE plpgsql; diff --git a/backend/manager/dbscripts/business_entity_snapshot_sp.sql b/backend/manager/dbscripts/business_entity_snapshot_sp.sql index e5b64be..89da162 100644 --- a/backend/manager/dbscripts/business_entity_snapshot_sp.sql +++ b/backend/manager/dbscripts/business_entity_snapshot_sp.sql @@ -5,7 +5,7 @@ BEGIN BEGIN INSERT INTO business_entity_snapshot(id, command_id, command_type, entity_id,entity_type,entity_snapshot, snapshot_class, snapshot_type,insertion_order) - VALUES(uuid_generate_v1(), v_command_id, v_command_type, v_entity_id,v_entity_type,v_entity_snapshot, v_snapshot_class, v_snapshot_type,v_insertion_order); + VALUES(uuid_generate_sequential(), v_command_id, v_command_type, v_entity_id,v_entity_type,v_entity_snapshot, v_snapshot_class, v_snapshot_type,v_insertion_order); END; RETURN; diff --git a/backend/manager/dbscripts/common_sp.sql b/backend/manager/dbscripts/common_sp.sql index af0187b..95e34f5 100644 --- a/backend/manager/dbscripts/common_sp.sql +++ b/backend/manager/dbscripts/common_sp.sql @@ -208,7 +208,7 @@ insert into users(user_id,name,domain,username,groups,status) select v_user_id, v_name, v_domain, v_user_name,'',1 where not exists (select user_id,name,domain,username,groups,status from users where user_id = v_user_id and name = v_name and domain = v_domain and username = v_user_name and groups = '' and status = 1); -insert into permissions(id,role_id,ad_element_id,object_id,object_type_id) select uuid_generate_v1(), '00000000-0000-0000-0000-000000000001', v_user_id, getGlobalIds('system'), 1 where not exists(select role_id,ad_element_id,object_id,object_type_id from permissions where role_id = '00000000-0000-0000-0000-000000000001' and ad_element_id = v_user_id and object_id= getGlobalIds('system') and object_type_id = 1); +insert into permissions(id,role_id,ad_element_id,object_id,object_type_id) select uuid_generate_sequential(), '00000000-0000-0000-0000-000000000001', v_user_id, getGlobalIds('system'), 1 where not exists(select role_id,ad_element_id,object_id,object_type_id from permissions where role_id = '00000000-0000-0000-0000-000000000001' and ad_element_id = v_user_id and object_id= getGlobalIds('system') and object_type_id = 1); END; $procedure$ LANGUAGE plpgsql; @@ -275,7 +275,7 @@ insert into users(user_id,name,domain,username,groups,status) select input_uuid, v_name, v_domain, v_user_name,'',1 where not exists (select user_id,name,domain,username,groups,status from users where user_id = input_uuid); -insert into permissions(id,role_id,ad_element_id,object_id,object_type_id) select uuid_generate_v1(), '00000000-0000-0000-0000-000000000001', input_uuid, getGlobalIds('system'), 1 where not exists(select role_id,ad_element_id,object_id,object_type_id from permissions where role_id = '00000000-0000-0000-0000-000000000001' and ad_element_id = input_uuid and object_id= getGlobalIds('system') and object_type_id = 1); +insert into permissions(id,role_id,ad_element_id,object_id,object_type_id) select uuid_generate_sequential(), '00000000-0000-0000-0000-000000000001', input_uuid, getGlobalIds('system'), 1 where not exists(select role_id,ad_element_id,object_id,object_type_id from permissions where role_id = '00000000-0000-0000-0000-000000000001' and ad_element_id = input_uuid and object_id= getGlobalIds('system') and object_type_id = 1); END; $BODY$ LANGUAGE plpgsql; diff --git a/backend/manager/dbscripts/create_db.sh b/backend/manager/dbscripts/create_db.sh index 21a5f18..5bdcda0 100755 --- a/backend/manager/dbscripts/create_db.sh +++ b/backend/manager/dbscripts/create_db.sh @@ -7,14 +7,13 @@ set_defaults usage() { - printf "Usage: ${ME} [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] [-u USERNAME] [-f UUID] [-l LOGFILE] [-v]\n" + printf "Usage: ${ME} [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] [-u USERNAME] [-l LOGFILE] [-v]\n" printf "\n" printf "\t-s SERVERNAME - The database servername for the database (def. ${SERVERNAME})\n" printf "\t-p PORT - The database port for the database (def. ${PORT})\n" printf "\t-d DATABASE - The database name (def. ${DATABASE})\n" printf "\t-u USERNAME - The admin username for the database.\n" printf "\t-l LOGFILE - The logfile for capturing output (def. ${LOGFILE})\n" - printf "\t-f UUID - The [optional] location of uuid-ossp.sql file\n" printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" printf "\t-h - This help text.\n" printf "\n" @@ -35,7 +34,6 @@ d) DATABASE=$OPTARG;; u) USERNAME=$OPTARG;; l) LOGFILE=$OPTARG;; - f) UUID=$OPTARG;; v) VERBOSE=true;; h) ret=0 && usage;; \?) ret=1 && usage;; @@ -55,11 +53,8 @@ #set database min error level CMD="ALTER DATABASE \"${DATABASE}\" SET client_min_messages=ERROR;" execute_command "${CMD}" ${DATABASE} ${SERVERNAME} ${PORT}> /dev/null -printf "Inserting UUID functions...\n" echo user name is: ${USERNAME} - -check_and_install_uuid_osspa ${UUID} printf "Creating tables...\n" execute_file "create_tables.sql" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null diff --git a/backend/manager/dbscripts/create_functions.sql b/backend/manager/dbscripts/create_functions.sql index f9f5760..a44ad06 100644 --- a/backend/manager/dbscripts/create_functions.sql +++ b/backend/manager/dbscripts/create_functions.sql @@ -624,4 +624,8 @@ LANGUAGE plpgsql; - +-- +-- We need to run this here because some of the scripts that run after +-- creating the functions use the UUID generator: +-- +\i upgrade/pre_upgrade/0030_add_uuid_generator.sql diff --git a/backend/manager/dbscripts/dbfunctions.sh b/backend/manager/dbscripts/dbfunctions.sh index 27390c3..122bfc3 100755 --- a/backend/manager/dbscripts/dbfunctions.sh +++ b/backend/manager/dbscripts/dbfunctions.sh @@ -314,61 +314,6 @@ echo $(psql --version | head -1 | awk '{print $3}') } -check_and_install_uuid_osspa_pg8() { - if [ $1 ]; then - psql -d ${DATABASE} -U ${USERNAME} -h ${SERVERNAME} -p ${PORT} -f "$1" - return $? - elif [ ! -f /usr/share/pgsql/contrib/uuid-ossp.sql ] ; then - return 1 - else - psql -d ${DATABASE} -U ${USERNAME} -h ${SERVERNAME} -p ${PORT} -f /usr/share/pgsql/contrib/uuid-ossp.sql - return $? - fi -} - -check_and_install_uuid_osspa_pg9() { - # Checks that the extension is installed - CMD_CHECK_INSTALLED="SELECT COUNT(extname) FROM pg_extension WHERE extname='uuid-ossp';" - UUID_INSTALLED=$(expr `execute_command "${CMD_CHECK_INSTALLED}" ${DATABASE} ${SERVERNAME} ${PORT}`) - # Checks that the extension can be installed - CMD_CHECK_AVAILABLE="SELECT COUNT(name) FROM pg_available_extensions WHERE name='uuid-ossp';" - UUID_AVAILABLE=$(expr `execute_command "${CMD_CHECK_AVAILABLE}" ${DATABASE} ${SERVERNAME} ${PORT}`) - - # If uuid is not installed, check whether it's available and install - if [ $UUID_INSTALLED -eq 1 ]; then - return 0 - else - if [ $UUID_AVAILABLE -eq 0 ]; then - return 1 - else - CMD="CREATE EXTENSION \"uuid-ossp\";" - execute_command "${CMD}" ${DATABASE} ${SERVERNAME} ${PORT} > /dev/null - return $? - fi - fi -} - -check_and_install_uuid_osspa() { - - if [ $(pg_version | egrep "^9.1") ]; then - echo "Creating uuid-ossp extension..." - check_and_install_uuid_osspa_pg9 $1 - else - echo "adding uuid-ossp.sql from contrib..." - check_and_install_uuid_osspa_pg8 $1 - fi - - if [ $? -ne 0 ]; then - printf "\nThe uuid-ossp extension is not available." - printf "\nIt is possible the 'postgresql-contrib' package was not installed.\n" - printf "In order to install the package in Fedora please perform: " - printf "yum install postgresql-contrib\n" - printf "After installation is done, please run create_db.sh script again.\n" - printf "\nAlternatively, specify the location of the file with -f parameter\n" - exit 1 - fi -} - # gets the configuration value of the given option name and version. # usage: <some variable>=get_config_value <name> <version> get_config_value() { diff --git a/backend/manager/dbscripts/engine-db-install.sh b/backend/manager/dbscripts/engine-db-install.sh index f242f05..b3e2069 100755 --- a/backend/manager/dbscripts/engine-db-install.sh +++ b/backend/manager/dbscripts/engine-db-install.sh @@ -19,7 +19,7 @@ CUR_DATE=`date +"%Y_%m_%d_%H_%M_%S"` #list of mandatory rpms - please add here any additional rpms required before configuring the postgresql server -REQUIRED_RPMS=(postgresql-server postgresql postgresql-libs postgresql-contrib uuid) +REQUIRED_RPMS=(postgresql-server postgresql postgresql-libs) #postgresql data dir PGDATA=/var/lib/pgsql/data @@ -363,22 +363,6 @@ # Create user $DB_USER + password PGPASSFILE="${ENGINE_PGPASS}" $PSQL -U $DB_ADMIN -c "CREATE ROLE $DB_USER WITH CREATEDB LOGIN ENCRYPTED PASSWORD '$DB_PASS'" >> $LOGFILE 2>&1 _verifyRC $? "failed creating user $DB_USER with encrypted password" - - # Handle UUID extensions - pushd $ENGINE_DB_SCRIPTS_DIR >> $LOGFILE - source ./dbfunctions.sh - source ./dbcustomfunctions.sh - if [ $(pg_version | egrep "^9.1") ]; then - echo "Creating uuid-ossp extension..." - USERNAME=$DB_ADMIN - DATABASE=$TEMPLATE - VERBOSE=false - check_and_install_uuid_osspa_pg9 - else - echo "adding uuid-ossp.sql from contrib..." - PGPASSFILE="${ENGINE_PGPASS}" $PSQL -U $DB_ADMIN -d $TEMPLATE -f $UUID_SQL >> $LOGFILE 2>&1 - fi - popd >> $LOGFILE DB_ADMIN=$DB_USER fi diff --git a/backend/manager/dbscripts/insert_data.sql b/backend/manager/dbscripts/insert_data.sql index 4b7c4cf..98a8d4e 100644 --- a/backend/manager/dbscripts/insert_data.sql +++ b/backend/manager/dbscripts/insert_data.sql @@ -8,7 +8,7 @@ v_id_0009 UUID; BEGIN v_id_0000 := '00000000-0000-0000-0000-000000000000'; - v_storage_pool_id := uuid_generate_v1(); + v_storage_pool_id := uuid_generate_sequential(); v_cluster_id := '99408929-82CF-4DC7-A532-9D998063FA95'; v_id_0009 := '00000000-0000-0000-0000-000000000009'; diff --git a/backend/manager/dbscripts/inst_sp.sql b/backend/manager/dbscripts/inst_sp.sql index 6e76bcf..4bece5a 100644 --- a/backend/manager/dbscripts/inst_sp.sql +++ b/backend/manager/dbscripts/inst_sp.sql @@ -25,7 +25,7 @@ DECLARE v_connection_id UUID; BEGIN - v_connection_id := uuid_generate_v1(); + v_connection_id := uuid_generate_sequential(); if not exists (select 1 from storage_server_connections where connection = v_connection) then -- Insert storage server connection info perform Insertstorage_server_connections(v_connection,cast(v_connection_id as varchar(250)),NULL,NULL,NULL,NULL,1,NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/backend/manager/dbscripts/tags_sp.sql b/backend/manager/dbscripts/tags_sp.sql index df2d5aa..1bea7b5 100644 --- a/backend/manager/dbscripts/tags_sp.sql +++ b/backend/manager/dbscripts/tags_sp.sql @@ -15,7 +15,7 @@ v_type INTEGER) AS $procedure$ BEGIN - v_tag_id := uuid_generate_v1(); + v_tag_id := uuid_generate_sequential(); INSERT INTO tags(tag_id,description, tag_name,parent_id,readonly,type) VALUES(v_tag_id,v_description, v_tag_name,v_parent_id,v_readonly,v_type); END; $procedure$ diff --git a/backend/manager/dbscripts/upgrade/03_00_0050_make_blank_template_pulic.sql b/backend/manager/dbscripts/upgrade/03_00_0050_make_blank_template_pulic.sql index 0f0d0ae..d65a7e0 100644 --- a/backend/manager/dbscripts/upgrade/03_00_0050_make_blank_template_pulic.sql +++ b/backend/manager/dbscripts/upgrade/03_00_0050_make_blank_template_pulic.sql @@ -2,7 +2,7 @@ -- make blank template public insert into permissions (id,role_id,ad_element_id,object_id,object_type_id) - select uuid_generate_v1(), + select uuid_generate_sequential(), 'DEF00009-0000-0000-0000-DEF000000009', -- TemplateUser getGlobalIds('everyone'), '00000000-0000-0000-0000-000000000000', -- blank template id -- diff --git a/backend/manager/dbscripts/upgrade/03_00_0300_add_local_admin_user.sql b/backend/manager/dbscripts/upgrade/03_00_0300_add_local_admin_user.sql index 19ca0f5..ec73410 100644 --- a/backend/manager/dbscripts/upgrade/03_00_0300_add_local_admin_user.sql +++ b/backend/manager/dbscripts/upgrade/03_00_0300_add_local_admin_user.sql @@ -11,7 +11,7 @@ where not exists (select 1 from users where user_id = v_user_id); insert into permissions(id,role_id,ad_element_id,object_id,object_type_id) - select uuid_generate_v1(), '00000000-0000-0000-0000-000000000001', v_user_id, getGlobalIds('system'), 1 + select uuid_generate_sequential(), '00000000-0000-0000-0000-000000000001', v_user_id, getGlobalIds('system'), 1 where not exists (select 1 from permissions where role_id = '00000000-0000-0000-0000-000000000001' and diff --git a/backend/manager/dbscripts/upgrade/03_01_0220_vm_device_upgrade_data.sql b/backend/manager/dbscripts/upgrade/03_01_0220_vm_device_upgrade_data.sql index 02218ad..d07b991 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0220_vm_device_upgrade_data.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0220_vm_device_upgrade_data.sql @@ -30,7 +30,7 @@ insert INTO vm_device( device_id, vm_id,type,device,address,boot_order,spec_params,is_managed,is_plugged,is_shared,is_readonly) - values ( uuid_generate_v1(), v_vm_id, 'video', v_display_type, '', null, v_display_mem, true, null, false, false); + values ( uuid_generate_sequential(), v_vm_id, 'video', v_display_type, '', null, v_display_mem, true, null, false, false); end loop; else @@ -167,7 +167,7 @@ -- insert CDROM to vm_device (only 1 is supported currently) insert INTO vm_device( device_id, vm_id, type, device, address, boot_order, spec_params, is_managed, is_plugged, is_shared, is_readonly) - select uuid_generate_v1(), vm_guid, 'disk', 'cdrom', '', null, iso_path, true , null, false, false + select uuid_generate_sequential(), vm_guid, 'disk', 'cdrom', '', null, iso_path, true , null, false, false from vm_static where iso_path != ''; OPEN v_cur; diff --git a/backend/manager/dbscripts/upgrade/03_01_0370_vm_device_upgrade_data.sql b/backend/manager/dbscripts/upgrade/03_01_0370_vm_device_upgrade_data.sql index 9f44deb..7f761db 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0370_vm_device_upgrade_data.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0370_vm_device_upgrade_data.sql @@ -29,7 +29,7 @@ for i in 1..v_new_num_of_monitors loop insert INTO vm_device( device_id, vm_id,type,device,address,boot_order,spec_params,is_managed,is_plugged,is_readonly) - values ( uuid_generate_v1(), v_vm_id, 'video', v_display_type, '', null, v_display_mem, true, null, false); + values ( uuid_generate_sequential(), v_vm_id, 'video', v_display_type, '', null, v_display_mem, true, null, false); end loop; else @@ -167,7 +167,7 @@ -- insert CDROM to vm_device (only 1 is supported currently) insert INTO vm_device( device_id, vm_id, type, device, address, boot_order, spec_params, is_managed, is_plugged, is_readonly) - select uuid_generate_v1(), vm_guid, 'disk', 'cdrom', '', null, 'path=' || iso_path, true , null, false + select uuid_generate_sequential(), vm_guid, 'disk', 'cdrom', '', null, 'path=' || iso_path, true , null, false from vm_static where iso_path != ''; OPEN v_cur; diff --git a/backend/manager/dbscripts/upgrade/03_01_0440_vm_device_upgrade_data.sql b/backend/manager/dbscripts/upgrade/03_01_0440_vm_device_upgrade_data.sql index 1be2ae4..25727e7 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0440_vm_device_upgrade_data.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0440_vm_device_upgrade_data.sql @@ -29,7 +29,7 @@ for i in 1..v_new_num_of_monitors loop insert INTO vm_device( device_id, vm_id,type,device,address,boot_order,spec_params,is_managed,is_plugged,is_readonly) - values ( uuid_generate_v1(), v_vm_id, 'video', v_display_type, '', null, v_display_mem, true, null, false); + values ( uuid_generate_sequential(), v_vm_id, 'video', v_display_type, '', null, v_display_mem, true, null, false); end loop; else @@ -167,7 +167,7 @@ -- insert CDROM to vm_device (only 1 is supported currently) insert INTO vm_device( device_id, vm_id, type, device, address, boot_order, spec_params, is_managed, is_plugged, is_readonly) - select uuid_generate_v1(), vm_guid, 'disk', 'cdrom', '', null, 'path=' || iso_path, true , null, false + select uuid_generate_sequential(), vm_guid, 'disk', 'cdrom', '', null, 'path=' || iso_path, true , null, false from vm_static where iso_path != ''; OPEN v_cur; diff --git a/backend/manager/dbscripts/upgrade/03_01_0520_quota_upgrade_script.sql b/backend/manager/dbscripts/upgrade/03_01_0520_quota_upgrade_script.sql index 58dc651..1861c59 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0520_quota_upgrade_script.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0520_quota_upgrade_script.sql @@ -23,7 +23,7 @@ -- FROM storage_pool -- WHERE id NOT IN (SELECT DISTINCT storage_pool_id FROM quota)) -- LOOP --- quota_uuid := uuid_generate_v1(); +-- quota_uuid := uuid_generate_sequential(); -- -- Insert unlimited Quota for storage pool -- INSERT -- INTO quota @@ -48,7 +48,7 @@ -- true); -- -- -- Set quota limitations of unlimited Quota --- quota_limitation_uuid := uuid_generate_v1(); +-- quota_limitation_uuid := uuid_generate_sequential(); -- INSERT -- INTO quota_limitation -- (id, @@ -88,7 +88,7 @@ -- WHERE id = cur.id; -- -- insert into permissions (id,role_id,ad_element_id,object_id,object_type_id) --- values(uuid_generate_v1(), +-- values(uuid_generate_sequential(), -- 'def0000a-0000-0000-0000-def00000000a', -- Quota consume role -- getGlobalIds('everyone'), -- quota_uuid, -- quota id -- diff --git a/backend/manager/dbscripts/upgrade/03_01_0560_vm_device_upgrade_data.sql b/backend/manager/dbscripts/upgrade/03_01_0560_vm_device_upgrade_data.sql index 46d8408..ce5953b 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0560_vm_device_upgrade_data.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0560_vm_device_upgrade_data.sql @@ -29,7 +29,7 @@ for i in 1..v_new_num_of_monitors loop insert INTO vm_device( device_id, vm_id,type,device,address,boot_order,spec_params,is_managed,is_plugged,is_readonly) - values ( uuid_generate_v1(), v_vm_id, 'video', v_display_type, '', null, v_display_mem, true, null, false); + values ( uuid_generate_sequential(), v_vm_id, 'video', v_display_type, '', null, v_display_mem, true, null, false); end loop; else @@ -167,7 +167,7 @@ -- insert CDROM to vm_device (only 1 is supported currently) insert INTO vm_device( device_id, vm_id, type, device, address, boot_order, spec_params, is_managed, is_plugged, is_readonly) - select uuid_generate_v1(), vm_guid, 'disk', 'cdrom', '', null, 'path=' || iso_path, true , null, false + select uuid_generate_sequential(), vm_guid, 'disk', 'cdrom', '', null, 'path=' || iso_path, true , null, false from vm_static where iso_path != ''; OPEN v_cur; diff --git a/backend/manager/dbscripts/upgrade/03_01_0600_migrate_images_to_snapshots.sql b/backend/manager/dbscripts/upgrade/03_01_0600_migrate_images_to_snapshots.sql index 0a7bb2d..f31f718 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0600_migrate_images_to_snapshots.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0600_migrate_images_to_snapshots.sql @@ -131,7 +131,7 @@ status, creation_date) VALUES ( - uuid_generate_v1(), + uuid_generate_sequential(), cur.vm_guid, 'ACTIVE', 'OK', diff --git a/backend/manager/dbscripts/upgrade/03_01_0730_add_empty_cd_to_vm.sql b/backend/manager/dbscripts/upgrade/03_01_0730_add_empty_cd_to_vm.sql index d1e72ab..3011932 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0730_add_empty_cd_to_vm.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0730_add_empty_cd_to_vm.sql @@ -14,7 +14,7 @@ LOOP FETCH v_cur INTO v_vm_id; EXIT WHEN NOT FOUND; - v_device_id:=uuid_generate_v1(); + v_device_id:=uuid_generate_sequential(); v_spec_params:= 'path=' || ',deviceId=' || v_device_id; if not exists (select vm_id from vm_device where vm_id = v_vm_id and type = 'disk' and device = 'cdrom') then insert into vm_device( diff --git a/backend/manager/dbscripts/upgrade/03_01_0740_add_vm_device_soundcard.sql b/backend/manager/dbscripts/upgrade/03_01_0740_add_vm_device_soundcard.sql index e36cfb9..712a770 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0740_add_vm_device_soundcard.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0740_add_vm_device_soundcard.sql @@ -20,7 +20,7 @@ v_soundcard := 'ich6'; end case; if not exists (select 1 from vm_device where vm_id = v_record.vm_guid and type = 'sound') then - v_device_id := uuid_generate_v1(); + v_device_id := uuid_generate_sequential(); v_spec_params := 'deviceId=' || v_device_id; insert INTO vm_device( device_id, vm_id,type,device,address,boot_order,spec_params,is_managed,is_plugged,is_readonly) diff --git a/backend/manager/dbscripts/upgrade/03_01_0950_add_permissions_on_storage_to_users.sql b/backend/manager/dbscripts/upgrade/03_01_0950_add_permissions_on_storage_to_users.sql index c4ad004..1621be2 100644 --- a/backend/manager/dbscripts/upgrade/03_01_0950_add_permissions_on_storage_to_users.sql +++ b/backend/manager/dbscripts/upgrade/03_01_0950_add_permissions_on_storage_to_users.sql @@ -40,7 +40,7 @@ ad_element_id, object_id, object_type_id) - (SELECT uuid_generate_v1(), + (SELECT uuid_generate_sequential(), v_DISK_OPERATOR_ROLE_ID, ad_element_id, v_VmDisks.disk_id, @@ -65,7 +65,7 @@ ad_element_id, object_id, object_type_id) - (SELECT uuid_generate_v1(), + (SELECT uuid_generate_sequential(), v_DISK_CREATOR_ROLE_ID, v_permissions.ad_element_id, storage_pool_iso_map.storage_id, @@ -81,7 +81,7 @@ ad_element_id, object_id, object_type_id) - (SELECT uuid_generate_v1(), + (SELECT uuid_generate_sequential(), v_DISK_CREATOR_ROLE_ID, v_permissions.ad_element_id, storage_pool_iso_map.storage_id, @@ -96,7 +96,7 @@ ad_element_id, object_id, object_type_id) - (SELECT uuid_generate_v1(), + (SELECT uuid_generate_sequential(), v_DISK_CREATOR_ROLE_ID, v_permissions.ad_element_id, storage_domain_static.id, diff --git a/backend/manager/dbscripts/upgrade/03_01_1090_gluster_brick_option_id.sql b/backend/manager/dbscripts/upgrade/03_01_1090_gluster_brick_option_id.sql index 5fdd7e0..1e53d0b 100644 --- a/backend/manager/dbscripts/upgrade/03_01_1090_gluster_brick_option_id.sql +++ b/backend/manager/dbscripts/upgrade/03_01_1090_gluster_brick_option_id.sql @@ -1,13 +1,13 @@ -- Add the "id" column and make it the primary key SELECT fn_db_add_column('gluster_volume_bricks', 'id', 'UUID'); -UPDATE gluster_volume_bricks set id = uuid_generate_v1(); +UPDATE gluster_volume_bricks set id = uuid_generate_sequential(); ALTER TABLE gluster_volume_bricks DROP CONSTRAINT pk_gluster_volume_bricks; ALTER TABLE gluster_volume_bricks ADD CONSTRAINT pk_gluster_volume_bricks PRIMARY KEY(id); ALTER TABLE gluster_volume_bricks ADD CONSTRAINT IDX_gluster_volume_bricks_volume_server_brickdir UNIQUE(volume_id, server_id, brick_dir); -- Add the "id" column and make it the primary key SELECT fn_db_add_column('gluster_volume_options', 'id', 'UUID'); -UPDATE gluster_volume_options set id = uuid_generate_v1(); +UPDATE gluster_volume_options set id = uuid_generate_sequential(); ALTER TABLE gluster_volume_options DROP CONSTRAINT pk_gluster_volume_options; ALTER TABLE gluster_volume_options ADD CONSTRAINT pk_gluster_volume_options PRIMARY KEY(id); ALTER TABLE gluster_volume_options ADD CONSTRAINT IDX_gluster_volume_options_volume_id_option_key UNIQUE(volume_id, option_key); diff --git a/backend/manager/dbscripts/upgrade/pre_upgrade/0030_add_uuid_generator.sql b/backend/manager/dbscripts/upgrade/pre_upgrade/0030_add_uuid_generator.sql new file mode 100644 index 0000000..f8e8591 --- /dev/null +++ b/backend/manager/dbscripts/upgrade/pre_upgrade/0030_add_uuid_generator.sql @@ -0,0 +1,26 @@ +-- +-- Create the sequence used to generate UUIDs: +-- +create or replace function create_uuid_sequence() returns void +as $procedure$ +begin + if not exists (select 1 from information_schema.sequences where sequence_name = 'uuid_sequence') then + create sequence uuid_sequence increment by 1 start with 1; + end if; +end; $procedure$ +language plpgsql; + +select create_uuid_sequence(); + +drop function create_uuid_sequence(); + +-- +-- This function generates a UUID with a fixed prefix in the first 10 +-- bytes and a number generated from a sequence in the last 6 bytes: +-- +create or replace function uuid_generate_sequential() returns uuid +as $procedure$ +begin + return 'a851fa6f-d5a4-08d2-0598-' || lpad(to_hex(nextval('uuid_sequence')), 12, '0'); +end; $procedure$ +language plpgsql; diff --git a/backend/manager/dbscripts/vds_groups_sp.sql b/backend/manager/dbscripts/vds_groups_sp.sql index b41fbd4..b10bba4 100644 --- a/backend/manager/dbscripts/vds_groups_sp.sql +++ b/backend/manager/dbscripts/vds_groups_sp.sql @@ -25,7 +25,7 @@ v_gluster_service BOOLEAN) AS $procedure$ BEGIN - v_vds_group_id := uuid_generate_v1(); + v_vds_group_id := uuid_generate_sequential(); INSERT INTO vds_groups(vds_group_id,description, name, cpu_name, selection_algorithm, high_utilization, low_utilization, cpu_over_commit_duration_minutes, hypervisor_type, storage_pool_id, max_vds_memory_over_commit, compatibility_version, transparent_hugepages, migrate_on_error, virt_service, gluster_service) diff --git a/backend/manager/dbscripts/vds_sp.sql b/backend/manager/dbscripts/vds_sp.sql index 848c264..ceecc59 100644 --- a/backend/manager/dbscripts/vds_sp.sql +++ b/backend/manager/dbscripts/vds_sp.sql @@ -340,7 +340,7 @@ BEGIN IF v_vds_unique_id IS NULL OR NOT EXISTS(SELECT vds_name FROM vds_static WHERE vds_unique_id = v_vds_unique_id) then BEGIN - v_vds_id := uuid_generate_v1(); + v_vds_id := uuid_generate_sequential(); INSERT INTO vds_static(vds_id,host_name, ip, vds_unique_id, port, vds_group_id, vds_name, server_SSL_enabled,vds_type,vds_strength,pm_type,pm_user,pm_password,pm_port,pm_options,pm_enabled, vds_spm_priority, sshKeyFingerprint) VALUES(v_vds_id,v_host_name, v_ip, v_vds_unique_id, v_port, v_vds_group_id, v_vds_name, v_server_SSL_enabled,v_vds_type,v_vds_strength,v_pm_type,v_pm_user,v_pm_password,v_pm_port,v_pm_options,v_pm_enabled, v_vds_spm_priority, v_sshKeyFingerprint); END; @@ -659,7 +659,7 @@ BEGIN BEGIN - v_vds_id := uuid_generate_v1(); + v_vds_id := uuid_generate_sequential(); INSERT INTO vds_static(vds_id,host_name, ip, vds_unique_id, port, vds_group_id, vds_name, server_SSL_enabled,vds_type,vds_strength,pm_type,pm_user,pm_password, pm_port, pm_options, pm_enabled, vds_spm_priority) VALUES(v_vds_id,v_host_name, v_ip, v_vds_unique_id, v_port, v_vds_group_id, v_vds_name, v_server_SSL_enabled,v_vds_type, v_vds_strength,v_pm_type,v_pm_user,v_pm_password,v_pm_port, v_pm_options, v_pm_enabled, v_vds_spm_priority); diff --git a/backend/manager/dbscripts/vm_pools_sp.sql b/backend/manager/dbscripts/vm_pools_sp.sql index 3508615..638849a 100644 --- a/backend/manager/dbscripts/vm_pools_sp.sql +++ b/backend/manager/dbscripts/vm_pools_sp.sql @@ -12,7 +12,7 @@ v_vds_group_id UUID) AS $procedure$ BEGIN - v_vm_pool_id := uuid_generate_v1(); + v_vm_pool_id := uuid_generate_sequential(); INSERT INTO vm_pools(vm_pool_id,vm_pool_description, vm_pool_name, vm_pool_type,parameters, prestarted_vms, vds_group_id) VALUES(v_vm_pool_id,v_vm_pool_description, v_vm_pool_name,v_vm_pool_type,v_parameters, v_prestarted_vms, v_vds_group_id); END; $procedure$ diff --git a/packaging/fedora/setup/engine_validators.py b/packaging/fedora/setup/engine_validators.py index 3352d95..0b8f5e2 100644 --- a/packaging/fedora/setup/engine_validators.py +++ b/packaging/fedora/setup/engine_validators.py @@ -279,9 +279,6 @@ # DB Create check _checkCreateDbPrivilege(param["DB_ADMIN"], param["DB_HOST"], param["DB_PORT"]) - # UUID extention check. - _checkUUIDExtension(param["DB_ADMIN"], param["DB_HOST"], param["DB_PORT"]) - # Delete DB check _checkDropDbPrivilege(param["DB_ADMIN"], param["DB_HOST"], param["DB_PORT"]) @@ -462,20 +459,6 @@ raise Exception("\n" + output_messages.ERR_DB_DROP_PRIV % dbHost + ".\n") else: logging.info("Successfully deleted database on server %s." % dbHost) - -def _checkUUIDExtension(dbAdminUser, dbHost, dbPort): - """ Check that UUID extension is already loaded and raise Exception if not""" - logging.info("Checking that uuid extension is loaded by default on the remote server") - out, rc = utils.execRemoteSqlCommand(dbAdminUser, dbHost, dbPort, - "ovirt_engine_test", - "SELECT uuid_generate_v1();") - - # Extension was found - if not rc and out and "1 row" in out: - logging.info("Successfully passed UUID check") - else: - logging.error(output_messages.ERR_DB_UUID) - raise Exception(output_messages.ERR_DB_UUID) def _createTempPgPass(dbAdminUser, dbHost, dbPort, dbPass): """docstring for _createTempPgPass""" diff --git a/packaging/fedora/spec/ovirt-engine.spec.in b/packaging/fedora/spec/ovirt-engine.spec.in index c583ebb..d2e8393 100644 --- a/packaging/fedora/spec/ovirt-engine.spec.in +++ b/packaging/fedora/spec/ovirt-engine.spec.in @@ -176,7 +176,6 @@ # For local database: Requires: postgresql-server >= 8.4.7 -Requires: postgresql-contrib >= 8.4.7 # Require JBoss AS 7: Requires: jboss-as >= 7.1.1 -- To view, visit http://gerrit.ovirt.org/8955 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I819e37224288b202d2126cec475ee1d97f83a925 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
