change salt - getNodeProvider
Change-Id: I7e7cf6c855e1e477843f536434769147c6d07692
diff --git a/src/com/mirantis/mk/Salt.groovy b/src/com/mirantis/mk/Salt.groovy
index 5973184..a1781cf 100644
--- a/src/com/mirantis/mk/Salt.groovy
+++ b/src/com/mirantis/mk/Salt.groovy
@@ -575,12 +575,22 @@
* @param name Name of the VM (for ex. ctl01)
* @return Salt minion ID of KVM node hosting 'name' VM
*/
-def getNodeProvider(saltId, name) {
- def kvm = getKvmMinionId(saltId)
- return getReturnValues(getPillar(saltId, "${kvm}", "salt:control:cluster:internal:node:${name}:provider"))
+def getNodeProvider(saltId, nodeName) {
+ def salt = new com.mirantis.mk.Salt()
+ def common = new com.mirantis.mk.Common()
+ def kvms = salt.getMinions(saltId, 'I@salt:control')
+ for (kvm in kvms) {
+ try {
+ vms = salt.getReturnValues(salt.runSaltProcessStep(saltId, kvm, 'virt.list_domains', [], null, true))
+ if (vms.toString().contains(nodeName)) {
+ return kvm
+ }
+ } catch (Exception er) {
+ common.infoMsg("${nodeName} not present on ${kvm}")
+ }
+ }
}
-
/**
* Test if there are any minions to target
* @param saltId Salt Connection object or pepperEnv (the command will be sent using the selected method)