add countHashMapEquals to common
This function will be used for checking aws instances states.
Change-Id: I7f573ac3e46c49a77747d381659969c63ff7c7b0
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index a348e75..0597cfa 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -437,4 +437,17 @@
*/
def validInputParam(paramName){
return env.getEnvironment().containsKey(paramName) && env[paramName] != null && env[paramName] != ""
-}
\ No newline at end of file
+}
+
+/**
+ * Take list of hashmaps and count number of hashmaps with parameter equals eq
+ * @param lm list of hashmaps
+ * @param param define parameter of hashmap to read and compare
+ * @param eq desired value of hashmap parameter
+ * @return count of hashmaps meeting defined condition
+ */
+
+@NonCPS
+def countHashMapEquals(lm, param, eq) {
+ return lm.stream().filter{i -> !i[param].equals(eq)}.collect(java.util.stream.Collectors.counting())
+}