Fixed syntax of command status function
Change-Id: I42b5227a6881db18c86018b76e13cf1f269d9432
diff --git a/src/com/mirantis/mk/Salt.groovy b/src/com/mirantis/mk/Salt.groovy
index ab9bc72..c040fb5 100644
--- a/src/com/mirantis/mk/Salt.groovy
+++ b/src/com/mirantis/mk/Salt.groovy
@@ -206,7 +206,7 @@
* @param output print salt command (default true)
* @return output of salt command
*/
-def minion_present(master, target, minion_name, waitUntilPresent = true, batch=null, output = true) {
+def minionPresent(master, target, minion_name, waitUntilPresent = true, batch=null, output = true) {
return command_status(master, target, 'salt-key | grep ' + minion_name, minion_name, waitUntilPresent, batch, output)
}
@@ -221,14 +221,16 @@
* @param output print salt command (default true)
* @return output of salt command
*/
-def command_status(master, target, cmd, correct_state='running', waitUntilOk = true, batch=null, output = true, maxRetries = 200) {
+def commandStatus(master, target, cmd, correct_state='running', waitUntilOk = true, batch=null, output = true, maxRetries = 200) {
def common = new com.mirantis.mk.Common()
common.infoMsg("Checking if status of verification command ${cmd} on ${target} is in correct state")
if (waitUntilOk){
def count = 0
while(count < maxRetries) {
def out = runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'cmd.shell', batch, [cmd])
- if (out.toLowerCase().contains(correct_state.toLowerCase()) && output == true) {
+ def resultMap = out["return"][0]
+ def result = resultMap.get(resultMap.keySet()[0])
+ if (result.toLowerCase().contains(correct_state.toLowerCase())) {
if (output) {
printSaltCommandResult(out)
}
@@ -239,7 +241,9 @@
}
} else {
def out = runSaltCommand(master, 'local', ['expression': target, 'type': 'compound'], 'cmd.shell', batch, [cmd])
- if (out.toLowerCase().contains(correct_state.toLowerCase()) && output == true) {
+ def resultMap = out["return"][0]
+ def result = resultMap.get(resultMap.keySet()[0])
+ if (result.toLowerCase().contains(correct_state.toLowerCase())) {
if (output) {
printSaltCommandResult(out)
}