Add executeMachineSshCommand function

The patch adds executeMachineSshCommand function that allows to
execute ssh commands with retries and additional options.

Change-Id: I76fddf2002dfb509c1266696487767655659049b
Related-Prod: PRODX-2066
diff --git a/src/com/mirantis/mk/Ssh.groovy b/src/com/mirantis/mk/Ssh.groovy
index 703f81e..46d7c64 100644
--- a/src/com/mirantis/mk/Ssh.groovy
+++ b/src/com/mirantis/mk/Ssh.groovy
@@ -71,6 +71,33 @@
 }
 
 /**
+ * Execute command with ssh-agent with retries and additional options
+ *
+ * @param address address of remote server
+ * @param cmd command to execute
+ * @param user the name of user to execute ssh command with
+ * @param retries number of command retries in case of failure
+ * @param wait delay between retries
+ * @param options additional ssh options
+
+ */
+def executeMachineSshCommand(address, cmd, user = 'ubuntu', retries=5, wait=10, options=null){
+    def common = new com.mirantis.mk.Common()
+    if (!options){
+        options = ['StrictHostKeyChecking': 'no', 'UserKnownHostsFile': '/dev/null']
+    }
+    String optionsString = ''
+    options.each { k,v ->
+        optionsString += "-o ${k}=${v} "
+    }
+
+    common.retry(retries, wait) {
+        return agentSh("ssh ${optionsString} ${user}@${address} '${cmd}'")
+    }
+}
+
+
+/**
  * Setup ssh agent and add private key
  *
  * @param credentialsId Jenkins credentials name to lookup private key