Skip to content

Commit

Permalink
Add parameter to set os_region_name in glance config
Browse files Browse the repository at this point in the history
When https://review.openstack.org/#/c/125231/ was merged, the glance
providers became dependent on the DEFAULT/os_region_name parameter in
the glance configs, but the module had no way to set that parameter.
This caused the providers to fail.

This patch adds the parameter to glance::api so that the user can
control the value. It also removes functionality of the os_region_name
in glance::backend::cinder. While it would be better to deprecate this
parameter first and remove its functionality in a later release, there
is no clean way to do this and avoid a duplicate definition error.

An alternative to rapidly removing this functionality from
glance::backend::cinder would be modifying the glance parent provider
to make the DEFAULT/os_region_name glance config optional.

Change-Id: I075224acb9da2bb547d437b08cf6fccfed655d5c
  • Loading branch information
Colleen Murphy committed Oct 31, 2014
1 parent abd028a commit a97bf99
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
10 changes: 8 additions & 2 deletions manifests/api.pp
Expand Up @@ -162,6 +162,9 @@
# (optional) Base directory that the Image Cache uses.
# Defaults to '/var/lib/glance/image-cache'.
#
# [*os_region_name*]
# (optional) Sets the keystone region to use.
# Defaults to 'RegionOne'.
class glance::api(
$keystone_password,
$verbose = false,
Expand Down Expand Up @@ -198,6 +201,7 @@
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
$database_idle_timeout = 3600,
$image_cache_dir = '/var/lib/glance/image-cache',
$os_region_name = 'RegionOne',
# DEPRECATED PARAMETERS
$mysql_module = undef,
$sql_idle_timeout = false,
Expand Down Expand Up @@ -276,6 +280,7 @@
'DEFAULT/workers': value => $workers;
'DEFAULT/show_image_direct_url': value => $show_image_direct_url;
'DEFAULT/image_cache_dir': value => $image_cache_dir;
'DEFAULT/os_region_name': value => $os_region_name;
}

# known_stores config
Expand All @@ -290,8 +295,9 @@
}

glance_cache_config {
'DEFAULT/verbose': value => $verbose;
'DEFAULT/debug': value => $debug;
'DEFAULT/verbose': value => $verbose;
'DEFAULT/debug': value => $debug;
'DEFAULT/os_region_name': value => $os_region_name;
}

# configure api service to connect registry service
Expand Down
14 changes: 8 additions & 6 deletions manifests/backend/cinder.pp
Expand Up @@ -33,9 +33,9 @@
# Defaults to 'undef'
#
# [*os_region_name*]
# (optional) Region name of this node.
# Should be a valid region name
# Defaults to 'RegionOne'
# (optional) The os_region_name parameter is deprecated and has no effect.
# Use glance::api::os_region_name instead.
# Defaults to 'undef'
#
# [*cinder_ca_certificates_file*]
# (optional) Location of ca certicate file to use for cinder client requests.
Expand All @@ -54,7 +54,7 @@
#

class glance::backend::cinder(
$os_region_name = 'RegionOne',
$os_region_name = undef,
$cinder_ca_certificates_file = undef,
$cinder_api_insecure = false,
$cinder_catalog_info = 'volume:cinder:publicURL',
Expand All @@ -63,19 +63,21 @@

) {

if $os_region_name {
notice('The os_region_name parameter is deprecated and has no effect. Use glance::api::os_region_name instead.')
}

glance_api_config {
'DEFAULT/cinder_api_insecure': value => $cinder_api_insecure;
'DEFAULT/cinder_catalog_info': value => $cinder_catalog_info;
'DEFAULT/cinder_http_retries': value => $cinder_http_retries;
'DEFAULT/default_store': value => 'cinder';
'DEFAULT/os_region_name': value => $os_region_name;
}

glance_cache_config {
'DEFAULT/cinder_api_insecure': value => $cinder_api_insecure;
'DEFAULT/cinder_catalog_info': value => $cinder_catalog_info;
'DEFAULT/cinder_http_retries': value => $cinder_http_retries;
'DEFAULT/os_region_name': value => $os_region_name;
}

if $cinder_endpoint_template {
Expand Down
10 changes: 7 additions & 3 deletions spec/classes/glance_api_spec.rb
Expand Up @@ -38,6 +38,7 @@
:purge_config => false,
:known_stores => false,
:image_cache_dir => '/var/lib/glance/image-cache',
:os_region_name => 'RegionOne',
}
end

Expand All @@ -64,7 +65,8 @@
:database_idle_timeout => '36002',
:database_connection => 'mysql:///var:lib@glance/glance',
:show_image_direct_url => true,
:image_cache_dir => '/tmp/glance'
:image_cache_dir => '/tmp/glance',
:os_region_name => 'RegionOne2',
}
].each do |param_set|

Expand Down Expand Up @@ -96,7 +98,8 @@
'registry_host',
'registry_port',
'registry_client_protocol',
'show_image_direct_url'
'show_image_direct_url',
'os_region_name',
].each do |config|
should contain_glance_api_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
end
Expand All @@ -107,7 +110,8 @@
'verbose',
'debug',
'registry_host',
'registry_port'
'registry_port',
'os_region_name',
].each do |config|
should contain_glance_cache_config("DEFAULT/#{config}").with_value(param_hash[config.intern])
end
Expand Down
5 changes: 0 additions & 5 deletions spec/classes/glance_backend_cinder_spec.rb
Expand Up @@ -34,15 +34,13 @@
should contain_glance_api_config('DEFAULT/default_store').with_value('cinder')
should contain_glance_api_config('DEFAULT/cinder_api_insecure').with_value(false)
should contain_glance_api_config('DEFAULT/cinder_catalog_info').with_value('volume:cinder:publicURL')
should contain_glance_api_config('DEFAULT/os_region_name').with_value('RegionOne')
should contain_glance_api_config('DEFAULT/cinder_http_retries').with_value('3')
should contain_glance_api_config('DEFAULT/cinder_ca_certificates_file').with(:ensure => 'absent')
should contain_glance_api_config('DEFAULT/cinder_endpoint_template').with(:ensure => 'absent')
end
it 'configures glance-cache.conf' do
should contain_glance_cache_config('DEFAULT/cinder_api_insecure').with_value(false)
should contain_glance_cache_config('DEFAULT/cinder_catalog_info').with_value('volume:cinder:publicURL')
should contain_glance_cache_config('DEFAULT/os_region_name').with_value('RegionOne')
should contain_glance_cache_config('DEFAULT/cinder_http_retries').with_value('3')
should contain_glance_cache_config('DEFAULT/cinder_ca_certificates_file').with(:ensure => 'absent')
should contain_glance_cache_config('DEFAULT/cinder_endpoint_template').with(:ensure => 'absent')
Expand All @@ -57,7 +55,6 @@
:cinder_catalog_info => 'volume:cinder:internalURL',
:cinder_endpoint_template => 'http://srv-foo:8776/v1/%(project_id)s',
:cinder_http_retries => '10',
:os_region_name => 'foo'
}
end
it 'configures glance-api.conf' do
Expand All @@ -67,15 +64,13 @@
should contain_glance_api_config('DEFAULT/cinder_catalog_info').with_value('volume:cinder:internalURL')
should contain_glance_api_config('DEFAULT/cinder_endpoint_template').with_value('http://srv-foo:8776/v1/%(project_id)s')
should contain_glance_api_config('DEFAULT/cinder_http_retries').with_value('10')
should contain_glance_api_config('DEFAULT/os_region_name').with_value('foo')
end
it 'configures glance-cache.conf' do
should contain_glance_cache_config('DEFAULT/cinder_api_insecure').with_value(true)
should contain_glance_cache_config('DEFAULT/cinder_ca_certificates_file').with_value('/etc/ssh/ca.crt')
should contain_glance_cache_config('DEFAULT/cinder_catalog_info').with_value('volume:cinder:internalURL')
should contain_glance_cache_config('DEFAULT/cinder_endpoint_template').with_value('http://srv-foo:8776/v1/%(project_id)s')
should contain_glance_cache_config('DEFAULT/cinder_http_retries').with_value('10')
should contain_glance_cache_config('DEFAULT/os_region_name').with_value('foo')
end
end

Expand Down

0 comments on commit a97bf99

Please sign in to comment.