Handle different types of Salt cmd returns
Fixes: PROD-21843
Change-Id: I97c6804f43cb822e8b8f617a2582ef4d5e01acba
diff --git a/src/com/mirantis/mk/Salt.groovy b/src/com/mirantis/mk/Salt.groovy
index 6530062..f7724a6 100644
--- a/src/com/mirantis/mk/Salt.groovy
+++ b/src/com/mirantis/mk/Salt.groovy
@@ -248,12 +248,20 @@
def node = out["return"][i];
for(int j=0;j<node.size();j++){
def nodeKey = node.keySet()[j]
- if (!node[nodeKey].contains("Salt command execution success")) {
- throw new Exception("Execution of cmd ${originalCmd} failed. Server returns: ${node[nodeKey]}")
+ if (node[nodeKey] instanceof String) {
+ if (!node[nodeKey].contains("Salt command execution success")) {
+ throw new Exception("Execution of cmd ${originalCmd} failed. Server returns: ${node[nodeKey]}")
+ }
+ } else if (node[nodeKey] instanceof Boolean) {
+ if (!node[nodeKey]) {
+ throw new Exception("Execution of cmd ${originalCmd} failed. Server returns: ${node[nodeKey]}")
+ }
+ } else {
+ throw new Exception("Execution of cmd ${originalCmd} failed. Server returns unexpected data type: ${node[nodeKey]}")
}
}
}
- }else{
+ } else {
throw new Exception("Salt Api response doesn't have return param!")
}
}