From: Rishabh Dave Date: Tue, 9 Oct 2018 20:47:40 +0000 (+0530) Subject: ceph-validate: avoid "list index out of range" error X-Git-Tag: v3.2.0beta9~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ff4dc83b87c31269106d7c0c7e475e7a08e96b06;p=ceph-ansible.git ceph-validate: avoid "list index out of range" error Be sure that error.path has more than one members before using them. Signed-off-by: Rishabh Dave --- diff --git a/plugins/actions/validate.py b/plugins/actions/validate.py index 5cedd83e7..e6e40f9fe 100644 --- a/plugins/actions/validate.py +++ b/plugins/actions/validate.py @@ -102,7 +102,12 @@ class ActionModule(ActionBase): reason = "[{}] Reason: {}".format(host, error.reason) try: if "schema is missing" not in error.message: - given = "[{}] Given value for {}: {}".format(host, error.path[0], error.path[1]) + for i in range(0, len(error.path)): + if i == 0: + given = "[{}] Given value for {}".format( + host, error.path[0]) + else: + given = given + ": {}".format(error.path[i]) display.error(given) else: given = ""