mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-09-30 05:23:21 -07:00
pacemaker_cluster: enhancements and add unit tests (#10227)
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.16) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py2.7) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py3.11) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py3.6) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.16) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py2.7) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py3.11) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.16+py3.6) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run
* feat(initial): Add unit tests and rewrite pacemaker_cluster This commit introduces unit tests and pacemaker_cluster module rewrite to use the pacemaker module utils. * feat(cleanup): Various fixes and add resource state This commit migrates the pacemaker_cluster's cleanup state to the pacemaker_resource module. Additionally, the unit tests for pacemaker_cluster have been corrected to proper mock run command order. * doc(botmeta): Add author to pacemaker_cluster * style(whitespace): Cleanup test files * refactor(cleanup): Remove unused state value * bug(fix): Parse apply_all as separate option * refactor(review): Apply code review suggestions This commit refactors breaking changes in pacemaker_cluster module into deprecated features. The following will be scheduled for deprecation: `state: cleanup` and `state: None`. * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * refactor(review): Additional review suggestions * refactor(deprecations): Remove all deprecation changes * refactor(review): Enhance rename changelog entry and fix empty string logic * refactor(cleanup): Remove from pacemaker_resource * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * refactor(review): Add changelog and revert required name * revert(default): Use default state=present * Update changelogs/fragments/10227-pacemaker-cluster-and-resource-enhancement.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelog fragment. --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
4801b0fc00
commit
283d947f17
8 changed files with 695 additions and 156 deletions
|
@ -14,7 +14,12 @@ _state_map = {
|
|||
"absent": "remove",
|
||||
"status": "status",
|
||||
"enabled": "enable",
|
||||
"disabled": "disable"
|
||||
"disabled": "disable",
|
||||
"online": "start",
|
||||
"offline": "stop",
|
||||
"maintenance": "set",
|
||||
"config": "config",
|
||||
"cleanup": "cleanup",
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,20 +43,19 @@ def fmt_resource_argument(value):
|
|||
|
||||
|
||||
def get_pacemaker_maintenance_mode(runner):
|
||||
with runner("config") as ctx:
|
||||
rc, out, err = ctx.run()
|
||||
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()))
|
||||
return bool(maintenance_mode_output)
|
||||
|
||||
|
||||
def pacemaker_runner(module, cli_action=None, **kwargs):
|
||||
def pacemaker_runner(module, **kwargs):
|
||||
runner_command = ['pcs']
|
||||
if cli_action:
|
||||
runner_command.append(cli_action)
|
||||
runner = CmdRunner(
|
||||
module,
|
||||
command=runner_command,
|
||||
arg_formats=dict(
|
||||
cli_action=cmd_runner_fmt.as_list(),
|
||||
state=cmd_runner_fmt.as_map(_state_map),
|
||||
name=cmd_runner_fmt.as_list(),
|
||||
resource_type=cmd_runner_fmt.as_func(fmt_resource_type),
|
||||
|
@ -59,6 +63,7 @@ def pacemaker_runner(module, cli_action=None, **kwargs):
|
|||
resource_operation=cmd_runner_fmt.as_func(fmt_resource_operation),
|
||||
resource_meta=cmd_runner_fmt.stack(cmd_runner_fmt.as_opt_val)("meta"),
|
||||
resource_argument=cmd_runner_fmt.as_func(fmt_resource_argument),
|
||||
apply_all=cmd_runner_fmt.as_bool("--all"),
|
||||
wait=cmd_runner_fmt.as_opt_eq_val("--wait"),
|
||||
config=cmd_runner_fmt.as_fixed("config"),
|
||||
force=cmd_runner_fmt.as_bool("--force"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue