Merge "docs/build-instr: Fix git clone URL for HTTPS." into stable/brahmaputra
[fuel.git] / deploy / common.py
index ccd43d7..787a21a 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()
@@ -49,8 +48,13 @@ def exec_cmd(cmd, check=True):
     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
 
@@ -129,8 +133,8 @@ def commafy(comma_separated_list):
 
 
 def check_if_root():
-    r = exec_cmd('whoami')
-    if r != 'root':
+    uid = os.getuid()
+    if uid != 0:
         err('You need be root to run this application')