Browse code

Merge "clean logical volumes in init_cinder"

Jenkins authored on 2013/07/15 23:11:19
Showing 1 changed files
... ...
@@ -81,10 +81,9 @@ VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
81 81
 
82 82
 # Functions
83 83
 # ---------
84
-# _cleanup_lvm removes all cinder volumes and the backing file of the
85
-# volume group used by cinder
86
-# _cleanup_lvm $VOLUME_GROUP $VOLUME_NAME_PREFIX
87
-function _cleanup_lvm() {
84
+# _clean_lvm_lv removes all cinder LVM volumes
85
+# _clean_lvm_lv $VOLUME_GROUP $VOLUME_NAME_PREFIX
86
+function _clean_lvm_lv() {
88 87
     local vg=$1
89 88
     local lv_prefix=$2
90 89
 
... ...
@@ -95,6 +94,13 @@ function _cleanup_lvm() {
95 95
             sudo lvremove -f $vg/$lv
96 96
         fi
97 97
     done
98
+}
99
+
100
+# _clean_lvm_backing_file() removes the backing file of the
101
+# volume group used by cinder
102
+# _clean_lvm_backing_file() $VOLUME_GROUP
103
+function _clean_lvm_backing_file() {
104
+    local vg=$1
98 105
 
99 106
     # if there is no logical volume left, it's safe to attempt a cleanup
100 107
     # of the backing file
... ...
@@ -145,10 +151,12 @@ function cleanup_cinder() {
145 145
     fi
146 146
 
147 147
     # Campsite rule: leave behind a volume group at least as clean as we found it
148
-    _cleanup_lvm $VOLUME_GROUP $VOLUME_NAME_PREFIX
148
+    _clean_lvm_lv $VOLUME_GROUP $VOLUME_NAME_PREFIX
149
+    _clean_lvm_backing_file $VOLUME_GROUP
149 150
 
150 151
     if [ "$CINDER_MULTI_LVM_BACKEND" = "True" ]; then
151
-        _cleanup_lvm $VOLUME_GROUP2 $VOLUME_NAME_PREFIX
152
+        _clean_lvm_lv $VOLUME_GROUP2 $VOLUME_NAME_PREFIX
153
+        _clean_lvm_backing_file $VOLUME_GROUP2
152 154
     fi
153 155
 }
154 156
 
... ...
@@ -412,9 +420,9 @@ function init_cinder() {
412 412
             # Remove iscsi targets
413 413
             sudo tgtadm --op show --mode target | grep $VOLUME_NAME_PREFIX | grep Target | cut -f3 -d ' ' | sudo xargs -n1 tgt-admin --delete || true
414 414
             # Start with a clean volume group
415
-            _clean_volume_group $VOLUME_GROUP $VOLUME_NAME_PREFIX
415
+            _clean_lvm_lv $VOLUME_GROUP $VOLUME_NAME_PREFIX
416 416
             if [ "$CINDER_MULTI_LVM_BACKEND" = "True" ]; then
417
-                _clean_volume_group $VOLUME_GROUP2 $VOLUME_NAME_PREFIX
417
+                _clean_lvm_lv $VOLUME_GROUP2 $VOLUME_NAME_PREFIX
418 418
             fi
419 419
         fi
420 420
     fi