Adding running checks for neutron.client

The patch adds waiter check for neutron.client in order
to be sure that neutron services are up and running before
execute neutron.client state.

Change-Id: I858c30b2dad81f6b5ee42bda9b3d3379d4265425
Related-PROD: PROD-24685
diff --git a/_modules/neutronng.py b/_modules/neutronng.py
index 6ea50f9..87bc154 100644
--- a/_modules/neutronng.py
+++ b/_modules/neutronng.py
@@ -1,7 +1,9 @@
 # -*- coding: utf-8 -*-
 
 import logging
+import time
 from functools import wraps
+from salt.exceptions import CommandExecutionError
 LOG = logging.getLogger(__name__)
 
 # Import third party libs
@@ -416,3 +418,22 @@
         salt '*' neutronng.list_extensions
     '''
     return neutron_interface.list_extensions(**kwargs)
+
+
+def wait_for_api_ready(profile, retries=1, retry_timeout=10):
+
+    response = {'status': 'up'}
+    for i in range(1, retries+1):
+        try:
+            list_routers(profile=profile)
+        except Exception as e:
+                msg = ("Error: %s "
+                       "Sleeping for %ss. "
+                       "Attempts %s of %s ")
+                LOG.error(msg % (e, retry_timeout, i, retries))
+                time.sleep(retry_timeout)
+                if i == retries:
+                  raise CommandExecutionError(e)
+                continue
+    return response
+