Merge "Ironic node provision pipeline"
diff --git a/.gitignore b/.gitignore
index f8b92c3..3060674 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 .gradle
 build
+.idea
\ No newline at end of file
diff --git a/build-debian-packages-prometheus-relay.groovy b/build-debian-packages-prometheus-relay.groovy
new file mode 100644
index 0000000..9f79e35
--- /dev/null
+++ b/build-debian-packages-prometheus-relay.groovy
@@ -0,0 +1,94 @@
+def common = new com.mirantis.mk.Common()
+def git = new com.mirantis.mk.Git()
+def artifactory = new com.mirantis.mk.Artifactory()
+def aptly = new com.mirantis.mk.Aptly()
+
+def timestamp = common.getDatetime()
+def version = "0.1~${timestamp}"
+
+node('docker') {
+    try{
+
+        stage("cleanup") {
+            sh("rm -rf * || true")
+        }
+
+        def workingDir = "src/gerrit.mcp.mirantis.net/debian"
+        stage("checkout") {
+            git.checkoutGitRepository(
+                "${workingDir}/prometheus-relay",
+                "${SOURCE_URL}",
+                SOURCE_BRANCH,
+                SOURCE_CREDENTIALS,
+                true,
+                30,
+                1
+            )
+        }
+
+        try {
+
+            def jenkinsUID = sh (
+                script: 'id -u',
+                returnStdout: true
+            ).trim()
+            def imgName = "${OS}-${DIST}-${ARCH}"
+            def img
+
+            stage("build package") {
+                img.inside{
+                    sh("""wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz &&
+                        tar xf go1.8.1.linux-amd64.tar.gz &&
+                        export GOROOT=\$PWD/go &&
+                        export PATH=\$PATH:\$GOROOT/bin &&
+                        export GOPATH=\$PWD &&
+                        cd src/gerrit.mcp.mirantis.net/debian/prometheus-relay &&
+                        make""")
+                }
+                archiveArtifacts artifacts: "${workingDir}/prometheus-relay/build/*.deb"
+            }
+            if (UPLOAD_APTLY.toBoolean()) {
+                lock("aptly-api") {
+                    stage("upload") {
+                        def buildSteps = [:]
+                        def debFiles = sh script: "ls ${workingDir}/prometheus-relay/build/*.deb", returnStdout: true
+                        def debFilesArray = debFiles.trim().tokenize()
+                        def workspace = common.getWorkspace()
+                        for (int i = 0; i < debFilesArray.size(); i++) {
+
+                            def debFile = debFilesArray[i];
+                            buildSteps[debFiles[i]] = aptly.uploadPackageStep(
+                                "${workspace}/"+debFile,
+                                APTLY_URL,
+                                APTLY_REPO,
+                                true
+                            )
+                        }
+                        parallel buildSteps
+                    }
+                    stage("publish") {
+                        aptly.snapshotRepo(APTLY_URL, APTLY_REPO, timestamp)
+                        aptly.publish(APTLY_URL)
+                    }
+
+                }
+            }
+
+        } catch (Exception e) {
+            currentBuild.result = 'FAILURE'
+            throw e
+        }
+
+    } catch (Throwable e) {
+       // If there was an exception thrown, the build failed
+       currentBuild.result = "FAILURE"
+       currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
+       throw e
+    } finally {
+       common.sendNotification(currentBuild.result,"",["slack"])
+
+       if (currentBuild.result != 'FAILURE') {
+          sh("rm -rf *")
+       }
+    }
+}
diff --git a/generate-cookiecutter-products.groovy b/generate-cookiecutter-products.groovy
index c392c3e..288a4a5 100644
--- a/generate-cookiecutter-products.groovy
+++ b/generate-cookiecutter-products.groovy
@@ -157,8 +157,6 @@
             smc['DEPLOY_NETWORK_GW'] = templateContext['default_context']['deploy_network_gateway']
             smc['DEPLOY_NETWORK_NETMASK'] = templateContext['default_context']['deploy_network_netmask']
             smc['DNS_SERVERS'] = templateContext['default_context']['dns_server01']
-            smc['CICD_CONTROL_ADDRESS'] = templateContext['default_context']['cicd_control_vip_address']
-            smc['INFRA_CONFIG_ADDRESS'] = templateContext['default_context']['salt_master_address']
 
             for (i in common.entries(smc)) {
                 sh "sed -i \"s,export ${i[0]}=.*,export ${i[0]}=${i[1]},\" user_data.sh"
diff --git a/test-run-rally.groovy b/test-run-rally.groovy
new file mode 100644
index 0000000..4cf3bd3
--- /dev/null
+++ b/test-run-rally.groovy
@@ -0,0 +1,60 @@
+/**
+ *
+ * Service test pipeline
+ *
+ * Expected parameters:
+ *   SALT_MASTER_URL                 URL of Salt master
+ *   SALT_MASTER_CREDENTIALS         Credentials to the Salt API
+ * Test settings:
+ *   IMAGE_LINK                      Link to docker image with Rally
+ *   RALLY_SCENARIO                  Rally test scenario
+ *   TEST_TARGET                     Salt target for Rally node
+ *   CLEANUP_REPORTS_AND_CONTAINER   Cleanup reports from rally,tempest container, remove all containers started the IMAGE_LINK
+ *   DO_CLEANUP_RESOURCES            If "true": runs clean-up script for removing Rally and Tempest resources
+ */
+
+
+common = new com.mirantis.mk.Common()
+salt = new com.mirantis.mk.Salt()
+test = new com.mirantis.mk.Test()
+
+// Define global variables
+def saltMaster
+
+node("python") {
+    try {
+
+        //
+        // Prepare connection
+        //
+        stage ('Connect to salt master') {
+            // Connect to Salt master
+            saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+        }
+
+        //
+        // Test
+        //
+
+        stage('Run OpenStack Rally scenario') {
+            test.runRallyScenarios(saltMaster, IMAGE_LINK, TEST_TARGET, RALLY_SCENARIO, "/home/rally/rally_reports/",
+                    DO_CLEANUP_RESOURCES)
+        }
+        stage('Copy test reports') {
+            test.copyTempestResults(saltMaster, TEST_TARGET)
+        }
+        stage('Archiving test artifacts') {
+            test.archiveRallyArtifacts(saltMaster, TEST_TARGET)
+        }
+    } catch (Throwable e) {
+        currentBuild.result = 'FAILURE'
+        throw e
+    } finally {
+        if (CLEANUP_REPORTS_AND_CONTAINER.toBoolean()) {
+            stage('Cleanup reports and container') {
+                test.removeReports(saltMaster, TEST_TARGET, "rally_reports", 'rally_reports.tar')
+                test.removeDockerContainer(saltMaster, TEST_TARGET, IMAGE_LINK)
+            }
+        }
+    }
+}
diff --git a/test-run-tempest.groovy b/test-run-tempest.groovy
new file mode 100644
index 0000000..4785992
--- /dev/null
+++ b/test-run-tempest.groovy
@@ -0,0 +1,60 @@
+/**
+ *
+ * Service test pipeline
+ *
+ * Expected parameters:
+ *   SALT_MASTER_URL                 URL of Salt master
+ *   SALT_MASTER_CREDENTIALS         Credentials to the Salt API
+ * Test settings:
+ *   IMAGE_LINK                      Link to docker image with Rally and Tempest
+ *   TEST_TEMPEST_PATTERN            If not false, run tests matched to pattern only
+ *   TEST_TARGET                     Salt target for tempest node
+ *   CLEANUP_REPORTS_AND_CONTAINER   Cleanup reports from rally,tempest container, remove all containers started the IMAGE_LINK
+ *   DO_CLEANUP_RESOURCES            If "true": runs clean-up script for removing Rally and Tempest resources
+ */
+
+
+common = new com.mirantis.mk.Common()
+salt = new com.mirantis.mk.Salt()
+test = new com.mirantis.mk.Test()
+
+// Define global variables
+def saltMaster
+
+node("python") {
+    try {
+
+        //
+        // Prepare connection
+        //
+        stage ('Connect to salt master') {
+            // Connect to Salt master
+            saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+        }
+
+        //
+        // Test
+        //
+
+        stage('Run OpenStack Tempest tests') {
+            test.runTempestTests(saltMaster, IMAGE_LINK, TEST_TARGET, TEST_TEMPEST_PATTERN, "/home/rally/rally_reports/",
+                    DO_CLEANUP_RESOURCES)
+        }
+        stage('Copy test reports') {
+            test.copyTempestResults(saltMaster, TEST_TARGET)
+        }
+        stage('Archiving test artifacts') {
+            test.archiveRallyArtifacts(saltMaster, TEST_TARGET)
+        }
+    } catch (Throwable e) {
+        currentBuild.result = 'FAILURE'
+        throw e
+    } finally {
+        if (CLEANUP_REPORTS_AND_CONTAINER.toBoolean()) {
+            stage('Cleanup reports and container') {
+                test.removeReports(saltMaster, TEST_TARGET, "rally_reports", 'rally_reports.tar')
+                test.removeDockerContainer(saltMaster, TEST_TARGET, IMAGE_LINK)
+            }
+        }
+    }
+}