Hello Eli Mesika, I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/40072 to review the following change. Change subject: dbutils: Enable unlock utility handle all entities ...................................................................... dbutils: Enable unlock utility handle all entities This patch enables engine-setup to unlock all entities in one call. This is done in order to prevent upgrade of engine and database while some entities are still locked. Change-Id: I494dece6ba871727750f3fccacd95490294bea6e Signed-off-by: emesika <emes...@redhat.com> --- M packaging/dbscripts/common_sp.sql M packaging/dbscripts/unlock_entity.sh 2 files changed, 52 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/40072/1 diff --git a/packaging/dbscripts/common_sp.sql b/packaging/dbscripts/common_sp.sql index 8ba08d6..505416f 100644 --- a/packaging/dbscripts/common_sp.sql +++ b/packaging/dbscripts/common_sp.sql @@ -527,6 +527,36 @@ END; $procedure$ LANGUAGE plpgsql; +-- Unlocks all locked entities +create or replace FUNCTION fn_db_unlock_all() +returns void +AS $procedure$ +declare + DOWN integer; + OK integer; + LOCKED integer; + TEMPLATE_OK integer; + TEMPLATE_LOCKED integer; + IMAGE_LOCKED integer; + SNAPSHOT_OK varchar; + SNAPSHOT_LOCKED varchar; +BEGIN + DOWN:=0; + OK:=1; + LOCKED:=2; + TEMPLATE_OK:=0; + TEMPLATE_LOCKED:=1; + IMAGE_LOCKED:=15; + SNAPSHOT_OK:='OK'; + SNAPSHOT_LOCKED:='LOCKED'; + update vm_static set template_status = TEMPLATE_OK where template_status = TEMPLATE_LOCKED; + update vm_dynamic set status = DOWN where status = IMAGE_LOCKED; + update images set imagestatus = OK where imagestatus = LOCKED; + update snapshots set status = SNAPSHOT_OK where status ilike SNAPSHOT_LOCKED; +END; $procedure$ +LANGUAGE plpgsql; + + /* Displays DC id , DC name, SPM Host id , SPM Host name and number of async tasks awaiting. 1) create a record type with DC name, DC id, SPM host id, SPM host name, count diff --git a/packaging/dbscripts/unlock_entity.sh b/packaging/dbscripts/unlock_entity.sh index bc510d6..5c95e16 100755 --- a/packaging/dbscripts/unlock_entity.sh +++ b/packaging/dbscripts/unlock_entity.sh @@ -20,7 +20,8 @@ -p PORT - The database port for the database (def. ${DBFUNC_DB_PORT}) -u USER - The username for the database (def. ${DBFUNC_DB_USER}) -d DATABASE - The database name (def. ${DBFUNC_DB_DATABASE}) - -t TYPE - The object type {vm | template | disk | snapshot} + -t TYPE - The object type {all | vm | template | disk | snapshot} + If "all" is used then no ENTITIES are expected. -r - Recursive, unlocks all disks under the selected vm/template. -q - Query db and display a list of the locked entites. ENTITIES - The list of object names in case of vm/template, UUIDs in case of a disk @@ -52,6 +53,8 @@ CMD="select fn_db_unlock_disk('${id}');" elif [ "${object_type}" = "snapshot" ]; then CMD="select fn_db_unlock_snapshot('${id}');" + elif [ "${object_type}" = "all" ]; then + CMD="select fn_db_unlock_all();" else printf "Error: $* " fi @@ -205,18 +208,24 @@ IDS="$@" [ -n "${TYPE}" ] || die "Please specify type" -[ -z "${IDS}" -a -z "${QUERY}" ] && die "Please specify ids or query" -[ -n "${IDS}" -a -n "${QUERY}" ] && die "Please specify one ids or query" +if [ "${TYPE}" != "all" ]; then + [ -z "${IDS}" -a -z "${QUERY}" ] && die "Please specify ids or query" + [ -n "${IDS}" -a -n "${QUERY}" ] && die "Please specify one ids or query" +fi -if [ -n "${IDS}" ]; then - echo "Caution, this operation may lead to data corruption and should be used with care. Please contact support prior to running this command" - echo "Are you sure you want to proceed? [y/n]" - read answer - [ "${answer}" = "y" ] || die "Please contact support for further assistance." - - for ID in ${IDS} ; do - entity_unlock "${TYPE}" "${ID}" "$(whoami)" ${RECURSIVE} - done -elif [ -n "${QUERY}" ]; then +if [ -n "${QUERY}" ]; then entity_query "${TYPE}" +else + if [ "${TYPE}" = "all" ]; then + entity_unlock "${TYPE}" "" "$(whoami)" ${RECURSIVE} + else + echo "Caution, this operation may lead to data corruption and should be used with care. Please contact support prior to running this command" + echo "Are you sure you want to proceed? [y/n]" + read answer + [ "${answer}" = "y" ] || die "Please contact support for further assistance." + + for ID in ${IDS} ; do + entity_unlock "${TYPE}" "${ID}" "$(whoami)" ${RECURSIVE} + done + fi fi -- To view, visit https://gerrit.ovirt.org/40072 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I494dece6ba871727750f3fccacd95490294bea6e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com> Gerrit-Reviewer: Eli Mesika <emes...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches