Merge "Optimize openscap pipeline"
diff --git a/branch-git-repos.groovy b/branch-git-repos.groovy
index 47c143a..0624c40 100644
--- a/branch-git-repos.groovy
+++ b/branch-git-repos.groovy
@@ -116,19 +116,9 @@
                 sh "git branch -d '${gitBranchNew}' && git push origin ':${gitBranchNew}' || :"
                 sh "git tag    -d '${gitBranchNew}' && git push origin ':refs/tags/${gitBranchNew}' || :"
 
-                // Check if gitSrcObj is a branch
-                gitCommit = sh (script: "git ls-remote --heads --quiet origin '${gitSrcObj}' | awk '{print \$1}'",
-                                returnStdout: true).trim()
-                if (gitCommit) {
-                // Rename existing branch
-                    sh "git checkout -b '${gitSrcObj}' -t 'origin/${gitSrcObj}'" // Checkout old branch
-                    sh "git branch -m '${gitSrcObj}' '${gitBranchNew}'"          // ... rename it
-                    sh "git push origin ':${gitSrcObj}'"                         // ... remove old remote branch
-                } else {
                 // Create new branch
-                    sh "git checkout -b '${gitBranchNew}' '${gitSrcObj}'"        // Create new local branch
-                }
-                sh "git push origin '${gitBranchNew}'"                           // ... push new branch
+                sh "git checkout -b '${gitBranchNew}' '${gitSrcObj}'" // Create new local branch
+                sh "git push origin '${gitBranchNew}'"                // ... push new branch
             }
         }
     }
diff --git a/cloud-deploy-pipeline.groovy b/cloud-deploy-pipeline.groovy
index aadc7c9..a51f436 100644
--- a/cloud-deploy-pipeline.groovy
+++ b/cloud-deploy-pipeline.groovy
@@ -486,6 +486,7 @@
 
                     if (common.checkContains('STACK_INSTALL', 'contrail')) {
                         orchestrate.installContrailCompute(venvPepper, extra_tgt)
+                        orchestrate.installBackup(venvPepper, 'contrail', extra_tgt)
                     }
                 }
 
diff --git a/cvp-func.groovy b/cvp-func.groovy
index d1fff1a..120bb9d 100644
--- a/cvp-func.groovy
+++ b/cvp-func.groovy
@@ -1,6 +1,6 @@
 /**
  *
- * Launch validation of the cloud
+ * Launch CVP Tempest verification of the cloud
  *
  * Expected parameters:
 
@@ -14,7 +14,7 @@
  *   SKIP_LIST_PATH              Path to tempest skip list file in TOOLS_REPO
  *   TARGET_NODE                 Node to run container with Tempest/Rally
  *   TEMPEST_REPO                Tempest repo to clone and use
- *   TEMPEST_TEST_PATTERN        Tests to run during HA scenarios
+ *   TEMPEST_TEST_PATTERN        Tests to run
  *   TEMPEST_ENDPOINT_TYPE       Type of OS endpoint to use during test run
  *
  */
@@ -26,15 +26,20 @@
 def saltMaster
 def artifacts_dir = 'validation_artifacts/'
 def remote_artifacts_dir = '/root/qa_results/'
+def container_name = "${env.JOB_NAME}"
 
 node() {
     try{
         stage('Initialization') {
-            saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
-            validate.runBasicContainer(saltMaster, TARGET_NODE, TEST_IMAGE)
             sh "rm -rf ${artifacts_dir}"
+            saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
             salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
             salt.cmdRun(saltMaster, TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
+            keystone_creds = validate._get_keystone_creds_v3(saltMaster)
+            if (!keystone_creds) {
+                keystone_creds = validate._get_keystone_creds_v2(saltMaster)
+            }
+            validate.runContainer(saltMaster, TARGET_NODE, TEST_IMAGE, container_name, keystone_creds)
             validate.configureContainer(saltMaster, TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO, TEMPEST_ENDPOINT_TYPE)
         }
 
diff --git a/cvp-ha.groovy b/cvp-ha.groovy
index ab5b5d4..649ac6a 100644
--- a/cvp-ha.groovy
+++ b/cvp-ha.groovy
@@ -1,6 +1,6 @@
 /**
  *
- * Launch HA test for the cloud
+ * Launch CVP HA testing for the cloud (virtualized control plane only)
  *
  * Expected parameters:
  *
@@ -28,6 +28,7 @@
 def saltMaster
 def artifacts_dir = 'validation_artifacts/'
 def remote_artifacts_dir = '/root/qa_results/'
+def container_name = "${env.JOB_NAME}"
 def current_target_node = null
 def first_node = null
 def tempest_result = ''
@@ -36,11 +37,15 @@
         def num_retries = Integer.parseInt(RETRY_CHECK_STATUS)
         try {
             stage('Initialization') {
-                saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
-                validate.runBasicContainer(saltMaster, TEMPEST_TARGET_NODE, TEST_IMAGE)
                 sh "rm -rf ${artifacts_dir}"
+                saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
                 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
                 salt.cmdRun(saltMaster, TEMPEST_TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
+                keystone_creds = validate._get_keystone_creds_v3(saltMaster)
+                if (!keystone_creds) {
+                    keystone_creds = validate._get_keystone_creds_v2(saltMaster)
+                }
+                validate.runContainer(saltMaster, TARGET_NODE, TEST_IMAGE, container_name, keystone_creds)
                 validate.configureContainer(saltMaster, TEMPEST_TARGET_NODE, PROXY, TOOLS_REPO, TEMPEST_REPO)
             }
 
diff --git a/cvp-perf.groovy b/cvp-perf.groovy
index fe86197..7938572 100644
--- a/cvp-perf.groovy
+++ b/cvp-perf.groovy
@@ -1,6 +1,6 @@
 /**
  *
- * Launch validation of the cloud
+ * Launch CVP Rally performance testing of the cloud
  *
  * Expected parameters:
  *   SALT_MASTER_URL             URL of Salt master
@@ -21,16 +21,21 @@
 
 def artifacts_dir = 'validation_artifacts/'
 def remote_artifacts_dir = '/root/qa_results/'
+def container_name = "${env.JOB_NAME}"
 def saltMaster
 
 node() {
     try{
         stage('Initialization') {
-            saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
             sh "rm -rf ${artifacts_dir}"
+            saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
             salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_artifacts_dir}")
             salt.cmdRun(saltMaster, TARGET_NODE, "mkdir -p ${remote_artifacts_dir}")
-            validate.runBasicContainer(saltMaster, TARGET_NODE, TEST_IMAGE)
+            keystone_creds = validate._get_keystone_creds_v3(saltMaster)
+            if (!keystone_creds) {
+                keystone_creds = validate._get_keystone_creds_v2(saltMaster)
+            }
+            validate.runContainer(saltMaster, TARGET_NODE, TEST_IMAGE, container_name, keystone_creds)
             validate.configureContainer(saltMaster, TARGET_NODE, PROXY, TOOLS_REPO, "")
         }
 
diff --git a/cvp-runner.groovy b/cvp-runner.groovy
index dd58da5..7cf8e28 100644
--- a/cvp-runner.groovy
+++ b/cvp-runner.groovy
@@ -10,30 +10,107 @@
  *   TESTS_REPO                      Repo to clone
  *   TESTS_SETTINGS                  Additional environment varibales to apply
  *   PROXY                           Proxy to use for cloning repo or for pip
+ *   TEST_IMAGE                      Docker image link or name to use for running container with test framework.
+ *   DEBUG_MODE                      If you need to debug (keep container after test), please enabled this
  *
  */
 
+common = new com.mirantis.mk.Common()
 validate = new com.mirantis.mcp.Validate()
-
+salt = new com.mirantis.mk.Salt()
 def artifacts_dir = 'validation_artifacts/'
+def remote_dir = '/root/qa_results/'
+def container_workdir = '/var/lib'
+def TARGET_NODE = "I@gerrit:client"
+def reinstall_env = false
+def container_name = "${env.JOB_NAME}"
+def saltMaster
+def settings
 
 node() {
     try{
         stage('Initialization') {
-            validate.prepareVenv(TESTS_REPO, PROXY)
+            sh "rm -rf ${artifacts_dir}"
+            if ( TESTS_SETTINGS != "" ) {
+                for (var in TESTS_SETTINGS.tokenize(";")) {
+                    key = var.tokenize("=")[0].trim()
+                    value = var.tokenize("=")[1].trim()
+                    if (key == 'TARGET_NODE') {
+                        TARGET_NODE = value
+                        common.infoMsg("Node for container is set to ${TARGET_NODE}")
+                    }
+                    if (key == 'REINSTALL_ENV') {
+                        reinstall_env = value.toBoolean()
+                    }
+                }
+            }
+            if ( IMAGE == "" ) {
+                common.infoMsg("Env for tests will be built on Jenkins slave")
+                TARGET_NODE = ""
+                validate.prepareVenv(TESTS_REPO, PROXY)
+            } else {
+                saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+                salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_dir}")
+                salt.cmdRun(saltMaster, TARGET_NODE, "mkdir -p ${remote_dir}")
+                validate.runContainer(saltMaster, TARGET_NODE, IMAGE, container_name)
+                if ( TESTS_REPO != "") {
+                    salt.cmdRun(saltMaster, TARGET_NODE, "docker exec ${container_name} rm -rf ${container_workdir}/cvp*")
+                    salt.cmdRun(saltMaster, TARGET_NODE, "docker exec ${container_name} git clone ${TESTS_REPO} ${container_workdir}/${container_name}")
+                    TESTS_SET = container_workdir + '/' + container_name + '/' + TESTS_SET
+                    if ( reinstall_env ) {
+                        common.infoMsg("Pip packages in container will be reinstalled based on requirements.txt from ${TESTS_REPO}")
+                        salt.cmdRun(saltMaster, TARGET_NODE, "docker exec ${container_name} pip install --force-reinstall -r ${container_workdir}/${container_name}/requirements.txt")
+                    }
+                }
+            }
         }
 
         stage('Run Tests') {
             sh "mkdir -p ${artifacts_dir}"
-            validate.runTests(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS, TESTS_SET, artifacts_dir, TESTS_SETTINGS)
+            validate.runPyTests(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS, TESTS_SET, TESTS_SETTINGS.tokenize(";"), container_name, TARGET_NODE, remote_dir, artifacts_dir)
         }
+
         stage ('Publish results') {
             archiveArtifacts artifacts: "${artifacts_dir}/*"
             junit "${artifacts_dir}/*.xml"
+            if (env.JOB_NAME.contains("cvp-spt")) {
+                plot csvFileName: 'plot-8634d2fe-dc48-4713-99f9-b69a381483aa.csv',
+                     group: 'SPT',
+                     style: 'line',
+                     title: 'SPT Glance results',
+                     xmlSeries: [[
+                     file: "${env.JOB_NAME}_report.xml",
+                     nodeType: 'NODESET',
+                     url: '',
+                     xpath: '/testsuite/testcase[@name="test_speed_glance"]/properties/property']]
+                plot csvFileName: 'plot-8634d2fe-dc48-4713-99f9-b69a381483bb.csv',
+                     group: 'SPT',
+                     style: 'line',
+                     title: 'SPT HW2HW results',
+                     xmlSeries: [[
+                     file: "${env.JOB_NAME}_report.xml",
+                     nodeType: 'NODESET',
+                     url: '',
+                     xpath: '/testsuite/testcase[@classname="cvp_spt.tests.test_hw2hw"]/properties/property']]
+                plot csvFileName: 'plot-8634d2fe-dc48-4713-99f9-b69a381483bc.csv',
+                     group: 'SPT',
+                     style: 'line',
+                     title: 'SPT VM2VM results',
+                     xmlSeries: [[
+                     file: "${env.JOB_NAME}_report.xml",
+                     nodeType: 'NODESET',
+                     url: '',
+                     xpath: '/testsuite/testcase[@classname="cvp_spt.tests.test_vm2vm"]/properties/property']]
+            }
         }
     } catch (Throwable e) {
         // If there was an error or exception thrown, the build failed
         currentBuild.result = "FAILURE"
         throw e
+    } finally {
+        if (DEBUG_MODE == 'false') {
+            validate.runCleanup(saltMaster, TARGET_NODE, container_name)
+            salt.cmdRun(saltMaster, TARGET_NODE, "rm -rf ${remote_dir}")
+        }
     }
 }
diff --git a/cvp-stacklight.groovy b/cvp-stacklight.groovy
new file mode 100644
index 0000000..e7ce974
--- /dev/null
+++ b/cvp-stacklight.groovy
@@ -0,0 +1,33 @@
+/**
+ *
+ * Temporary pipeline for running cvp-stacklight job
+ *
+ * Expected parameters:
+ *   SALT_MASTER_URL                 URL of Salt master
+ *   SALT_MASTER_CREDENTIALS         Credentials to the Salt API
+ *
+ *   TESTS_SET                       Leave empty for full run or choose a file (test)
+ *   TESTS_REPO                      Repo to clone
+ *   TESTS_SETTINGS                  Additional environment varibales to apply
+ *   PROXY                           Proxy to use for cloning repo or for pip
+ *
+ */
+
+validate = new com.mirantis.mcp.Validate()
+
+def artifacts_dir = 'validation_artifacts/'
+
+node() {
+    stage('Initialization') {
+        validate.prepareVenv(TESTS_REPO, PROXY)
+    }
+
+    stage('Run Tests') {
+        sh "mkdir -p ${artifacts_dir}"
+        validate.runTests(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS, TESTS_SET, artifacts_dir, TESTS_SETTINGS)
+    }
+    stage ('Publish results') {
+        archiveArtifacts artifacts: "${artifacts_dir}/*"
+        junit "${artifacts_dir}/*.xml"
+    }
+}
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/release-mcp-version.groovy b/release-mcp-version.groovy
index 470f338..0d9ce5e 100644
--- a/release-mcp-version.groovy
+++ b/release-mcp-version.groovy
@@ -17,15 +17,17 @@
  *   GIT_CREDENTIALS
  *   GIT_REPO_LIST
  *   VCP_IMAGE_LIST - list of images
+ *   SYNC_VCP_IMAGE_TO_S3 - boolean
  *   RELEASE_VCP_IMAGES - boolean
  *   EMAIL_NOTIFY
  *   NOTIFY_RECIPIENTS
- *   NOTIFY_TEXT
- *
+  *
  */
 
 common = new com.mirantis.mk.Common()
-git = new com.mirantis.mk.Git()
+
+syncVcpImagesToS3 = env.SYNC_VCP_IMAGE_TO_S3.toBoolean() ?: false
+emailNotify = env.EMAIL_NOTIFY.toBoolean() ?: false
 
 def triggerAptlyPromoteJob(aptlyUrl, components, diffOnly, dumpPublish, packages, recreate, source, storages, target) {
     build job: "aptly-promote-all-testing-stable", parameters: [
@@ -66,6 +68,9 @@
 }
 
 def triggerGitTagJob(gitRepoList, gitCredentials, tag, sourceTag) {
+    // There is no `nightly` and `testing` build-IDs` in release process
+    // for git repos
+    if ( sourceTag in ['nightly', 'testing'] ) sourceTag = 'master'
     build job: "tag-git-repos-all", parameters: [
         [$class: 'TextParameterValue', name: 'GIT_REPO_LIST', value: gitRepoList],
         [$class: 'StringParameterValue', name: 'GIT_CREDENTIALS', value: gitCredentials],
@@ -83,6 +88,13 @@
     ]
 }
 
+def triggerSyncVCPJob(VcpImageList) {
+    build job: "upload-to-s3", parameters: [
+            [$class: 'TextParameterValue', name: 'FILENAMES',
+             value: VcpImageList + VcpImageList.collect({it + '.md5'})]
+    ]
+}
+
 timeout(time: 12, unit: 'HOURS') {
     node() {
         try {
@@ -117,9 +129,14 @@
                     triggerPromoteVCPJob(VCP_IMAGE_LIST, TARGET_REVISION, SOURCE_REVISION)
 
                 }
-                if (EMAIL_NOTIFY.toBoolean()) {
+                if (syncVcpImagesToS3) {
+                    common.infoMsg("Syncing VCP images from internal: http://apt.mcp.mirantis.net/images  to s3: images.mirantis.com")
+                    triggerSyncVCPJob('')
+                }
+                if (emailNotify) {
+                    notify_text = "MCP Promotion  ${env.SOURCE_REVISION} => ${env.TARGET_REVISION} has been done"
                     emailext(to: NOTIFY_RECIPIENTS,
-                        body: NOTIFY_TEXT,
+                        body: notify_text,
                         subject: "MCP Promotion has been done")
                 }
             }
diff --git a/tag-git-repos.groovy b/tag-git-repos.groovy
index 312ec9e..68fcdcd 100644
--- a/tag-git-repos.groovy
+++ b/tag-git-repos.groovy
@@ -16,9 +16,23 @@
 
 def gitRepoAddTag(repoURL, repoName, tag, credentials, ref = "HEAD"){
   common.infoMsg("Tagging: ${repoURL} ${ref} => ${tag}")
-  git.checkoutGitRepository(repoName, repoURL, "master", credentials)
+  checkout([
+    $class: 'GitSCM',
+    branches: [
+      [name: 'FETCH_HEAD'],
+    ],
+    userRemoteConfigs: [
+      [url: repoURL, refspec: ref, credentialsId: credentials],
+    ],
+    extensions: [
+      [$class: 'PruneStaleBranch'],
+      [$class: 'RelativeTargetDirectory', relativeTargetDir: repoName],
+      [$class: 'SubmoduleOption', disableSubmodules: true],
+      [$class: 'UserIdentity', name: 'MCP CI', email: 'ci+infra@mirantis.com'],
+    ],
+  ])
   dir(repoName) {
-    sh "git tag -f -a ${tag} ${ref} -m \"Release of mcp version ${tag}\""
+    sh "git tag -f -a ${tag} -m \"Release of mcp version ${tag}\""
     sshagent([credentials]) {
       sh "git push -f origin ${tag}:refs/tags/${tag}"
     }
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()],