Merge "Add ability to wait jobs triggered by the same trigger"
diff --git a/src/com/mirantis/mcp/Common.groovy b/src/com/mirantis/mcp/Common.groovy
index b501b04..7a29432 100644
--- a/src/com/mirantis/mcp/Common.groovy
+++ b/src/com/mirantis/mcp/Common.groovy
@@ -1,5 +1,8 @@
 package com.mirantis.mcp
 
+import java.util.zip.GZIPInputStream
+import java.util.zip.GZIPOutputStream
+
 @Grab(group='org.yaml', module='snakeyaml', version='1.17')
 import org.yaml.snakeyaml.Yaml
 
@@ -200,3 +203,19 @@
   } //else
 
 }
+
+def zipBase64(String s){
+    def targetStream = new ByteArrayOutputStream()
+    def zipStream = new GZIPOutputStream(targetStream)
+    zipStream.write(s.getBytes('UTF-8'))
+    zipStream.close()
+    def zippedBytes = targetStream.toByteArray()
+    targetStream.close()
+    return zippedBytes.encodeBase64()
+}
+
+def unzipBase64(String compressed){
+    def inflaterStream = new GZIPInputStream(new ByteArrayInputStream(compressed.decodeBase64()))
+    def uncompressedStr = inflaterStream.getText('UTF-8')
+    return uncompressedStr
+}
diff --git a/src/com/mirantis/mk/Orchestrate.groovy b/src/com/mirantis/mk/Orchestrate.groovy
index dea0366..d18ebb5 100644
--- a/src/com/mirantis/mk/Orchestrate.groovy
+++ b/src/com/mirantis/mk/Orchestrate.groovy
@@ -284,7 +284,10 @@
 
     // Install sphinx server
     salt.enforceStateWithTest(master, "I@sphinx:server ${extra_tgt}", 'sphinx')
-    salt.enforceStateWithTest(master, "I@nginx:server ${extra_tgt}", 'salt.minion')
+    // Running minion states in a batch to avoid races related to certificates which are placed on glusterfs
+    // Details on races: https://mirantis.jira.com/browse/PROD-25796
+    // TODO: Run in parallel when glusterfs for certificates is dropped in cookiecutter
+    salt.enforceStateWithTest(master, "I@nginx:server ${extra_tgt}", 'salt.minion', '', true, true, 1)
     salt.enforceStateWithTest(master, "I@nginx:server ${extra_tgt}", 'nginx')
 
     // setup keystone service
diff --git a/src/com/mirantis/mk/Python.groovy b/src/com/mirantis/mk/Python.groovy
index f135cc0..6183f51 100644
--- a/src/com/mirantis/mk/Python.groovy
+++ b/src/com/mirantis/mk/Python.groovy
@@ -247,7 +247,8 @@
     requirements = [
         'cookiecutter',
         'jinja2==2.8.1',
-        'PyYAML==3.12'
+        'PyYAML==3.12',
+        'python-gnupg==0.4.3'
     ]
     setupVirtualenv(path, 'python2', requirements)
 }
diff --git a/src/com/mirantis/mk/SaltModelTesting.groovy b/src/com/mirantis/mk/SaltModelTesting.groovy
index 156034b..16e469c 100644
--- a/src/com/mirantis/mk/SaltModelTesting.groovy
+++ b/src/com/mirantis/mk/SaltModelTesting.groovy
@@ -83,8 +83,8 @@
   mcp_extra:
     source: "${extraRepoSource}"
   mcp_saltformulas:
-    source: "deb http://apt.mcp.mirantis.net/xenial ${distribRevision} salt salt-latest"
-    repo_key: "http://apt.mcp.mirantis.net/public.gpg"
+    source:   "deb [arch=amd64]  http://mirror.mirantis.com/${distribRevision}/salt-formulas/xenial xenial main"
+    repo_key: "http://mirror.mirantis.com/${distribRevision}/salt-formulas/xenial/archive-salt-formulas.key"
   ubuntu:
     source: "deb [arch=amd64] http://mirror.mirantis.com/${distribRevision}/ubuntu xenial main restricted universe"
   ubuntu-upd: