Introduce a pcs_without_push function

With the new pcs 0.10.x version we cannot create pacemaker remotes like
we did previously.(pcs resource create foo ocf:remote ...). It will need
to run a bunch of pcs commands that cannot work on an offline CIB (i.e.
we cannot use the pcs() function which does the usual cib dump/push
cycle). So let's introduce a pcs_without_push() function which invokes
pcs without doing a cib push/dump mechanism.

The commands intended for this function are synchronous in the cluster
in any case.

Change-Id: Ia162322d969ac4909a187af446d1316aa788d94d
This commit is contained in:
Michele Baldessari 2019-05-23 07:43:09 +02:00
parent c03a507462
commit 0c5d69921d
1 changed files with 20 additions and 0 deletions

View File

@ -145,6 +145,26 @@ def pcs(name, resource_name, cmd, tries=1, try_sleep=0,
end
end
def pcs_without_push(name, resource_name, cmd, tries=1, try_sleep=0, post_success_sleep=0)
max_tries = tries
max_tries.times do |try|
try_text = max_tries > 1 ? "try #{try+1}/#{max_tries}: " : ''
Puppet.debug("#{try_text}#{PCS_BIN} #{cmd}")
pcs_out = `#{PCS_BIN} #{cmd} 2>&1`
if $?.exitstatus == 0
sleep post_success_sleep
return pcs_out
else
Puppet.debug("Error: #{pcs_out}")
sleep try_sleep
end
if try == max_tries-1
pcs_out_line = pcs_out.lines.first ? pcs_out.lines.first.chomp! : ''
raise Puppet::Error, "pcs #{name} failed: #{pcs_out_line}"
end
end
end
def pcs_create_with_verify(name, resource_name, cmd, tries=1, try_sleep=0)
max_tries = tries
max_tries.times do |try|