Merge "Scenario for SFC"
[fuel.git] / deploy / common.py
index 17fd217..cc418b5 100644 (file)
@@ -18,9 +18,8 @@ import stat
 import errno
 
 N = {'id': 0, 'status': 1, 'name': 2, 'cluster': 3, 'ip': 4, 'mac': 5,
-     'roles': 6, 'pending_roles': 7, 'online': 8}
-E = {'id': 0, 'status': 1, 'name': 2, 'mode': 3, 'release_id': 4,
-     'changes': 5, 'pending_release_id': 6}
+     'roles': 6, 'pending_roles': 7, 'online': 8, 'group_id': 9}
+E = {'id': 0, 'status': 1, 'name': 2, 'release_id': 3, 'pending_release_id': 4}
 R = {'id': 0, 'name': 1, 'state': 2, 'operating_system': 3, 'version': 4}
 RO = {'name': 0, 'conflicts': 1}
 CWD = os.getcwd()
@@ -39,16 +38,23 @@ LOG.addHandler(out_handler)
 os.chmod(LOGFILE, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
 
 def exec_cmd(cmd, check=True):
+    nul_f = open(os.devnull, 'w')
     process = subprocess.Popen(cmd,
                                stdout=subprocess.PIPE,
-                               stderr=subprocess.STDOUT,
+                               stderr=nul_f,
                                shell=True)
+    nul_f.close()
     response = process.communicate()[0].strip()
     return_code = process.returncode
     if check:
         if return_code > 0:
+            print "Failed command: " + str(cmd)
+            print "Command returned response: " + str(response)
+            print "Command return code: " + str(return_code)
             raise Exception(response)
         else:
+            print "Command: " + str(cmd)
+            print str(response)
             return response
     return response, return_code