make it possible to have multiple type_sets with the same value
Add a value option to set value not only by namevar, but rather by a dedicated value variable. Otherwise we might end up with duplicated resources. Change-Id: I64eb8b2efc81821b8f32ca493ba5ba9b3afad1d6 Co-Author: Janosch Rohdewald <janosch.rohdewald@swisscom.com> Backport-Potential: juno
This commit is contained in:
parent
4d0d175128
commit
e56e06b7f3
@ -13,6 +13,9 @@
|
||||
# [*key*]
|
||||
# (required) the key name that we are setting the value for.
|
||||
#
|
||||
# [*value*]
|
||||
# the value that we are setting. Defaults to content of namevar.
|
||||
#
|
||||
# [*os_tenant_name*]
|
||||
# (optional) The keystone tenant name. Defaults to 'admin'.
|
||||
#
|
||||
@ -36,6 +39,7 @@ define cinder::type_set (
|
||||
$os_username = 'admin',
|
||||
$os_auth_url = 'http://127.0.0.1:5000/v2.0/',
|
||||
$os_region_name = undef,
|
||||
$value = $name,
|
||||
) {
|
||||
|
||||
# TODO: (xarses) This should be moved to a ruby provider so that among other
|
||||
@ -55,10 +59,10 @@ define cinder::type_set (
|
||||
$region_env = []
|
||||
}
|
||||
|
||||
exec {"cinder type-key ${type} set ${key}=${name}":
|
||||
exec {"cinder type-key ${type} set ${key}=${value}":
|
||||
path => ['/usr/bin', '/bin'],
|
||||
command => "cinder type-key ${type} set ${key}=${name}",
|
||||
unless => "cinder extra-specs-list | grep -Eq '\\b${type}\\b.*\\b${key}\\b.*\\b${name}\\b'",
|
||||
command => "cinder type-key ${type} set ${key}=${value}",
|
||||
unless => "cinder extra-specs-list | grep -Eq '\\b${type}\\b.*\\b${key}\\b.*\\b${value}\\b'",
|
||||
environment => concat($cinder_env, $region_env),
|
||||
require => Package['python-cinderclient']
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ describe 'cinder::type_set' do
|
||||
|
||||
let(:title) {'hippo'}
|
||||
|
||||
let :params do {
|
||||
let :default_params do {
|
||||
:type => 'sith',
|
||||
:key => 'monchichi',
|
||||
:os_password => 'asdf',
|
||||
@ -16,15 +16,35 @@ describe 'cinder::type_set' do
|
||||
}
|
||||
end
|
||||
|
||||
it 'should have its execs' do
|
||||
is_expected.to contain_exec('cinder type-key sith set monchichi=hippo').with(
|
||||
:command => 'cinder type-key sith set monchichi=hippo',
|
||||
:unless => "cinder extra-specs-list | grep -Eq '\\bsith\\b.*\\bmonchichi\\b.*\\bhippo\\b'",
|
||||
:environment => [
|
||||
'OS_TENANT_NAME=admin',
|
||||
'OS_USERNAME=admin',
|
||||
'OS_PASSWORD=asdf',
|
||||
'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/'],
|
||||
:require => 'Package[python-cinderclient]')
|
||||
describe 'by default' do
|
||||
let(:params){ default_params }
|
||||
it 'should have its execs' do
|
||||
should contain_exec('cinder type-key sith set monchichi=hippo').with(
|
||||
:command => 'cinder type-key sith set monchichi=hippo',
|
||||
:unless => "cinder extra-specs-list | grep -Eq '\\bsith\\b.*\\bmonchichi\\b.*\\bhippo\\b'",
|
||||
:environment => [
|
||||
'OS_TENANT_NAME=admin',
|
||||
'OS_USERNAME=admin',
|
||||
'OS_PASSWORD=asdf',
|
||||
'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/'],
|
||||
:require => 'Package[python-cinderclient]')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with a different value' do
|
||||
let(:params){
|
||||
default_params.merge({:value => 'hippi'})
|
||||
}
|
||||
it 'should have its execs' do
|
||||
should contain_exec('cinder type-key sith set monchichi=hippi').with(
|
||||
:command => 'cinder type-key sith set monchichi=hippi',
|
||||
:unless => "cinder extra-specs-list | grep -Eq '\\bsith\\b.*\\bmonchichi\\b.*\\bhippi\\b'",
|
||||
:environment => [
|
||||
'OS_TENANT_NAME=admin',
|
||||
'OS_USERNAME=admin',
|
||||
'OS_PASSWORD=asdf',
|
||||
'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/'],
|
||||
:require => 'Package[python-cinderclient]')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user