Do key validation only when key is provided

key_id is optional, the previous code didn't handle the case of key_id
not specified
This commit is contained in:
Maykel Moya 2013-10-17 11:59:12 +02:00
parent 6dedb68bde
commit a96f75c396

View file

@ -188,11 +188,12 @@ def main():
state = module.params['state']
changed = False
try:
_ = int(key_id, 16)
key_id = key_id.lstrip('0x')
except ValueError:
module.fail_json("Invalid key_id")
if key_id:
try:
_ = int(key_id, 16)
key_id = key_id.lstrip('0x')
except ValueError:
module.fail_json("Invalid key_id")
# FIXME: I think we have a common facility for this, if not, want
check_missing_binaries(module)