Merge pull request #820 from rjeffman/ipaautomountmap_mapname_required

ipaautomountmap: Fix parameter evaluation.
This commit is contained in:
Thomas Woerner
2022-04-29 13:16:37 +02:00
committed by GitHub

View File

@@ -112,20 +112,21 @@ class AutomountMap(IPAAnsibleModule):
state = self.params_get("state")
if state == "present":
if len(name) != 1:
self.fail_json(msg="Exactly one name must be provided \
for state=present.")
self.fail_json(msg="Exactly one name must be provided for"
" 'state: present'.")
if state == "absent":
if len(name) == 0:
self.fail_json(msg="Argument 'map_type' can not be used with "
"state 'absent'")
self.fail_json(msg="At least one 'name' must be provided for"
" 'state: absent'")
invalid = ["desc"]
self.params_fail_used_invalid(invalid, state)
def get_args(self, mapname, desc): # pylint: disable=no-self-use
_args = {}
if mapname:
_args["automountmapname"] = mapname
# automountmapname is required for all automountmap operations.
if not mapname:
self.fail_json(msg="automountmapname cannot be None or empty.")
_args = {"automountmapname": mapname}
# An empty string is valid and will clear the attribute.
if desc is not None:
_args["description"] = desc