From 5fb2a0ae2ddbd21da2fc1be7987cf4d3ea35ac4f Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Wed, 17 Jul 2019 02:52:19 +0530 Subject: [PATCH] Backport PR to resolve NoneType error in issue 57711 (#58706) * fix 57711 (#58618) Signed-off-by: Sumit Jaiswal (cherry picked from commit 8b844b67b589a608d7c3a55fef5c632fe8961e9a) * changelog file --- .../57711-To_resolve_NoneType_error_in_aci_l3out.yaml | 3 +++ lib/ansible/modules/network/aci/aci_l3out.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/57711-To_resolve_NoneType_error_in_aci_l3out.yaml diff --git a/changelogs/fragments/57711-To_resolve_NoneType_error_in_aci_l3out.yaml b/changelogs/fragments/57711-To_resolve_NoneType_error_in_aci_l3out.yaml new file mode 100644 index 00000000000..3cc1596dacc --- /dev/null +++ b/changelogs/fragments/57711-To_resolve_NoneType_error_in_aci_l3out.yaml @@ -0,0 +1,3 @@ +bugfixes: + - To resolve NoneType error as it was missing NoneType check for l3protocol param in aci_l3out. + (https://github.com/ansible/ansible/pull/58618). diff --git a/lib/ansible/modules/network/aci/aci_l3out.py b/lib/ansible/modules/network/aci/aci_l3out.py index cfe2480c6f0..ab8b7d07eab 100644 --- a/lib/ansible/modules/network/aci/aci_l3out.py +++ b/lib/ansible/modules/network/aci/aci_l3out.py @@ -280,10 +280,11 @@ def main(): state = module.params['state'] tenant = module.params['tenant'] - if 'eigrp' in l3protocol and asn is None: - module.fail_json(msg="Parameter 'asn' is required when l3protocol is 'eigrp'") - if 'eigrp' not in l3protocol and asn is not None: - module.warn("Parameter 'asn' is only applicable when l3protocol is 'eigrp'. The ASN will be ignored") + if l3protocol: + if 'eigrp' in l3protocol and asn is None: + module.fail_json(msg="Parameter 'asn' is required when l3protocol is 'eigrp'") + if 'eigrp' not in l3protocol and asn is not None: + module.warn("Parameter 'asn' is only applicable when l3protocol is 'eigrp'. The ASN will be ignored") enforce_ctrl = '' if enforceRtctrl is not None: