]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-validate: avoid "list index out of range" error
authorRishabh Dave <ridave@redhat.com>
Tue, 9 Oct 2018 20:47:40 +0000 (02:17 +0530)
committermergify[bot] <mergify[bot]@users.noreply.github.com>
Wed, 24 Oct 2018 18:21:48 +0000 (18:21 +0000)
Be sure that error.path has more than one members before using them.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
plugins/actions/validate.py

index 5cedd83e71a1700e127b32bce9db6042f985ed2c..e6e40f9fe671433db240d4f8e7dc4e1203004ee4 100644 (file)
@@ -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 = ""