Add Cinder backend to image store
Cinder is an potiential backend in Glance. This patchs aims to: - create glance::backend::cinder - improve spec_helper using shared_examples Change-Id: I15e5de8281ff2e60465fedda97d9c9ccf808386c Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>changes/80/59080/4
parent
5557c224f3
commit
eb7c33bb1f
|
@ -0,0 +1,97 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Class: glance::backend::cinder
|
||||
#
|
||||
# Setup Glance to backend images into Cinder
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*cinder_catalog_info*]
|
||||
# (optional) Info to match when looking for cinder in the service catalog.
|
||||
# Format is : separated values of the form:
|
||||
# <service_type>:<service_name>:<endpoint_type> (string value)
|
||||
# Defaults to 'volume:cinder:publicURL'
|
||||
#
|
||||
# [*cinder_endpoint_template*]
|
||||
# (optional) Override service catalog lookup with template for cinder endpoint.
|
||||
# Should be a valid URL. Example: 'http://localhost:8776/v1/%(project_id)s'
|
||||
# Defaults to 'undef'
|
||||
#
|
||||
# [*os_region_name*]
|
||||
# (optional) Region name of this node.
|
||||
# Should be a valid region name
|
||||
# Defaults to 'RegionOne'
|
||||
#
|
||||
# [*cinder_ca_certificates_file*]
|
||||
# (optional) Location of ca certicate file to use for cinder client requests.
|
||||
# Should be a valid ca certicate file
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*cinder_http_retries*]
|
||||
# (optional) Number of cinderclient retries on failed http calls.
|
||||
# Should be a valid integer
|
||||
# Defaults to '3'
|
||||
#
|
||||
# [*cinder_api_insecure*]
|
||||
# (optional) Allow to perform insecure SSL requests to cinder.
|
||||
# Should be a valid boolean value
|
||||
# Defaults to false
|
||||
#
|
||||
|
||||
class glance::backend::cinder(
|
||||
$os_region_name = 'RegionOne',
|
||||
$cinder_ca_certificates_file = undef,
|
||||
$cinder_api_insecure = false,
|
||||
$cinder_catalog_info = 'volume:cinder:publicURL',
|
||||
$cinder_endpoint_template = undef,
|
||||
$cinder_http_retries = '3'
|
||||
|
||||
) {
|
||||
|
||||
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 {
|
||||
glance_api_config { 'DEFAULT/cinder_endpoint_template': value => $cinder_endpoint_template; }
|
||||
glance_cache_config { 'DEFAULT/cinder_endpoint_template': value => $cinder_endpoint_template; }
|
||||
} else {
|
||||
glance_api_config { 'DEFAULT/cinder_endpoint_template': ensure => absent; }
|
||||
glance_cache_config { 'DEFAULT/cinder_endpoint_template': ensure => absent; }
|
||||
}
|
||||
|
||||
if $cinder_ca_certificates_file {
|
||||
glance_api_config { 'DEFAULT/cinder_ca_certificates_file': value => $cinder_ca_certificates_file; }
|
||||
glance_cache_config { 'DEFAULT/cinder_ca_certificates_file': value => $cinder_ca_certificates_file; }
|
||||
} else {
|
||||
glance_api_config { 'DEFAULT/cinder_ca_certificates_file': ensure => absent; }
|
||||
glance_cache_config { 'DEFAULT/cinder_ca_certificates_file': ensure => absent; }
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
#
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Unit tests for glance::backend::cinder class
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'glance::backend::cinder' do
|
||||
|
||||
let :pre_condition do
|
||||
'class { "glance::api": keystone_password => "pass" }'
|
||||
end
|
||||
|
||||
shared_examples_for 'glance with cinder backend' do
|
||||
|
||||
context 'when default parameters' do
|
||||
|
||||
it 'configures glance-api.conf' do
|
||||
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')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when overriding parameters' do
|
||||
let :params do
|
||||
{
|
||||
:cinder_api_insecure => true,
|
||||
:cinder_ca_certificates_file => '/etc/ssh/ca.crt',
|
||||
: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
|
||||
should contain_glance_api_config('DEFAULT/default_store').with_value('cinder')
|
||||
should contain_glance_api_config('DEFAULT/cinder_api_insecure').with_value(true)
|
||||
should contain_glance_api_config('DEFAULT/cinder_ca_certificates_file').with_value('/etc/ssh/ca.crt')
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'glance with cinder backend'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'glance with cinder backend'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
shared_examples_for "a Puppet::Error" do |description|
|
||||
it "with message matching #{description.inspect}" do
|
||||
expect { should have_class_count(1) }.to raise_error(Puppet::Error, description)
|
||||
end
|
||||
end
|
|
@ -1 +1,7 @@
|
|||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
require 'shared_examples'
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue