Merge "Adjust check for ceph global id reclaim CVE"
diff --git a/src/com/mirantis/mk/KaasUtils.groovy b/src/com/mirantis/mk/KaasUtils.groovy
index fe42b98..a183cb2 100644
--- a/src/com/mirantis/mk/KaasUtils.groovy
+++ b/src/com/mirantis/mk/KaasUtils.groovy
@@ -107,6 +107,7 @@
     def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
     def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false
     def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false
+    def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
 
     def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
     if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
@@ -144,7 +145,17 @@
         attachBYO = true
         upgradeBYO = true
     }
-
+    if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) {
+        enableVsphereDemo = true
+        enableOSDemo = true
+        awsOnDemandDemo = true
+        azureOnDemandDemo = true
+        equinixOnDemandDemo = true
+        equinixMetalV2OnDemandDemo = true
+        runUie2e = true
+        // Edit after fix PRODX-3961
+        enableBMDemo = false
+    }
     def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
     if (commitMsg ==~ /(?s).*\[run-byo-matrix\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*run-byo-matrix\.*/ || byoDeployMatches.size() > 0) {
         runBYOMatrix = true
@@ -363,7 +374,6 @@
     }
 
     // parse equinixmetalv2-metro trigger
-    def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
     def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
     if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
         equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
@@ -1083,3 +1093,36 @@
     }
     return testScheme
 }
+
+
+/**
+* getEquinixMetrosWithCapacity returns list of Equinix metros using specified
+* instance type (nodeType) and desired count of instances (nodeCount) in a metro.
+* Function downloads metal CLI from the
+* https://github.com/equinix/metal-cli/releases/download/v0.9.0/metal-linux-amd64
+* Empty list is returned in case of errors.
+*
+* @param:        nodeCount (int)      Desired count of instances
+* @param:        nodeType  (string)   Instance type
+* @return                  ([]string) List of selected metros
+*
+**/
+def getEquinixMetrosWithCapacity(nodeCount = 10, nodeType = 'c3.small.x86', version = '0.9.0') {
+    def common = new com.mirantis.mk.Common()
+    def metalUrl = "https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux"
+    def metros = []
+    def out = ''
+    try {
+        sh "curl -o metal -# ${metalUrl} && chmod +x metal"
+        withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
+            sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
+            out = sh(script: "./metal --config metal.yaml capacity get -m -P ${nodeType}|awk '/${nodeType}/ {print \$2}'|paste -s -d,|xargs ./metal --config metal.yaml capacity check -P ${nodeType} -q ${nodeCount} -m|grep true|awk '{print \$2}'|paste -s -d,", returnStdout: true).trim()
+            sh 'rm metal.yaml'
+        }
+        metros = out.tokenize(',')
+    } catch (Exception e) {
+        common.errorMsg "Exception: '${e}'"
+        return []
+    }
+    return metros
+}