From 9eb5921c1c1880ea1030ef67621e209d0200e94c Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Fri, 10 Nov 2017 04:48:05 +0000 Subject: [PATCH] fix AttributeError eos_static_route (#32779) Signed-off-by: Trishna Guha --- .../modules/network/eos/eos_static_route.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/ansible/modules/network/eos/eos_static_route.py b/lib/ansible/modules/network/eos/eos_static_route.py index 860093e3ad..d0b99e783e 100644 --- a/lib/ansible/modules/network/eos/eos_static_route.py +++ b/lib/ansible/modules/network/eos/eos_static_route.py @@ -189,16 +189,17 @@ def main(): supports_check_mode=True) address = module.params['address'] - prefix = address.split('/')[-1] + if address is not None: + prefix = address.split('/')[-1] + + if address and prefix: + if '/' not in address or not validate_ip_address(address.split('/')[0]): + module.fail_json(msg='{} is not a valid IP address'.format(address)) + + if not validate_prefix(prefix): + module.fail_json(msg='Length of prefix should be between 0 and 32 bits') + warnings = list() - check_args(module, warnings) - - if '/' not in address or not validate_ip_address(address.split('/')[0]): - module.fail_json(msg='{} is not a valid IP address'.format(address)) - - if not validate_prefix(prefix): - module.fail_json(msg='Length of prefix should be between 0 and 32 bits') - result = {'changed': False} if warnings: result['warnings'] = warnings