Added functions to validate the cloud.

This functions will provide ability to execute Rally and Tempest
test for cloud validation.

Change-Id: I44a77dcaf3bd2a2b324140a024a01a2079a9d3f7
diff --git a/src/com/mirantis/mcp/Validate.groovy b/src/com/mirantis/mcp/Validate.groovy
new file mode 100644
index 0000000..fa158b9
--- /dev/null
+++ b/src/com/mirantis/mcp/Validate.groovy
@@ -0,0 +1,91 @@
+package com.mirantis.mcp
+
+/**
+ *
+ * Tests providing functions
+ *
+ */
+
+/**
+ * Configure docker image with tests
+ *
+ * @param dockerImageLink   Docker image link with rally and tempest
+ * @param target            Host to run tests
+ * @param output_dir        Directory for results
+ */
+def runContainerConfiguration(master, dockerImageLink, target, output_dir){
+    def salt = new com.mirantis.mk.Salt()
+    def common = new com.mirantis.mk.Common()
+    def output_file = 'docker.log'
+    def _pillar = salt.getPillar(master, "ctl01*", 'keystone:server')
+    def keystone = _pillar['return'][0].values()[0]
+    salt.cmdRun(master, target, "docker run -tid --net=host --name=qa_tools " +
+            "-e tempest_version=15.0.0 -e OS_USERNAME=${keystone.admin_name} " +
+            "-e OS_PASSWORD=${keystone.admin_password} -e OS_TENANT_NAME=${keystone.admin_tenant} " +
+            "-e OS_AUTH_URL=http://${keystone.bind.private_address}:${keystone.bind.private_port}/v2.0 " +
+            "-e OS_REGION_NAME=${keystone.region} -e OS_ENDPOINT_TYPE=admin ${dockerImageLink} /bin/bash")
+    salt.cmdRun(master, target, "docker exec qa_tools bash -c /opt/devops-qa-tools/deployment/configure.sh > ${output_file}")
+    def file_content = salt.getFileContent(master, target, output_file)
+    writeFile file: "${output_dir}${output_file}", text: file_content
+}
+
+/**
+ * Execute tempest tests
+ *
+ * @param target            Host to run tests
+ * @param pattern           If not false, will run only tests matched the pattern
+ * @param output_dir        Directory for results
+ */
+def runTempestTests(master, target, output_dir, pattern = "false") {
+    def salt = new com.mirantis.mk.Salt()
+    def output_file = 'docker-tempest.log'
+    if (pattern == "false") {
+        salt.cmdRun(master, target, "docker exec qa_tools rally verify start --pattern set=full " +
+                "--detailed > ${output_file}")
+    }
+    else {
+        salt.cmdRun(master, target, "docker exec qa_tools rally verify start --pattern ${pattern} " +
+                "--detailed > ${output_file}")
+    }
+    def file_content = salt.getFileContent(master, target, output_file)
+    writeFile file: "${output_dir}${output_file}", text: file_content
+}
+
+/**
+ * Execute rally tests
+ *
+ * @param target            Host to run tests
+ * @param pattern           If not false, will run only tests matched the pattern
+ * @param output_dir        Directory for results
+ */
+def runRallyTests(master, target, output_dir, pattern = "false") {
+    def salt = new com.mirantis.mk.Salt()
+    def output_file = 'docker-rally.log'
+    salt.cmdRun(master, target, "docker exec qa_tools rally task start combined_scenario.yaml --task-args-file " +
+            "/opt/devops-qa-tools/rally-scenarios/task_arguments.yaml | tee ${output_file}")
+    def file_content = salt.getFileContent(master, target, output_file)
+    writeFile file: "${output_dir}${output_file}", text: file_content
+}
+
+/**
+ * Cleanup
+ *
+ * @param target            Host to run commands
+ * @param output_dir        Directory for results
+ */
+def runCleanup(master, target, output_dir) {
+    def salt = new com.mirantis.mk.Salt()
+    salt.cmdRun(master, target, "docker rm -f qa_tools")
+    sh "rm -r ${output_dir}"
+}
+
+/** Install docker if needed
+ *
+ * @param target              Target node to install docker pkg
+ */
+def installDocker(master, target) {
+    def salt = new com.mirantis.mk.Salt()
+    if ( ! salt.runSaltProcessStep(master, target, 'pkg.version', ["docker-engine"]) ) {
+        salt.runSaltProcessStep(master, target, 'pkg.install', ["docker.io"])
+    }
+}