Fixed creating custom heat envs if enviroment contains path

Change-Id: I7320c7b047e102005bdd462a2a3bceaee7595c56
diff --git a/src/com/mirantis/mk/Openstack.groovy b/src/com/mirantis/mk/Openstack.groovy
index 87c11eb..089fc15 100644
--- a/src/com/mirantis/mk/Openstack.groovy
+++ b/src/com/mirantis/mk/Openstack.groovy
@@ -167,14 +167,19 @@
         if (legacy_env) {
             envFile = "${env.WORKSPACE}/template/env/${template}/${name}.env"
             envSource = "${env.WORKSPACE}/template/env/${template}/${environment}.env"
-        }
-        else {
+        } else {
+            if(environment.contains("/")){
+              //init() returns all elements but the last in a collection.
+              def envPath = env.tokenize("/").init().join("/")
+              if(envPath){
+                name = envPath + "/" + name
+              }
+            }
             envFile = "${env.WORKSPACE}/template/env/${name}.env"
             envSource = "${env.WORKSPACE}/template/env/${environment}.env"
         }
         createHeatEnv(envFile, params, envSource)
-    }
-    else {
+    } else {
         envFile = "${env.WORKSPACE}/template/${name}.env"
         createHeatEnv(envFile, params)
     }
@@ -184,11 +189,10 @@
     }
     output = python.parseTextTable(outputTable, 'item', 'prettytable', path)
 
-    i = 1
-
-    while (true) {
+    def heatStatusCheckerCount = 1
+    while (heatStatusCheckerCount <= 500) {
         status = getHeatStackStatus(client, name, path)
-        echo("[Heat Stack] Status: ${status}, Check: ${i}")
+        echo("[Heat Stack] Status: ${status}, Check: ${heatStatusCheckerCount}")
 
         if (status.indexOf('CREATE_FAILED') != -1) {
             info = getHeatStackInfo(client, name, path)
@@ -200,7 +204,7 @@
             break
         }
         sh('sleep 5s')
-        i++
+        heatStatusCheckerCount++
     }
     echo("[Heat Stack] Status: ${status}")
 }