Refactor cluster checks to use common_check_list and readiness_loop

Change-Id: I3a1b28b7139c863805b5d66a461dc4a3a6baded8
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/osm_lcm/odu_libs/workflows.py b/osm_lcm/odu_libs/workflows.py
index 86cf743..a95e982 100644
--- a/osm_lcm/odu_libs/workflows.py
+++ b/osm_lcm/odu_libs/workflows.py
@@ -17,6 +17,7 @@
 
 
 import asyncio
+import traceback
 from math import ceil
 
 
@@ -101,3 +102,23 @@
         False,
         "{item} {name} was not ready after {max_iterations} iterations (aprox {timeout} seconds)",
     )
+
+
+async def common_check_list(self, checkings_list):
+    try:
+        for checking in checkings_list:
+            if checking["enable"]:
+                status, message = await self.readiness_loop(
+                    item=checking["item"],
+                    name=checking["name"],
+                    namespace=checking["namespace"],
+                    flag=checking["flag"],
+                    timeout=checking["timeout"],
+                )
+                if not status:
+                    return status, message
+    except Exception as e:
+        self.logger.debug(traceback.format_exc())
+        self.logger.debug(f"Exception: {e}", exc_info=True)
+        return False, f"Unexpected exception: {e}"
+    return True, "OK"