correctly parse empty parameter values in CIB objects

For a CIB object definition such as:

    primitive database-config-default-fs ocf💓Filesystem \
            params device="/dev/drbd/postgresql" directory="/var/lib/pgsql" fstype="" \
            op monitor interval="10s"

when #extract_hash attempts to extract the 'params' section,
Shellwords.split will return an Array whose last element is

    fstype=

not

    fstype=""

as you might expect.  Therefore we need to allow for an empty string to
the right of the equals sign, otherwise parsing fails.
This commit is contained in:
Adam Spiers
2014-03-21 17:11:11 +00:00
parent 21f3231732
commit b5e07b7abf

View File

@@ -45,7 +45,7 @@ module Pacemaker
h = {} h = {}
Shellwords.split($1).each do |kvpair| Shellwords.split($1).each do |kvpair|
break if kvpair == 'op' break if kvpair == 'op'
unless kvpair =~ /^(.+?)=(.+)$/ unless kvpair =~ /^(.+?)=(.*)$/
raise "Couldn't understand '#{kvpair}' for '#{data_type}' section "\ raise "Couldn't understand '#{kvpair}' for '#{data_type}' section "\
"of #{name} primitive (definition was [#{obj_definition}])" "of #{name} primitive (definition was [#{obj_definition}])"
end end