Teach the common module code to warn users about typo'd arguments and also set everything to None automatically such

that code doesn't have to do a lot of params.get('foo', None) everywhere.
reviewable/pr18780/r1
Michael DeHaan 12 years ago
parent b3353d8f86
commit fe9b0bf38d

@ -76,6 +76,12 @@ def main():
class CommandModule(AnsibleModule):
def _handle_aliases(self):
pass
def _check_invalid_arguments(self):
pass
def _load_params(self):
''' read the input and return a dictionary and the arguments string '''
args = base64.b64decode(MODULE_ARGS)

6
yum

@ -280,15 +280,13 @@ def main():
# removed==absent, installed==present, these are accepted as aliases
state=dict(default='installed', choices=['absent','present','installed','removed','latest']),
list=dict(choices=['installed','updates','available','repos','pkgspec']),
conf_file=dict()
)
)
params = module.params
if 'conf_file' not in params:
params['conf_file'] = None
if 'list' in params and 'pkg' in params:
if params['list'] and params['pkg']:
module.fail_json(msg="expected 'list=' or 'name=', but not both")
if 'list' in params:

Loading…
Cancel
Save