| ... | ... |
@@ -372,15 +372,9 @@ function init_cinder {
|
| 372 | 372 |
|
| 373 | 373 |
if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then |
| 374 | 374 |
local be be_name be_type |
| 375 |
- local has_lvm=0 |
|
| 376 | 375 |
for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
|
| 377 | 376 |
be_type=${be%%:*}
|
| 378 | 377 |
be_name=${be##*:}
|
| 379 |
- |
|
| 380 |
- if [[ $be_type == 'lvm' ]]; then |
|
| 381 |
- has_lvm=1 |
|
| 382 |
- fi |
|
| 383 |
- |
|
| 384 | 378 |
if type init_cinder_backend_${be_type} >/dev/null 2>&1; then
|
| 385 | 379 |
# Always init the default volume group for lvm. |
| 386 | 380 |
if [[ "$be_type" == "lvm" ]]; then |
| ... | ... |
@@ -391,17 +385,6 @@ function init_cinder {
|
| 391 | 391 |
done |
| 392 | 392 |
fi |
| 393 | 393 |
|
| 394 |
- # Keep it simple, set a marker if there's an LVM backend |
|
| 395 |
- # use the created VG's to setup lvm filters |
|
| 396 |
- if [[ $has_lvm == 1 ]]; then |
|
| 397 |
- # Order matters here, not only obviously to make |
|
| 398 |
- # sure the VG's are created, but also some distros |
|
| 399 |
- # do some customizations to lvm.conf on init, we |
|
| 400 |
- # want to make sure we copy those over |
|
| 401 |
- sudo cp /etc/lvm/lvm.conf /etc/cinder/lvm.conf |
|
| 402 |
- configure_cinder_backend_conf_lvm |
|
| 403 |
- fi |
|
| 404 |
- |
|
| 405 | 394 |
mkdir -p $CINDER_STATE_PATH/volumes |
| 406 | 395 |
create_cinder_cache_dir |
| 407 | 396 |
} |
| ... | ... |
@@ -19,7 +19,6 @@ |
| 19 | 19 |
# clean_cinder_backend_lvm - called from clean_cinder() |
| 20 | 20 |
# configure_cinder_backend_lvm - called from configure_cinder() |
| 21 | 21 |
# init_cinder_backend_lvm - called from init_cinder() |
| 22 |
-# configure_cinder_backend_conf_lvm - called from configure_cinder() |
|
| 23 | 22 |
|
| 24 | 23 |
|
| 25 | 24 |
# Save trace setting |
| ... | ... |
@@ -66,36 +65,6 @@ function init_cinder_backend_lvm {
|
| 66 | 66 |
init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
-# configure_cinder_backend_conf_lvm - Sets device filter in /etc/cinder/lvm.conf |
|
| 70 |
-# init_cinder_backend_lvm |
|
| 71 |
-function configure_cinder_backend_conf_lvm {
|
|
| 72 |
- local filter_suffix='"r/.*/" ]' |
|
| 73 |
- local filter_string="filter = [ " |
|
| 74 |
- local conf_entries=$(grep volume_group /etc/cinder/cinder.conf | sed "s/ //g") |
|
| 75 |
- local pv |
|
| 76 |
- local vg |
|
| 77 |
- local line |
|
| 78 |
- |
|
| 79 |
- for pv_info in $(sudo pvs --noheadings -o name,vg_name --separator ';'); do |
|
| 80 |
- echo_summary "Evaluate PV info for Cinder lvm.conf: $pv_info" |
|
| 81 |
- IFS=';' read pv vg <<< "$pv_info" |
|
| 82 |
- for line in ${conf_entries}; do
|
|
| 83 |
- IFS='=' read label group <<< "$line" |
|
| 84 |
- group=$(echo $group|sed "s/^ *//g") |
|
| 85 |
- if [[ "$vg" == "$group" ]]; then |
|
| 86 |
- new="\"a$pv/\", " |
|
| 87 |
- filter_string=$filter_string$new |
|
| 88 |
- fi |
|
| 89 |
- done |
|
| 90 |
- done |
|
| 91 |
- filter_string=$filter_string$filter_suffix |
|
| 92 |
- |
|
| 93 |
- # FIXME(jdg): Possible odd case that the lvm.conf file has been modified |
|
| 94 |
- # and doesn't have a filter entry to search/replace. For devstack don't |
|
| 95 |
- # know that we care, but could consider adding a check and add |
|
| 96 |
- sudo sed -i "s#^[ \t]*filter.*# $filter_string#g" /etc/cinder/lvm.conf |
|
| 97 |
- echo "set LVM filter_strings: $filter_string" |
|
| 98 |
-} |
|
| 99 | 69 |
# Restore xtrace |
| 100 | 70 |
$MY_XTRACE |
| 101 | 71 |
|
| ... | ... |
@@ -138,6 +138,31 @@ function init_default_lvm_volume_group {
|
| 138 | 138 |
fi |
| 139 | 139 |
} |
| 140 | 140 |
|
| 141 |
+# set_lvm_filter() Gather all devices configured for LVM and |
|
| 142 |
+# use them to build a global device filter |
|
| 143 |
+# set_lvm_filter() Create a device filter |
|
| 144 |
+# and add to /etc/lvm.conf. Note this uses |
|
| 145 |
+# all current PV's in use by LVM on the |
|
| 146 |
+# system to build it's filter. |
|
| 147 |
+# |
|
| 148 |
+# Usage: set_lvm_filter() |
|
| 149 |
+function set_lvm_filter {
|
|
| 150 |
+ local filter_suffix='"r|.*|" ]' |
|
| 151 |
+ local filter_string="global_filter = [ " |
|
| 152 |
+ local pv |
|
| 153 |
+ local vg |
|
| 154 |
+ local line |
|
| 155 |
+ |
|
| 156 |
+ for pv_info in $(sudo pvs --noheadings -o name); do |
|
| 157 |
+ pv=$(echo -e "${pv_info}" | sed 's/ //g' | sed 's/\/dev\///g')
|
|
| 158 |
+ new="\"a|$pv|\", " |
|
| 159 |
+ filter_string=$filter_string$new |
|
| 160 |
+ done |
|
| 161 |
+ filter_string=$filter_string$filter_suffix |
|
| 162 |
+ |
|
| 163 |
+ sudo sed -i "/# global_filter = \[*\]/a\ $global_filter$filter_string" /etc/lvm/lvm.conf |
|
| 164 |
+ echo_summary "set lvm.conf device global_filter to: $filter_string" |
|
| 165 |
+} |
|
| 141 | 166 |
|
| 142 | 167 |
# Restore xtrace |
| 143 | 168 |
$MY_XTRACE |
| ... | ... |
@@ -1316,6 +1316,15 @@ service_check |
| 1316 | 1316 |
# Prepare bash completion for OSC |
| 1317 | 1317 |
openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion > /dev/null |
| 1318 | 1318 |
|
| 1319 |
+# If cinder is configured, set global_filter for PV devices |
|
| 1320 |
+if is_service_enabled cinder; then |
|
| 1321 |
+ if is_ubuntu; then |
|
| 1322 |
+ echo_summary "Configuring lvm.conf global device filter" |
|
| 1323 |
+ set_lvm_filter |
|
| 1324 |
+ else |
|
| 1325 |
+ echo_summary "Skip setting lvm filters for non Ubuntu systems" |
|
| 1326 |
+ fi |
|
| 1327 |
+fi |
|
| 1319 | 1328 |
|
| 1320 | 1329 |
# Fin |
| 1321 | 1330 |
# === |