use require_if to check for username or AK instead of custom code (#20937)

the logical or parameter to require_if was introduced in #20220
This commit is contained in:
Evgeni Golov 2017-02-06 19:53:12 +01:00 committed by Adrian Likins
commit 827723db90

View file

@ -490,6 +490,7 @@ def main():
), ),
required_together = [ ['username', 'password'], ['activationkey', 'org_id'] ], required_together = [ ['username', 'password'], ['activationkey', 'org_id'] ],
mutually_exclusive = [ ['username', 'activationkey'] ], mutually_exclusive = [ ['username', 'activationkey'] ],
required_if = [ [ 'state', 'present', ['username', 'activationkey'], True ] ],
) )
rhsm.module = module rhsm.module = module
@ -515,10 +516,6 @@ def main():
# Ensure system is registered # Ensure system is registered
if state == 'present': if state == 'present':
# Check for missing parameters ...
if not (activationkey or org_id or username or password):
module.fail_json(msg="Missing arguments, must supply an activationkey (%s) and Organization ID (%s) or username (%s) and password (%s)" % (activationkey, org_id, username, password))
# Register system # Register system
if rhsm.is_registered and not force_register: if rhsm.is_registered and not force_register:
if pool != '^$': if pool != '^$':