Hello Martin Peřina,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/18404

to review the following change.

Change subject: engine: Add support for multiple IDs in unlock_entity.sh
......................................................................

engine: Add support for multiple IDs in unlock_entity.sh

Adds support to enter multiple IDs of same type as parameters of
unlock_entity.sh script. This patch make '-i' parameter obsolete
and entity IDs has to be entered as last parameter of the script.
Example:

  unlock_entity.sh -t vm 1 2 3

Change-Id: Ic1f9807eef92b9d4cf6f0c020e059ffe549badf2
Bug-Url: https://bugzilla.redhat.com/960448
Signed-off-by: Martin Perina <[email protected]>
---
M packaging/dbscripts/dbfunctions.sh
M packaging/dbscripts/unlock_entity.sh
2 files changed, 12 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/18404/1

diff --git a/packaging/dbscripts/dbfunctions.sh 
b/packaging/dbscripts/dbfunctions.sh
index 26e844a..d1b016b 100755
--- a/packaging/dbscripts/dbfunctions.sh
+++ b/packaging/dbscripts/dbfunctions.sh
@@ -461,9 +461,9 @@
        execute_command "${CMD}" "${DATABASE}" "${SERVERNAME}" "${PORT}"
        if [ $? -eq 0 ]; then
            log_unlock_entity ${object_type} ${id} ${user}
-           printf "unlock ${object_type} ${id} completed successfully."
+           printf "unlock ${object_type} ${id} completed successfully.\n"
        else
-           printf "unlock ${object_type} ${id} completed with errors.."
+           printf "unlock ${object_type} ${id} completed with errors.\n"
        fi
    fi
 }
diff --git a/packaging/dbscripts/unlock_entity.sh 
b/packaging/dbscripts/unlock_entity.sh
index c9a363f..c256e31 100755
--- a/packaging/dbscripts/unlock_entity.sh
+++ b/packaging/dbscripts/unlock_entity.sh
@@ -8,10 +8,9 @@
 set_defaults
 
 usage() {
-    printf "Usage: ${ME} -t TYPE -i ID [-h] [-s SERVERNAME [-p PORT]] [-d 
DATABASE] [-u USERNAME] [-l LOGFILE] [-r] [-q] [-v]\n"
+    printf "Usage: ${ME} -t TYPE [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] 
[-u USERNAME] [-l LOGFILE] [-r] [-q] [-v] ENTITIES\n"
     printf "\n"
     printf "\t-t TYPE       - The object type {vm | template | disk | 
snapshot} \n"
-    printf "\t-i ID         - The object name in case of vm/template , UUID in 
case of a disk \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"
@@ -21,6 +20,7 @@
     printf "\t-q            - Query db and display a list of the locked 
entites.\n"
     printf "\t-v            - Turn on verbosity                         
(WARNING: lots of output)\n"
     printf "\t-h            - This help text.\n"
+    printf "\tENTITIES      - The list of object names in case of vm/template, 
UUIDs in case of a disk \n"
     printf "\n"
 
     popd>/dev/null
@@ -33,10 +33,9 @@
     fi
 }
 
-while getopts :ht:i:s:d:u:p:l:f:qrv option; do
+while getopts :ht:s:d:u:p:l:f:qrv option; do
     case $option in
         t) TYPE=$OPTARG;;
-        i) ID=$OPTARG;;
         s) SERVERNAME=$OPTARG;;
         p) PORT=$OPTARG;;
         d) DATABASE=$OPTARG;;
@@ -50,6 +49,9 @@
     esac
 done
 
+shift $(( OPTIND - 1 ))
+IDS="$@"
+
 if [ ! -n "${QUERY}" ]; 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]"
@@ -62,8 +64,10 @@
     fi
 fi
 
-if [[ -n "${TYPE}" && -n "${ID}" ]]; then
-    unlock_entity "${TYPE}" "${ID}" "$(whoami)" ${RECURSIVE}
+if [[ -n "${TYPE}" && -n "${IDS}" ]]; then
+    for ID in ${IDS} ; do
+        unlock_entity "${TYPE}" "${ID}" "$(whoami)" ${RECURSIVE}
+    done
 elif [[ -n "${TYPE}" && -n "${QUERY}" ]]; then
     query_locked_entities "${TYPE}"
 else


-- 
To view, visit http://gerrit.ovirt.org/18404
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1f9807eef92b9d4cf6f0c020e059ffe549badf2
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: Martin Peřina <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to