Only add Glance Image Cache info if needed

Only add the parameters for the Glance Image Cache is
this has been selected to be enabled in the Fuel GUI

Also make sure the Cinder tenant and user IDs are
32 characters long.
Change-Id: I2f11ceda93fb13bf94db4774b79dd02c20cf0613
This commit is contained in:
Simon Dodsley 2016-03-02 10:54:18 -05:00
parent 3622db6bce
commit 6d08960104
2 changed files with 9 additions and 8 deletions

View File

@ -11,7 +11,8 @@ module Puppet::Parser::Functions
alpha = ('a'..'f').to_a
length = args[0].to_i
CHARS = (alpha + numbers)
id = CHARS.sort_by { rand }.join[0...length]
id_sub = CHARS.sort_by { rand }.join[0...length]
id = id_sub + id_sub
return id
end
end

View File

@ -73,13 +73,16 @@ class plugin_purestorage_cinder::controller (
# Luckily the glance image cache doesn't actually use keystone to check the IDs so
# we can just, temporarily, assign a randon ID to the two fields.
# When keystone-puppet has the functionality we need we will fix this workaround
if $plugin_settings['pure_glance_image_cache'] {
if $plugin_settings['pure_glance_image_cache'] == 'true' {
$PROJECT_ID = get_random_id(32)
$USER_ID = get_random_id(32)
cinder_config {
cinder_config {
"DEFAULT/cinder_internal_tenant_project_id": value => "$PROJECT_ID";
"DEFAULT/cinder_internal_tenant_user_id": value => "$USER_ID";
"$section/image_volume_cache_enabled": value => $plugin_settings["pure_glance_image_cache"];
"$section/image_volume_cache_max_count": value => $plugin_settings["pure_glance_cache_count"];
"$section/image_volume_cache_max_size_gb": value => $plugin_settings["pure_glance_cache_size"];
}
}
@ -90,10 +93,7 @@ class plugin_purestorage_cinder::controller (
use_chap_auth => $plugin_settings['pure_chap'],
use_multipath_for_image_xfer => $plugin_settings['pure_multipath'],
pure_storage_protocol => $plugin_settings['pure_protocol'],
extra_options => { "$section/backend_host" => { value => $section },
"$section/image_volume_cache_enabled" => { value => $plugin_settings["pure_glance_image_cache"] },
"$section/image_volume_cache_max_count" => { value => $plugin_settings["pure_glance_cache_count"] },
"$section/image_volume_cache_max_size_gb" => { value => $plugin_settings["pure_glance_cache_size"] }
extra_options => { "$section/backend_host" => { value => $section }
}
}