summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-14 06:04:57 +0000
committerGerrit Code Review <review@openstack.org>2016-08-14 06:04:57 +0000
commitd097398b2714afd42576db509d2b9d7f60d5502a (patch)
treef705f85ce3641a126b49e1f7a9d0b789fdfa5ac7
parent9e36222ff5c2f2e244584a823099840e06ca0d2a (diff)
parent4f6ce5d5cae5a7ca3ef92ebd90611dacf2ed9f07 (diff)
downloadtrove-integration-d097398b2714afd42576db509d2b9d7f60d5502a.tar.gz
Merge "Add "clean" command to redstack"
-rwxr-xr-xscripts/redstack47
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/redstack b/scripts/redstack
index 6c3e716..75eec90 100755
--- a/scripts/redstack
+++ b/scripts/redstack
@@ -1134,6 +1134,51 @@ function cmd_clear() {
cmd_wipe_queues
}
+function exec_cmd_on_output() {
+ local output_cmd=$1
+ local exec_cmd=$2
+ local skip_id=${3:-""}
+
+ echo "Cleaning up objects from '${output_cmd}'"
+ exec $output_cmd|awk -vexec_cmd="$exec_cmd" -vskip_id="$skip_id" '{if (NR>3 && $2!="" && $2!=skip_id && $2!="|") { cmd = exec_cmd " " $2; print "Executing " cmd; system(cmd) } }'
+}
+
+
+function cmd_clean() {
+ echo "Cleaning up project '${OS_PROJECT_NAME}'"
+ # reset any stuck backups
+ mysql_trove "update backups set state='COMPLETED'"
+ # clear out any DS version metadata
+ mysql_trove "delete from datastore_version_metadata"
+ # reset any stuck instances, and clear all replicas
+ mysql_trove "update instances set task_id=2, slave_of_id=null"
+ # reset any stuck clusters
+ mysql_trove "update clusters set task_id=1"
+ # get rid of any extraneous quota usage
+ mysql_trove "delete from quota_usages"
+
+ source $PATH_DEVSTACK_SRC/openrc admin ${OS_PROJECT_NAME}
+ # delete any trove clusters
+ exec_cmd_on_output "trove cluster-list" "trove cluster-delete"
+ # delete any trove instances
+ exec_cmd_on_output "trove list" "trove delete"
+ # delete any backups
+ exec_cmd_on_output "trove backup-list" "trove backup-delete"
+ # sleep for a bit and then clean up
+ # any remaining nova instances or cinder volumes
+ sleep 5
+ exec_cmd_on_output "nova list" "nova delete"
+ sleep 2
+ exec_cmd_on_output "cinder list" "cinder delete"
+ # delete any config groups since all instances should be gone now
+ exec_cmd_on_output "trove configuration-list" "trove configuration-delete"
+ # delete any modules too
+ exec_cmd_on_output "trove module-list" "trove module-delete"
+ # make sure that security groups are also gone, except the default
+ exec_cmd_on_output "nova secgroup-list" "nova secgroup-delete" "1"
+ echo "If any errors occurred wait a few seconds and run the command again"
+}
+
function cmd_kick_start() {
cmd_test_init $1
cmd_build_and_upload_image $1
@@ -1304,6 +1349,7 @@ function print_usage() {
rd-sql - Opens the Trove MySQL database.
vagrant-ssh - Runs a command from the host on the server.
clear - Destroy instances and rabbit queues.
+ clean - Clean up resources created by a failed test run.
run - Starts RD but not in a screen.
run-fake - Runs the server in fake mode.
update-projects - Git pull on all the daemons trove dependencies.
@@ -1341,6 +1387,7 @@ function run_command() {
"debug" ) shift; echo "Enabling debugging."; \
set -o xtrace; run_command $@;;
"clear" ) shift; cmd_clear $@;;
+ "clean" ) shift; cmd_clean $@;;
"run" ) shift; cmd_run $@;;
"kick-start" ) shift; cmd_kick_start $@;;
"dsvm-gate-tests" ) shift; cmd_dsvm_gate_tests $@;;