Add functions for saving artifacts in GCS
Also added function for generating random hash string
Change-Id: I447f90398bf7f7e4265ef1a9b3dcc266e25b7125
Related-Prod: PROD-31581
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index b5760da..9a350c2 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -1006,3 +1006,16 @@
Date parseDate(String date, String format) {
return Date.parse(format, date)
}
+
+/**
+ * Generate Random Hash string
+ * @param n Hash length
+ * @param pool Pool to use for hash generation
+*/
+def generateRandomHashString(int n, ArrayList pool = []) {
+ if (!pool) {
+ pool = ['a'..'z','A'..'Z',0..9,'_','+','='].flatten()
+ }
+ Random rand = new Random(System.currentTimeMillis())
+ return (1..n).collect { pool[rand.nextInt(pool.size())] }.join()
+}