Browse code

Merge "Init default lvm volume group only if required"

Jenkins authored on 2015/01/30 07:55:50
Showing 4 changed files
... ...
@@ -393,6 +393,10 @@ function init_cinder {
393 393
             fi
394 394
 
395 395
             if type init_cinder_backend_${be_type} >/dev/null 2>&1; then
396
+                # Always init the default volume group for lvm.
397
+                if [[ "$be_type" == "lvm" ]]; then
398
+                    init_default_lvm_volume_group
399
+                fi
396 400
                 init_cinder_backend_${be_type} ${be_name}
397 401
             fi
398 402
         done
... ...
@@ -117,6 +117,25 @@ function init_lvm_volume_group {
117 117
     _clean_lvm_volume_group $vg
118 118
 }
119 119
 
120
+# Sentinal value to ensure that init of default lvm volume group is
121
+# only performed once across calls of init_default_lvm_volume_group.
122
+_DEFAULT_LVM_INIT=${_DEFAULT_LVM_INIT:-0}
123
+
124
+# init_default_lvm_volume_group() initializes a default volume group
125
+# intended to be shared between cinder and nova.  It is idempotent;
126
+# the init of the default volume group is guaranteed to be performed
127
+# only once so that either or both of the dependent services can
128
+# safely call this function.
129
+#
130
+# Usage: init_default_lvm_volume_group()
131
+function init_default_lvm_volume_group {
132
+    if [[ "$_DEFAULT_LVM_INIT" = "0" ]]; then
133
+        init_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME $VOLUME_BACKING_FILE_SIZE
134
+        _DEFAULT_LVM_INIT=1
135
+    fi
136
+}
137
+
138
+
120 139
 # Restore xtrace
121 140
 $MY_XTRACE
122 141
 
... ...
@@ -640,6 +640,10 @@ function init_nova {
640 640
 
641 641
     create_nova_cache_dir
642 642
     create_nova_keys_dir
643
+
644
+    if [[ "$NOVA_BACKEND" == "LVM" ]]; then
645
+        init_default_lvm_volume_group
646
+    fi
643 647
 }
644 648
 
645 649
 # install_novaclient() - Collect source and prepare
... ...
@@ -918,10 +918,6 @@ init_service_check
918 918
 # A better kind of sysstat, with the top process per time slice
919 919
 start_dstat
920 920
 
921
-# Initialize default LVM volume group
922
-# -----------------------------------
923
-init_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME $VOLUME_BACKING_FILE_SIZE
924
-
925 921
 # Start Services
926 922
 # ==============
927 923