summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/network/aci/mso_schema_site_bd.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/modules/network/aci/mso_schema_site_bd.py')
-rw-r--r--lib/ansible/modules/network/aci/mso_schema_site_bd.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/ansible/modules/network/aci/mso_schema_site_bd.py b/lib/ansible/modules/network/aci/mso_schema_site_bd.py
index 02b47d1fd6..636cbbf9ab 100644
--- a/lib/ansible/modules/network/aci/mso_schema_site_bd.py
+++ b/lib/ansible/modules/network/aci/mso_schema_site_bd.py
@@ -138,12 +138,12 @@ def main():
],
)
- schema = module.params['schema']
- site = module.params['site']
- template = module.params['template']
- bd = module.params['bd']
- host_route = module.params['host_route']
- state = module.params['state']
+ schema = module.params.get('schema')
+ site = module.params.get('site')
+ template = module.params.get('template')
+ bd = module.params.get('bd')
+ host_route = module.params.get('host_route')
+ state = module.params.get('state')
mso = MSOModule(module)
@@ -153,13 +153,13 @@ def main():
mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema))
schema_path = 'schemas/{id}'.format(**schema_obj)
- schema_id = schema_obj['id']
+ schema_id = schema_obj.get('id')
# Get site
site_id = mso.lookup_site(site)
# Get site_idx
- sites = [(s['siteId'], s['templateName']) for s in schema_obj['sites']]
+ sites = [(s.get('siteId'), s.get('templateName')) for s in schema_obj.get('sites')]
if (site_id, template) not in sites:
mso.fail_json(msg="Provided site/template '{0}-{1}' does not exist. Existing sites/templates: {2}".format(site, template, ', '.join(sites)))
@@ -170,15 +170,15 @@ def main():
# Get BD
bd_ref = mso.bd_ref(schema_id=schema_id, template=template, bd=bd)
- bds = [v['bdRef'] for v in schema_obj['sites'][site_idx]['bds']]
+ bds = [v.get('bdRef') for v in schema_obj.get('sites')[site_idx]['bds']]
if bd is not None and bd_ref in bds:
bd_idx = bds.index(bd_ref)
bd_path = '/sites/{0}/bds/{1}'.format(site_template, bd)
- mso.existing = schema_obj['sites'][site_idx]['bds'][bd_idx]
+ mso.existing = schema_obj.get('sites')[site_idx]['bds'][bd_idx]
if state == 'query':
if bd is None:
- mso.existing = schema_obj['sites'][site_idx]['bds']
+ mso.existing = schema_obj.get('sites')[site_idx]['bds']
elif not mso.existing:
mso.fail_json(msg="BD '{bd}' not found".format(bd=bd))
mso.exit_json()