mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 07:24:00 -07:00
[PR #10707/63321754 backport][stable-11] pacemaker: Add regex checking for maintenance-mode (#10749)
pacemaker: Add regex checking for maintenance-mode (#10707)
* Add regex checking for maintenance-mode
* Add changelog fragment
* Apply suggestions from code review
---------
(cherry picked from commit 6332175493
)
Co-authored-by: Dexter <45038532+munchtoast@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
a618aa6b0a
commit
ddc546596e
4 changed files with 70 additions and 2 deletions
|
@ -6,8 +6,9 @@
|
|||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt
|
||||
import re
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt
|
||||
|
||||
_state_map = {
|
||||
"present": "create",
|
||||
|
@ -45,7 +46,8 @@ def fmt_resource_argument(value):
|
|||
def get_pacemaker_maintenance_mode(runner):
|
||||
with runner("cli_action config") as ctx:
|
||||
rc, out, err = ctx.run(cli_action="property")
|
||||
maintenance_mode_output = list(filter(lambda string: "maintenance-mode=true" in string.lower(), out.splitlines()))
|
||||
maint_mode_re = re.compile(r"maintenance-mode.*true", re.IGNORECASE)
|
||||
maintenance_mode_output = [line for line in out.splitlines() if maint_mode_re.search(line)]
|
||||
return bool(maintenance_mode_output)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue