Merge "Use new _get_keystone_creds_vX methods for cvp-func, cvp-perf, cvp-ha"
diff --git a/generate-cookiecutter-products.groovy b/generate-cookiecutter-products.groovy
index 6347808..7609103 100644
--- a/generate-cookiecutter-products.groovy
+++ b/generate-cookiecutter-products.groovy
@@ -13,7 +13,6 @@
 saltModelTesting = new com.mirantis.mk.SaltModelTesting()
 ssh = new com.mirantis.mk.Ssh()
 
-reclassVersion = env.RECLASS_VERSION ?: 'v1.5.4'
 slaveNode = env.SLAVE_NODE ?: 'python&&docker'
 
 timeout(time: 2, unit: 'HOURS') {
@@ -162,15 +161,26 @@
 
             stage("Test") {
                 if (TEST_MODEL.toBoolean() && sharedReclassUrl != '') {
+                    distribRevision = mcpVersion
+                    if (['master'].contains(mcpVersion)) {
+                        distribRevision = 'nightly'
+                    }
+                    if (distribRevision.contains('/')) {
+                        distribRevision = distribRevision.split('/')[-1]
+                    }
+                    // Check if we are going to test bleeding-edge release, which doesn't have binary release yet
+                    if (!common.checkRemoteBinary([apt_mk_version: distribRevision]).linux_system_repo_url) {
+                        common.errorMsg("Binary release: ${distribRevision} not exist. Fallback to 'proposed'! ")
+                        distribRevision = 'proposed'
+                    }
                     sh("cp -r ${modelEnv} ${testEnv}")
                     def DockerCName = "${env.JOB_NAME.toLowerCase()}_${env.BUILD_TAG.toLowerCase()}"
-                    common.infoMsg("Attempt to run test against formula-version: ${mcpVersion}")
+                    common.infoMsg("Attempt to run test against distribRevision: ${distribRevision}")
                     try {
                         def config = [
                             'dockerHostname'     : "${saltMaster}.${clusterDomain}",
                             'reclassEnv'         : testEnv,
-                            'formulasRevision'   : mcpVersion,
-                            'reclassVersion'     : reclassVersion,
+                            'distribRevision'    : distribRevision,
                             'dockerContainerName': DockerCName,
                             'testContext'        : 'salt-model-node'
                         ]
diff --git a/test-cookiecutter-reclass-chunk.groovy b/test-cookiecutter-reclass-chunk.groovy
index ebc4f9a..b1266a3 100644
--- a/test-cookiecutter-reclass-chunk.groovy
+++ b/test-cookiecutter-reclass-chunk.groovy
@@ -30,8 +30,7 @@
                     'dockerHostname': "cfg01.${templateContext.default_context.cluster_domain}",
                     'clusterName': templateContext.default_context.cluster_name,
                     'reclassEnv': extraVars.testReclassEnv,
-                    'formulasRevision': extraVars.DISTRIB_REVISION,
-                    'reclassVersion': extraVars.reclassVersion,
+                    'distribRevision': extraVars.DISTRIB_REVISION,
                     'dockerContainerName': extraVars.DockerCName,
                     'testContext': extraVars.modelFile
                 ]
diff --git a/test-cookiecutter-reclass.groovy b/test-cookiecutter-reclass.groovy
index 6f73570..c09c572 100644
--- a/test-cookiecutter-reclass.groovy
+++ b/test-cookiecutter-reclass.groovy
@@ -53,12 +53,8 @@
 gerritDataRS['gerritRefSpec'] = env.RECLASS_SYSTEM_GIT_REF ?: null
 gerritDataRS['gerritProject'] = 'salt-models/reclass-system'
 
-// version of debRepos, aka formulas\reclass
+// version of debRepos, aka formulas|reclass|ubuntu
 testDistribRevision = env.DISTRIB_REVISION ?: 'nightly'
-reclassVersion = 'v1.5.4'
-if (env.RECLASS_VERSION) {
-    reclassVersion = env.RECLASS_VERSION
-}
 // Name of sub-test chunk job
 chunkJobName = "test-mk-cookiecutter-templates-chunk"
 testModelBuildsData = [:]
@@ -157,7 +153,6 @@
   testReclassEnv: "model/${modelFile}/"
   modelFile: "contexts/${modelFile}.yml"
   DISTRIB_REVISION: "${testDistribRevision}"
-  reclassVersion: "${reclassVersion}"
   """
     def chunkJob = build job: chunkJobName, parameters: [
         [$class: 'TextParameterValue', name: 'EXTRA_VARIABLES_YAML',
diff --git a/test-customers-salt-models.groovy b/test-customers-salt-models.groovy
index 4e84e22..4a24918 100644
--- a/test-customers-salt-models.groovy
+++ b/test-customers-salt-models.groovy
@@ -22,7 +22,7 @@
             //   [$class: 'StringParameterValue', name: 'CLUSTER_NAME', value: modelName],
             //   [$class: 'StringParameterValue', name: 'NODE_TARGET', value: testTarget],
             //   [$class: 'StringParameterValue', name: 'FORMULAS_SOURCE', value: formulasSource]
-            //   [$class: 'StringParameterValue', name: 'FORMULAS_REVISION', value: FORMULAS_REVISION],
+            // [$class: 'StringParameterValue', name: 'DISTRIB_REVISION', value: distribRevision],
             //   [$class: 'StringParameterValue', name: 'CREDENTIALS_ID', value: CREDENTIALS_ID],
             //   [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: SYSTEM_GIT_URL],
             //   [$class: 'StringParameterValue', name: 'MAX_CPU_PER_JOB', value: MAX_CPU_PER_JOB],
diff --git a/test-openstack-component-pipeline.groovy b/test-openstack-component-pipeline.groovy
index 010dbc0..5f1730f 100644
--- a/test-openstack-component-pipeline.groovy
+++ b/test-openstack-component-pipeline.groovy
@@ -4,8 +4,6 @@
 
  * Flow parameters:
  *   CREDENTIALS_ID
- *   FORMULAS_REVISION
- *   FORMULAS_SOURCE
  *   SALT_OPTS
  *   STACK_DEPLOY_JOB
 
diff --git a/test-salt-model-node.groovy b/test-salt-model-node.groovy
index 9bbd782..27e0909 100644
--- a/test-salt-model-node.groovy
+++ b/test-salt-model-node.groovy
@@ -8,7 +8,7 @@
  *  NODE_TARGET
  *  SYSTEM_GIT_URL
  *  SYSTEM_GIT_REF
- *  RECLASS_VERSION
+ *  DISTRIB_REVISION of apt mirrror to be used (http://mirror.mirantis.com/DISTRIB_REVISION/ by default)
  *  MAX_CPU_PER_JOB
  *  LEGACY_TEST_MODE
  *  RECLASS_IGNORE_CLASS_NOTFOUND
@@ -22,16 +22,12 @@
 def ssh = new com.mirantis.mk.Ssh()
 def saltModelTesting = new com.mirantis.mk.SaltModelTesting()
 
-def defaultGitRef = DEFAULT_GIT_REF
-def defaultGitUrl = DEFAULT_GIT_URL
+def defaultGitRef = env.DEFAULT_GIT_REF ?: null
+def defaultGitUrl = env.DEFAULT_GIT_URL ?: null
 
+def distribRevision = env.DISTRIB_REVISION ?: 'nightly'
 def checkouted = false
 
-def reclassVersion = 'v1.5.4'
-if (common.validInputParam('RECLASS_VERSION')) {
-  reclassVersion = RECLASS_VERSION
-}
-
 throttle(['test-model']) {
   timeout(time: 1, unit: 'HOURS') {
     node("python&&docker") {
@@ -72,8 +68,7 @@
               'dockerHostname': NODE_TARGET,
               'clusterName': CLUSTER_NAME,
               'reclassEnv': workspace,
-              'formulasRevision': FORMULAS_REVISION,
-              'reclassVersion': reclassVersion,
+              'distribRevision': distribRevision,
               'dockerMaxCpus': MAX_CPU_PER_JOB.toInteger(),
               'ignoreClassNotfound': RECLASS_IGNORE_CLASS_NOTFOUND,
               'aptRepoUrl': APT_REPOSITORY,
diff --git a/test-salt-models-pipeline.groovy b/test-salt-models-pipeline.groovy
index 729fdb4..3b88aee 100644
--- a/test-salt-models-pipeline.groovy
+++ b/test-salt-models-pipeline.groovy
@@ -9,56 +9,29 @@
  *  TEST_CLUSTER_NAMES list of comma separated cluster names to test (optional, default all cluster levels)
  *  LEGACY_TEST_MODE legacy test mode flag
  *  RECLASS_IGNORE_CLASS_NOTFOUND ignore missing class flag for reclass config
- *  RECLASS_VERSION Version of reclass to be used (branch, ...)
+ *  DISTRIB_REVISION of apt mirrror to be used (http://mirror.mirantis.com/DISTRIB_REVISION/ by default)
  *  APT_REPOSITORY extra apt repository url
  *  APT_REPOSITORY_GPG extra apt repository url GPG
  */
 
 def gerrit = new com.mirantis.mk.Gerrit()
+common = new com.mirantis.mk.Common()
 def ssh = new com.mirantis.mk.Ssh()
 def git = new com.mirantis.mk.Git()
 
-def config_node_name_pattern
-try {
-  config_node_name_pattern = CONFIG_NODE_NAME_PATTERN
-} catch (MissingPropertyException e) {
-  config_node_name_pattern = "cfg01"
-}
+def config_node_name_pattern = env.CONFIG_NODE_NAME_PATTERN ?: 'cfg01'
+def gerritRef = env.GERRIT_REFSPEC ?: null
+def formulasSource = env.FORMULAS_SOURCE ?: 'pkg'
+distribRevision = env.DISTRIB_REVISION ?: 'nightly'
 
-def gerritRef
-try {
-  gerritRef = GERRIT_REFSPEC
-} catch (MissingPropertyException e) {
-  gerritRef = null
-}
-
-def formulasSource
-try {
-  formulasSource = FORMULAS_SOURCE
-} catch (MissingPropertyException e) {
-  formulasSource = "pkg"
-}
-
-def testClusterNames
-try {
-  testClusterNames = TEST_CLUSTER_NAMES
-} catch (MissingPropertyException e) {
-  testClusterNames = ""
-}
-
-def defaultGitRef, defaultGitUrl
-try {
-    defaultGitRef = DEFAULT_GIT_REF
-    defaultGitUrl = DEFAULT_GIT_URL
-} catch (MissingPropertyException e) {
-    defaultGitRef = null
-    defaultGitUrl = null
-}
+def testClusterNames = env.TEST_CLUSTER_NAMES ?: ''
+def defaultGitRef = env.DEFAULT_GIT_REF ?: null
+def defaultGitUrl = env.DEFAULT_GIT_URL ?: null
 
 def checkouted = false
 futureNodes = []
 failedNodes = false
-common = new com.mirantis.mk.Common()
+
 
 def setupRunner() {
     def branches = [:]
@@ -91,10 +64,9 @@
     [$class: 'StringParameterValue', name: 'CLUSTER_NAME', value: clusterName],
     [$class: 'StringParameterValue', name: 'NODE_TARGET', value: testTarget],
     [$class: 'StringParameterValue', name: 'FORMULAS_SOURCE', value: formulasSource],
-    [$class: 'StringParameterValue', name: 'FORMULAS_REVISION', value: FORMULAS_REVISION],
     [$class: 'StringParameterValue', name: 'CREDENTIALS_ID', value: CREDENTIALS_ID],
     [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: SYSTEM_GIT_URL],
-    [$class: 'StringParameterValue', name: 'RECLASS_VERSION', value: RECLASS_VERSION],
+    [$class: 'StringParameterValue', name: 'DISTRIB_REVISION', value: distribRevision],
     [$class: 'StringParameterValue', name: 'MAX_CPU_PER_JOB', value: MAX_CPU_PER_JOB],
     [$class: 'StringParameterValue', name: 'SYSTEM_GIT_REF', value: SYSTEM_GIT_REF],
     [$class: 'BooleanParameterValue', name: 'LEGACY_TEST_MODE', value: LEGACY_TEST_MODE.toBoolean()],