Handle flavor before image
[parser.git] / tests / functest_run.sh
index c85219e..3f7656c 100755 (executable)
@@ -74,6 +74,18 @@ download_parser_image() {
 }
 
 register_parser_image_and_flavor() {
+
+    echo ""
+    [[ ! $(openstack ${debug} flavor show ${VM_FLAVOR_NAME}) ]] && {
+        echo "  Create default flavor ${VM_FLAVOR_NAME}..."
+        openstack ${debug} flavor create --ram ${VM_FLAVOR_RAM} \
+                                --vcpus ${VM_FLAVOR_CPUS} \
+                                --disk ${VM_FLAVOR_DISK} \
+                                ${VM_FLAVOR_NAME}
+    } || {
+        echo "  Default flavor ${VM_FLAVOR_NAME} already exsits."
+    }
+
     openstack ${debug} image list | grep -qwo "${PARSER_IMAGE_NAME}" && {
         echo "  Image ${PARSER_IMAGE_NAME} has bee registed, needn't registe again."
         return 0
@@ -87,11 +99,6 @@ register_parser_image_and_flavor() {
                            --container-format bare \
                            --file ${PARSER_IMAGE_FILE}
 
-    [[ ! openstack flavor show ${VM_FLAVOR_NAME} ]] && {
-        echo "  Create default flavor ${VM_FLAVOR_NAME}..."
-        openstack flavor create --ram ${VM_FLAVOR_RAM} \
-            --vcpus ${VM_FLAVOR_CPUS} --disk ${VM_FLAVOR_DISK} ${VM_FLAVOR_NAM}
-    }
 }
 
 create_parser_user_and_project() {
@@ -186,8 +193,9 @@ translator_and_deploy_vRNC() {
         # 1. Delete parser stack ${PARSER_STACK_NAME}, use admin user in admin project
         openstack ${debug} stack list | grep -qow ${PARSER_STACK_NAME} && {
             echo "  Stack ${PARSER_STACK_NAME} exist, delete it first."
-            openstack stack delete --yes --wait ${PARSER_STACK_NAME}
+            openstack ${debug} stack delete --yes --wait ${PARSER_STACK_NAME}
         }
+
         # 2. Switch env to parser project temporally
         echo "  Switch openstack env to parser project"
         change_env_to_parser_user_project