Merge "Fix ssl cert upload path"
[fuel.git] / deploy / cloud / deployment.py
index ecccc24..4329a4c 100644 (file)
@@ -13,15 +13,10 @@ import json
 
 from common import (
     N,
-    E,
     exec_cmd,
-    run_proc,
-    run_proc_wait_terminated,
-    run_proc_kill,
     parse,
     err,
     log,
-    delete,
 )
 
 SEARCH_TEXT = '(err)'
@@ -29,6 +24,10 @@ LOG_FILE = '/var/log/puppet.log'
 GREP_LINES_OF_LEADING_CONTEXT = 100
 GREP_LINES_OF_TRAILING_CONTEXT = 100
 LIST_OF_CHAR_TO_BE_ESCAPED = ['[', ']', '"']
+ERROR_MSGS = ['Critical nodes are not available for deployment',
+              'offline. Remove them from environment and try again.',
+              'Task[move_to_bootstrap/',
+              'Failed tasks: Task[connectivity-checker/']
 
 
 class DeployNotStart(Exception):
@@ -117,8 +116,8 @@ class Deployment(object):
         ready = False
         timeout = False
 
-        attempts = 0
-        while attempts < 3:
+        attempts = 5
+        while attempts > 0:
             try:
                 if time.time() > start + abort_after:
                     timeout = True
@@ -130,14 +129,14 @@ class Deployment(object):
                     log('Error during deployment: {}'.format(msg))
                     break
                 if sts == 'running':
-                    log('Environmnent deploymnet progress: {}%'.format(prg))
+                    log('Environment deployment progress: {}%'.format(prg))
                 elif sts == 'ready':
                     ready = True
                     break
                 time.sleep(SLEEP_TIME)
             except (DeployNotStart, NodesGoOffline) as e:
                 log(e)
-                attempts += 1
+                attempts -= 1
                 deploy_id = None
                 time.sleep(SLEEP_TIME * attempts)
 
@@ -169,8 +168,7 @@ class Deployment(object):
     def _deployment_status(self, id):
         task = self._task_fields(id)
         if task['status'] == 'error':
-            if task['message'].endswith(
-                    'offline. Remove them from environment and try again.'):
+            if any(msg in task['message'] for msg in ERROR_MSGS):
                 raise NodesGoOffline(task['message'])
         return task['status'], task['progress'], task['message']
 
@@ -195,7 +193,7 @@ class Deployment(object):
         exec_cmd('rm -f /var/log/remote/fuel-snapshot-*', False)
         exec_cmd('rm -f /root/deploy-*', False)
         log('Generating Fuel deploy snap-shot')
-        if exec_cmd('fuel snapshot < /dev/null &> snapshot.log', False)[1] <> 0:
+        if exec_cmd('fuel snapshot < /dev/null &> snapshot.log', False)[1] != 0:
             log('Could not create a Fuel snapshot')
         else:
             exec_cmd('mv /root/fuel-snapshot* /var/log/remote/', False)