summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/network/aci/mso_schema_template_l3out.py
diff options
context:
space:
mode:
authorDag Wieers <dag@wieers.com>2019-11-06 18:24:11 +0100
committerGitHub <noreply@github.com>2019-11-06 18:24:11 +0100
commit26e0e4be016ea341f3cdfdcdd07a17d433ed44cb (patch)
treeed49eea26dbcb0c3014bc4a3c5d70fb648d4c082 /lib/ansible/modules/network/aci/mso_schema_template_l3out.py
parent1f5d2f9159ed2f5680a0074c37fd163067557e1a (diff)
downloadansible-26e0e4be016ea341f3cdfdcdd07a17d433ed44cb.tar.gz
ACI/MSO: Use get() dict lookups (#63074)
This improves the reliability of the modules somewhat.
Diffstat (limited to 'lib/ansible/modules/network/aci/mso_schema_template_l3out.py')
-rw-r--r--lib/ansible/modules/network/aci/mso_schema_template_l3out.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/ansible/modules/network/aci/mso_schema_template_l3out.py b/lib/ansible/modules/network/aci/mso_schema_template_l3out.py
index 44390d01f2..6bdeff982f 100644
--- a/lib/ansible/modules/network/aci/mso_schema_template_l3out.py
+++ b/lib/ansible/modules/network/aci/mso_schema_template_l3out.py
@@ -144,40 +144,40 @@ def main():
],
)
- schema = module.params['schema']
- template = module.params['template']
- l3out = module.params['l3out']
- display_name = module.params['display_name']
- vrf = module.params['vrf']
- state = module.params['state']
+ schema = module.params.get('schema')
+ template = module.params.get('template')
+ l3out = module.params.get('l3out')
+ display_name = module.params.get('display_name')
+ vrf = module.params.get('vrf')
+ state = module.params.get('state')
mso = MSOModule(module)
# Get schema_id
schema_obj = mso.get_obj('schemas', displayName=schema)
if schema_obj:
- schema_id = schema_obj['id']
+ schema_id = schema_obj.get('id')
else:
mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema))
schema_path = 'schemas/{id}'.format(**schema_obj)
# Get template
- templates = [t['name'] for t in schema_obj['templates']]
+ templates = [t.get('name') for t in schema_obj.get('templates')]
if template not in templates:
mso.fail_json(msg="Provided template '{0}' does not exist. Existing templates: {1}".format(template, ', '.join(templates)))
template_idx = templates.index(template)
# Get L3out
- l3outs = [l['name'] for l in schema_obj['templates'][template_idx]['intersiteL3outs']]
+ l3outs = [l.get('name') for l in schema_obj.get('templates')[template_idx]['intersiteL3outs']]
if l3out is not None and l3out in l3outs:
l3out_idx = l3outs.index(l3out)
- mso.existing = schema_obj['templates'][template_idx]['intersiteL3outs'][l3out_idx]
+ mso.existing = schema_obj.get('templates')[template_idx]['intersiteL3outs'][l3out_idx]
if state == 'query':
if l3out is None:
- mso.existing = schema_obj['templates'][template_idx]['intersiteL3outs']
+ mso.existing = schema_obj.get('templates')[template_idx]['intersiteL3outs']
elif not mso.existing:
mso.fail_json(msg="L3out '{l3out}' not found".format(l3out=l3out))
mso.exit_json()