Opera adapter fix 1 65/31365/4
authorHarry Huang <huangxiangyu5@huawei.com>
Wed, 22 Mar 2017 10:45:54 +0000 (18:45 +0800)
committerHarry Huang <huangxiangyu5@huawei.com>
Wed, 22 Mar 2017 13:41:21 +0000 (21:41 +0800)
After adding sudo opera_adapter can't get $COMPASS_DIR
and still has the issue returning 0 when launch opera
fail.

Changing the way opera_adapter gets $COMPASS_DIR and
add judgement inside opera_adapter to get opera launch
error.

Change-Id: I59d0d496f47b38e474de3dfc1277877dbe8ed840
Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
deploy/launch.sh
deploy/opera_adapter.py

index 5f1ee1c..51b502f 100755 (executable)
@@ -142,8 +142,9 @@ echo "NOTE: openrc file is in the controller nodes"
 echo ""
 
 if [[ ${DHA##*/} =~ "openo" ]]; then
-    sudo python ${COMPASS_DIR}/deploy/opera_adapter.py $DHA $NETWORK
+    python ${COMPASS_DIR}/deploy/opera_adapter.py $DHA $NETWORK
     if [[ $? -ne 0 ]]; then
+        log_error 'opera launch failed'
         exit 1
     fi
 fi
index 71f1995..f83638d 100644 (file)
@@ -76,14 +76,14 @@ if __name__ == "__main__":
     compass_dir = os.getenv('COMPASS_DIR')
 
     if not compass_dir:
-        print("env var COMPASS_DIR  doesn't exit")
+        print("env var COMPASS_DIR  doesn't exist")
         sys.exit(1)
 
     if not os.path.exists(dha_file):
-        print("DHA file doesn't exit")
+        print("DHA file doesn't exist")
         sys.exit(1)
     if not os.path.exists(network_file):
-        print("NETWORK file doesn't exit")
+        print("NETWORK file doesn't exist")
         sys.exit(1)
 
     dha = load_file(dha_file)
@@ -119,5 +119,8 @@ if __name__ == "__main__":
     dump_file(openo_config, openo_config_file)
     sync_admin_openrc(network, admin_openrc_file)
 
-    p2 = subprocess.Popen("./opera_launch.sh", cwd=opera_dir, shell=True)
+    p2 = subprocess.Popen("sudo ./opera_launch.sh", cwd=opera_dir, shell=True)
     p2.communicate()
+    if p2.returncode != 0:
+        print('./opera_launch.sh fail')
+        sys.exit(1)