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