mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-03 23:41:51 +00:00
pmem: remove redundant use of regexp (#11388)
* pmem: remove redundant use of regexp * add changelog frag * add bugfixes extry * Update plugins/modules/pmem.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/pmem.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
996b7469e5
commit
defd15609c
2 changed files with 8 additions and 7 deletions
4
changelogs/fragments/11388-pmem-redundant-regexps.yml
Normal file
4
changelogs/fragments/11388-pmem-redundant-regexps.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
bugfixes:
|
||||||
|
- pmem - fix test for invalid data input (https://github.com/ansible-collections/community.general/pull/11388).
|
||||||
|
minor_changes:
|
||||||
|
- pmem - simplify text tests without using regular expression (https://github.com/ansible-collections/community.general/pull/11388).
|
||||||
|
|
@ -199,7 +199,6 @@ EXAMPLES = r"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
|
||||||
import traceback
|
import traceback
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib, human_to_bytes
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib, human_to_bytes
|
||||||
|
|
||||||
|
|
@ -493,19 +492,17 @@ class PersistentMemory:
|
||||||
return ipmctl_opts
|
return ipmctl_opts
|
||||||
|
|
||||||
def is_allocation_good(self, ipmctl_out, command):
|
def is_allocation_good(self, ipmctl_out, command):
|
||||||
warning = re.compile("WARNING")
|
ignore_error = "Do you want to continue? [y/n] Error: Invalid data input."
|
||||||
error = re.compile(".*Error.*")
|
|
||||||
ignore_error = re.compile("Do you want to continue? [y/n] Error: Invalid data input.")
|
|
||||||
|
|
||||||
errmsg = ""
|
errmsg = ""
|
||||||
rc = True
|
rc = True
|
||||||
for line in ipmctl_out.splitlines():
|
for line in ipmctl_out.splitlines():
|
||||||
if warning.match(line):
|
if line.startswith("WARNING"):
|
||||||
errmsg = f"{line} (command: {command})"
|
errmsg = f"{line} (command: {command})"
|
||||||
rc = False
|
rc = False
|
||||||
break
|
break
|
||||||
elif error.match(line):
|
elif "Error" in line:
|
||||||
if not ignore_error:
|
if not line.startswith(ignore_error):
|
||||||
errmsg = f"{line} (command: {command})"
|
errmsg = f"{line} (command: {command})"
|
||||||
rc = False
|
rc = False
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue