Browse Source

Merge "Allow updating stonith levels"

changes/71/697171/1
Zuul 2 weeks ago
parent
commit
b6174b3642
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      lib/puppet/provider/pcmk_stonith_level/default.rb

+ 25
- 0
lib/puppet/provider/pcmk_stonith_level/default.rb View File

@@ -11,6 +11,7 @@ Puppet::Type.type(:pcmk_stonith_level).provide(:default) do
res = stonith_resources.join(',')
cmd = 'stonith level add ' + level.to_s + ' ' + target + ' ' + res

destroy if does_level_exist?
pcs('create', "#{name}-#{target}-#{res}", cmd, @resource[:tries],
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])
end
@@ -25,6 +26,30 @@ Puppet::Type.type(:pcmk_stonith_level).provide(:default) do
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])
end

def does_level_exist?
# stonith level output is a bit cumbersome to parse:
# Target: overcloud-galera-0
# Level 1 - stonith-fence_ipmilan-006809859383,stonith-fence_compute-fence-nova
# Target: overcloud-novacompute-0
# Level 1 - stonith-fence_ipmilan-006809859383,stonith-fence_compute-fence-nova
# Level 2 - stonith-fence_ipmilan-006809859383,stonith-fence_compute-fence-nova
# Target: overcloud-rabbit-0
# Level 2 - stonith-fence_ipmilan-006809859383,stonith-fence_compute-fence-nova
target = @resource[:target]
level = @resource[:level]
stonith_resources = @resource[:stonith_resources]
res = stonith_resources.join(',')
# The below cmd return the "Level X - ...." strings after the Target: string until the next
# Target: string (or until the bottom of the file if it is the last Target in the output
cmd = 'stonith level | sed -n "/^Target: ' + target + '$/,/^Target:/{/^Target: ' + target + '$/b;/^Target:/b;p}"'
cmd += ' | grep -e "Level[[:space:]]*' + level.to_s + '"'
Puppet.debug("Exists: does level exist with something else #{level} #{target} #{res} -> #{cmd}")
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])

return ret == false ? false : true
end

def exists?
# stonith level output is a bit cumbersome to parse:
# Target: overcloud-galera-0

Loading…
Cancel
Save