Improve cinder_type properties regex
This changes the regex for properties managed with the cinder_type resource so that it supports the format Cinder needs for multiattach and similar. multiattach=<is> True This patch is needed so that cinder_type resources can set the above. See regex testing here [1]. Needs to be backported to older versions so that cinder_type can be properly used there as well. [1] https://regexr.com/5imqk Change-Id: If08fce9443281e65636aaaa99e3139732435f6f7
This commit is contained in:
parent
930d112c8e
commit
a032bec7d6
@ -16,7 +16,7 @@ Puppet::Type.newtype(:cinder_type) do
|
||||
is.sort == should.sort
|
||||
end
|
||||
validate do |value|
|
||||
raise ArgumentError, "Properties doesn't match" unless value.match(/^\s*[^=\s]+=[^=\s]+$/)
|
||||
raise ArgumentError, "Properties doesn't match" unless value.match(/^\s*[^=\s]+=\S(([^=,])+((?<=\S),(?=\S))?)+([^\s=,])+$/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ describe provider_class do
|
||||
{
|
||||
:name => 'Backend_1',
|
||||
:ensure => :present,
|
||||
:properties => ['key=value', 'new_key=new_value'],
|
||||
:properties => ['key=value', 'new_key=new_value', 'multiattach="<is> True"'],
|
||||
:is_public => true,
|
||||
:access_project_ids => [],
|
||||
}
|
||||
@ -41,10 +41,10 @@ describe provider_class do
|
||||
describe '#create' do
|
||||
it 'creates a type' do
|
||||
provider_class.expects(:openstack)
|
||||
.with('volume type', 'create', '--format', 'shell', ['--property', 'key=value', '--property', 'new_key=new_value', '--public', 'Backend_1'])
|
||||
.with('volume type', 'create', '--format', 'shell', ['--property', 'key=value', '--property', 'new_key=new_value', '--property', 'multiattach="<is> True"', '--public', 'Backend_1'])
|
||||
.returns('id="90e19aff-1b35-4d60-9ee3-383c530275ab"
|
||||
name="Backend_1"
|
||||
properties="key=\'value\', new_key=\'new_value\'"
|
||||
properties="key=\'value\', new_key=\'new_value\', multiattach=\'<is> True\'"
|
||||
is_public="True"
|
||||
access_project_ids=""
|
||||
')
|
||||
|
Loading…
Reference in New Issue
Block a user