Browse code

Specialize Zaqar's cleanup function

Instead of having mongodb specific cleanup logic in `cleanup_zaqar`,
specialize it to perform clean ups based on the driver that has been
enabled.

Change-Id: I5807a83443b87b2c8d184e0cd2d5563a649c6273

Flavio Percoco authored on 2014/09/08 16:48:27
Showing 1 changed files
... ...
@@ -20,6 +20,7 @@
20 20
 # start_zaqar
21 21
 # stop_zaqar
22 22
 # cleanup_zaqar
23
+# cleanup_zaqar_mongodb
23 24
 
24 25
 # Save trace setting
25 26
 XTRACE=$(set +o | grep xtrace)
... ...
@@ -72,9 +73,17 @@ function is_zaqar_enabled {
72 72
     return 1
73 73
 }
74 74
 
75
-# cleanup_zaqar() - Remove residual data files, anything left over from previous
76
-# runs that a clean run would need to clean up
75
+# cleanup_zaqar() - Cleans up general things from previous
76
+# runs and storage specific left overs.
77 77
 function cleanup_zaqar {
78
+    if [ "$ZAQAR_BACKEND" = 'mongodb' ] ; then
79
+        cleanup_zaqar_mongodb
80
+    fi
81
+}
82
+
83
+# cleanup_zaqar_mongodb() - Remove residual data files, anything left over from previous
84
+# runs that a clean run would need to clean up
85
+function cleanup_zaqar_mongodb {
78 86
     if ! timeout $SERVICE_TIMEOUT sh -c "while ! mongo zaqar --eval 'db.dropDatabase();'; do sleep 1; done"; then
79 87
         die $LINENO "Mongo DB did not start"
80 88
     else
... ...
@@ -116,8 +125,9 @@ function configure_zaqar {
116 116
         iniset $ZAQAR_CONF  drivers storage mongodb
117 117
         iniset $ZAQAR_CONF 'drivers:storage:mongodb' uri mongodb://localhost:27017/zaqar
118 118
         configure_mongodb
119
-        cleanup_zaqar
120 119
     fi
120
+
121
+    cleanup_zaqar
121 122
 }
122 123
 
123 124
 function configure_mongodb {