Merge "Revert "temporary switch to hardware slaves""
diff --git a/cvp-runner.groovy b/cvp-runner.groovy
index ad04607..b362f01 100644
--- a/cvp-runner.groovy
+++ b/cvp-runner.groovy
@@ -71,6 +71,7 @@
                     'baseRepoPreConfig': false,
                     'dockerMaxCpus': 2,
                     'dockerExtraOpts' : [
+                        "--network=host",
                         "-v /root/qa_results/:/root/qa_results/",
                         "-v ${env.WORKSPACE}/${artifacts_dir}/:${container_workdir}/${artifacts_dir}/",
                     ],
diff --git a/docker-mirror-images.groovy b/docker-mirror-images.groovy
index e308281..dca2462 100644
--- a/docker-mirror-images.groovy
+++ b/docker-mirror-images.groovy
@@ -70,7 +70,7 @@
         currentBuild.description = "${user}: [${env.SOURCE_IMAGE_TAG} => ${env.IMAGE_TAG}]\n${env.IMAGE_LIST}"
         try {
             allowedGroups = ['release-engineering']
-            releaseTags = ['proposed', 'release', 'testing', '2018', '2019', '2020']
+            releaseTags = ['proposed', 'release',  '2018', '2019', '2020']
             tags = [env.SOURCE_IMAGE_TAG, env.IMAGE_TAG]
             tagInRelease = tags.any { tag -> releaseTags.any { tag.contains(it) } }
             if (tagInRelease) {
diff --git a/galera-cluster-verify-restore.groovy b/galera-cluster-verify-restore.groovy
index e1e8cfb..a5d4483 100644
--- a/galera-cluster-verify-restore.groovy
+++ b/galera-cluster-verify-restore.groovy
@@ -19,7 +19,7 @@
 
 askConfirmation = (env.getProperty('ASK_CONFIRMATION') ?: true).toBoolean()
 checkTimeSync = (env.getProperty('CHECK_TIME_SYNC') ?: true).toBoolean()
-if (common.validInputParam(VERIFICATION_RETRIES) && VERIFICATION_RETRIES.isInteger()) {
+if (common.validInputParam('VERIFICATION_RETRIES') && VERIFICATION_RETRIES.isInteger()) {
     verificationRetries = VERIFICATION_RETRIES.toInteger()
 } else {
     verificationRetries = 5
@@ -84,7 +84,7 @@
             common.retry(verificationRetries, 15) {
                 exitCode = openstack.verifyGaleraStatus(pepperEnv, false, false)
                 if (exitCode >= 1) {
-                    error("Verification attempt finished with an error. This may be caused by cluster not having enough time to come up or to sync. Next verification attempt in 5 seconds.")
+                    error("Verification attempt finished with an error. This may be caused by cluster not having enough time to come up or to sync. Next verification attempt in 15 seconds.")
                 } else {
                     common.infoMsg("Restoration procedure seems to be successful. See verification report to be sure.")
                     currentBuild.result = "SUCCESS"
diff --git a/generate-cookiecutter-products.groovy b/generate-cookiecutter-products.groovy
index 67c0431..c619ce2 100644
--- a/generate-cookiecutter-products.groovy
+++ b/generate-cookiecutter-products.groovy
@@ -72,10 +72,13 @@
         distribRevision = distribRevision.split('/')[-1]
     }
     // Check if we are going to test bleeding-edge release, which doesn't have binary release yet
-    if (!common.checkRemoteBinary([mcp_version: distribRevision]).linux_system_repo_url) {
-        common.warningMsg("Binary release: ${distribRevision} not exist. Fallback to 'proposed'! ")
+    // After 2018q4 releases, need to also check 'static' repo, for example ubuntu.
+    binTest = common.checkRemoteBinary(['mcp_version': distribRevision])
+    if (!binTest.linux_system_repo_url || !binTest.linux_system_repo_ubuntu_url) {
+        common.errorMsg("Binary release: ${distribRevision} not exist or not full. Fallback to 'proposed'! ")
         distribRevision = 'proposed'
     }
+
     // (azvyagintsev) WA for PROD-25732
     if (context.cookiecutter_template_url.contains('gerrit.mcp.mirantis.com/mk/cookiecutter-templates')) {
         common.warningMsg('Apply WA for PROD-25732')
@@ -171,11 +174,6 @@
 
             stage("Test") {
                 if (runTestModel) {
-                    // Check if we are going to test bleeding-edge release, which doesn't have binary release yet
-                    if (!common.checkRemoteBinary([mcp_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 distribRevision: ${distribRevision}")
@@ -233,9 +231,15 @@
                 smc['DNS_SERVERS'] = context['dns_server01']
                 smc['MCP_VERSION'] = "${context['mcp_version']}"
                 if (context['local_repositories'] == 'True') {
-                    def localRepoIP = context['local_repo_url']
+                    def localRepoIP = ''
+                    if (context['mcp_version'] in ['2018.4.0', '2018.8.0', '2018.8.0-milestone1', '2018.11.0']) {
+                        localRepoIP = context['local_repo_url']
+                        smc['MCP_SALT_REPO_URL'] = "http://${localRepoIP}/ubuntu-xenial"
+                    } else {
+                        localRepoIP = context['aptly_server_deploy_address']
+                        smc['MCP_SALT_REPO_URL'] = "http://${localRepoIP}"
+                    }
                     smc['MCP_SALT_REPO_KEY'] = "http://${localRepoIP}/public.gpg"
-                    smc['MCP_SALT_REPO_URL'] = "http://${localRepoIP}/ubuntu-xenial"
                     smc['PIPELINES_FROM_ISO'] = 'false'
                     smc['PIPELINE_REPO_URL'] = "http://${localRepoIP}:8088"
                     smc['LOCAL_REPOS'] = 'true'
diff --git a/release-mcp-version.groovy b/release-mcp-version.groovy
index f726087..c7f41f8 100644
--- a/release-mcp-version.groovy
+++ b/release-mcp-version.groovy
@@ -94,7 +94,7 @@
 def triggerPkgPromoteJob(PkgRepoList, PromoteFrom, PromoteTo) {
     //For repositories with per-package promote such as extra, ceph
     //we use different approaches for different steps of promoting
-    def repos = PkgRepoList.trim().tokenize()
+    def repos = PkgRepoList.trim().tokenize("\n")
     def RepoName, RepoDist, PackagesToPromote
     for (repo in repos) {
         if (repo.startsWith('#')) {
@@ -111,17 +111,17 @@
         //During promote from testing to proposed we use per-package promote
         if (SOURCE_REVISION == 'testing') {
             build job: "pkg-promote", parameters: [
-               [$class: 'ChoiceParameterValue', name: 'repoName', value: RepoName],
-               [$class: 'ChoiceParameterValue', name: 'repoDist', value: RepoDist],
-               [$class: 'ChoiceParameterValue', name: 'promoteFrom', value: PromoteFrom],
-               [$class: 'ChoiceParameterValue', name: 'promoteTo', value: PromoteTo],
+               [$class: 'StringParameterValue', name: 'repoName', value: RepoName],
+               [$class: 'StringParameterValue', name: 'repoDist', value: RepoDist],
+               [$class: 'StringParameterValue', name: 'promoteFrom', value: PromoteFrom],
+               [$class: 'StringParameterValue', name: 'promoteTo', value: PromoteTo],
                [$class: 'TextParameterValue', name: 'packagesToPromote', value: PackagesToPromote],
             ]
         //In promote from proposed to release we move links to snapshots
         } else if (SOURCE_REVISION == 'proposed') {
             build job: "mirror-snapshot-pkg-name-${RepoName}-${RepoDist}", parameters: [
-               [$class: 'ChoiceParameterValue', name: 'Snapshot_Name', value: PromoteFrom],
-               [$class: 'ChoiceParameterValue', name: 'Snapshot_Id', value: PromoteTo],
+               [$class: 'StringParameterValue', name: 'MCP_VERSION', value: PromoteTo],
+               [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: PromoteFrom],
             ]
         }
     }
diff --git a/test-salt-model-wrapper.groovy b/test-salt-model-wrapper.groovy
index b499db1..9913c5c 100644
--- a/test-salt-model-wrapper.groovy
+++ b/test-salt-model-wrapper.groovy
@@ -8,18 +8,19 @@
  */
 
 import groovy.json.JsonOutput
+
 gerrit = new com.mirantis.mk.Gerrit()
 
-cookiecutterTemplatesRepo='mk/cookiecutter-templates'
-reclassSystemRepo='salt-models/reclass-system'
+cookiecutterTemplatesRepo = 'mk/cookiecutter-templates'
+reclassSystemRepo = 'salt-models/reclass-system'
 slaveNode = env.getProperty('SLAVE_NODE') ?: 'virtual'
 
 voteMatrix = [
-  'test-mk-cookiecutter-templates': true,
-  'test-drivetrain': true,
-  'oscore-test-cookiecutter-models': false,
-  'test-salt-model-infra': true,
-  'test-salt-model-mcp-virtual-lab': false,
+    'test-mk-cookiecutter-templates' : true,
+    'test-drivetrain'                : true,
+    'oscore-test-cookiecutter-models': false,
+    'test-salt-model-infra'          : true,
+    'test-salt-model-mcp-virtual-lab': false,
 ]
 
 baseGerritConfig = [:]
@@ -49,7 +50,7 @@
 // get job parameters for YAML-based job parametrization
 def yamlJobParameters(LinkedHashMap jobParams) {
     return [
-        [$class: 'TextParameterValue', name: 'EXTRA_VARIABLES_YAML', value: JsonOutput.toJson(jobParams) ]
+        [$class: 'TextParameterValue', name: 'EXTRA_VARIABLES_YAML', value: JsonOutput.toJson(jobParams)]
     ]
 }
 
@@ -59,7 +60,7 @@
     def propagateStatus = voteMatrix.get(jobName, true)
     return {
         def jobBuild = build job: jobName, propagate: false, parameters: jobParams
-        jobResultComments[threadName] = [ 'url': jobBuild.absoluteUrl, 'status': jobBuild.result, 'job': jobName ]
+        jobResultComments[threadName] = ['url': jobBuild.absoluteUrl, 'status': jobBuild.result, 'job': jobName]
         setGerritReviewComment()
         if (propagateStatus && jobBuild.result == 'FAILURE') {
             throw new Exception("Build ${threadName} is failed!")
@@ -114,12 +115,14 @@
         String distribRevision = 'nightly'
         //checking if the branch is from release
         if (gerritBranch.startsWith('release')) {
-            def distribRevisionRelease = gerritBranch.tokenize('/')[-1]
-            if (!common.checkRemoteBinary([apt_mk_version: distribRevisionRelease]).linux_system_repo_url) {
-              common.infoMsg("Binary release ${distribRevisionRelease} does not exist on http://mirror.mirantis.com. Falling back to 'proposed'.")
-              distribRevision = 'proposed'
+            distribRevision = gerritBranch.tokenize('/')[-1]
+            // Check if we are going to test bleeding-edge release, which doesn't have binary release yet
+            // After 2018q4 releases, need to also check 'static' repo, for example ubuntu.
+            binTest = common.checkRemoteBinary(['mcp_version': distribRevision])
+            if (!binTest.linux_system_repo_url || !binTest.linux_system_repo_ubuntu_url) {
+                common.errorMsg("Binary release: ${distribRevision} not exist or not full. Fallback to 'proposed'! ")
+                distribRevision = 'proposed'
             }
-            distribRevision = distribRevisionRelease
         }
         ArrayList testModels = job_env.get('TEST_MODELS', 'mcp-virtual-lab,infra').split(',')
 
@@ -131,13 +134,13 @@
                 currentBuild.result = 'SUCCESS'
                 return
             }
-            buildTestParams << job_env.findAll { k,v -> k ==~ /GERRIT_.+/ }
+            buildTestParams << job_env.findAll { k, v -> k ==~ /GERRIT_.+/ }
             baseGerritConfig = [
-                'gerritName': gerritName,
-                'gerritHost': gerritHost,
-                'gerritPort': gerritPort,
-                'gerritChangeNumber': gerritChangeNumber,
-                'credentialsId': gerritCredentials,
+                'gerritName'          : gerritName,
+                'gerritHost'          : gerritHost,
+                'gerritPort'          : gerritPort,
+                'gerritChangeNumber'  : gerritChangeNumber,
+                'credentialsId'       : gerritCredentials,
                 'gerritPatchSetNumber': gerritPatchSetNumber,
             ]
             LinkedHashMap gerritDependingProjects = gerrit.getDependentPatches(baseGerritConfig)
@@ -148,7 +151,7 @@
                 "Branch for ${gerritProject} => ${gerritBranch}"
             ]
             descriptionMsgs.add("Distrib revision => ${distribRevision}")
-            for(String project in gerritDependingProjects.keySet()) {
+            for (String project in gerritDependingProjects.keySet()) {
                 descriptionMsgs.add("---")
                 descriptionMsgs.add("Depending patch to ${project} found:")
                 descriptionMsgs.add("Ref for ${project} => ${gerritDependingProjects[project]['ref']}")
@@ -182,8 +185,8 @@
                     def jobParams = [
                         [$class: 'StringParameterValue', name: 'DEFAULT_GIT_URL', value: clusterGitUrl],
                         [$class: 'StringParameterValue', name: 'DEFAULT_GIT_REF', value: "HEAD"],
-                        [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: defaultSystemURL ],
-                        [$class: 'StringParameterValue', name: 'SYSTEM_GIT_REF', value: gerritRef ],
+                        [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: defaultSystemURL],
+                        [$class: 'StringParameterValue', name: 'SYSTEM_GIT_REF', value: gerritRef],
                     ]
                     branches[branchJobName] = runTests(branchJobName, jobParams)
                 }
@@ -215,7 +218,7 @@
 
             branches.keySet().each { key ->
                 if (branches[key] instanceof Closure) {
-                    jobResultComments[key] = [ 'url': job_env.get('BUILD_URL'), 'status': 'WAITING' ]
+                    jobResultComments[key] = ['url': job_env.get('BUILD_URL'), 'status': 'WAITING']
                 }
             }
             setGerritReviewComment()