Allow for '-' in volume type property values

There's no validation going on (yet) in cinder as to which characters
are allowed in properties. So this change alters the regex to cast a
wide net catching '-' and other possible valid variations.

Also update unit-test to cover this scenario.

Closes-Bug: #1932272
Change-Id: I564528663a3d2f83136b98ed46e09e373a9ad6de
This commit is contained in:
Erik Berg 2021-06-15 11:10:57 +02:00 committed by Takashi Kajinami
parent c0609d6c9f
commit 62899eba67
2 changed files with 4 additions and 4 deletions

View File

@ -114,7 +114,7 @@ Puppet::Type.type(:cinder_type).provide(
end
def self.pythondict2array(input)
json_input = JSON.parse(input.gsub(/u'(\w*)'/, '"\1"').gsub(/'/, '"'))
json_input = JSON.parse(input.gsub(/u'([^']*)'/, '"\1"').gsub(/'/, '"'))
output = []
json_input.each do | k, v |
output = output + ["#{k}=#{v}"]

View File

@ -16,7 +16,7 @@ describe provider_class do
{
:name => 'Backend_1',
:ensure => :present,
:properties => ['key=value', 'new_key=new_value', 'multiattach="<is> True"'],
:properties => ['key=value', 'new_key=a-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', '--property', 'multiattach="<is> True"', '--public', 'Backend_1'])
.with('volume type', 'create', '--format', 'shell', ['--property', 'key=value', '--property', 'new_key=a-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\', multiattach=\'<is> True\'"
properties="key=\'value\', new_key=\'a-new_value\', multiattach=\'<is> True\'"
is_public="True"
access_project_ids=""
')