Add missed definitions in stacklight upgrade pipeline

Related-PROD: PROD-23663 (PROD:23663)

Change-Id: Ifbbecc545eb1c5724a78ff005da6bd661532f577
diff --git a/stacklight-upgrade.groovy b/stacklight-upgrade.groovy
index 8c445ac..7b79f4c 100644
--- a/stacklight-upgrade.groovy
+++ b/stacklight-upgrade.groovy
@@ -25,9 +25,11 @@
 def commandKwargs
 def probe = 1
 def errorOccured = false
-def command = 'cmd.run'
 
 def upgrade(master, target, service, pckg, state) {
+    def common = new com.mirantis.mk.Common()
+    def salt = new com.mirantis.mk.Salt()
+    def command = 'cmd.run'
     stage("Change ${target} repos") {
         salt.runSaltProcessStep(master, "${target}", 'saltutil.refresh_pillar', [], null, true, 5)
         salt.enforceState(master, "${target}", 'linux.system.repo', true)
@@ -42,22 +44,25 @@
             return
         }
     }
-    stage("Run ${state} on ${target}") {
+    stage("Run ${state} state on ${target} nodes") {
         try {
-            salt.enforceState(master, '${target}', '${state}')
+            salt.enforceState(master, "${target}", ["${state}"], true)
         } catch (Exception er) {
             errorOccured = true
-            common.errorMsg('${state} state was executed and failed. Please fix it manually.')
+            common.errorMsg("${state} state was executed and failed. Please fix it manually.")
         }
     }
-    out = salt.runSaltCommand(master, 'local', ['expression': '${target}', 'type': 'compound'], command, null, 'systemctl status ${service}.service', null)
+    out = salt.runSaltCommand(master, 'local', ['expression': "${target}", 'type': 'compound'], command, null, "systemctl status ${service}.service", null)
     salt.printSaltCommandResult(out)
 
-    common.warningMsg('Please check \'systemctl status ${service}.service\' on ${target} nodes if ${service} is running.')
+    common.warningMsg("Please check \'systemctl status ${service}.service\' on ${target} nodes if ${service} is running.")
     return
 }
 
 def upgrade_es_kibana(master) {
+    def common = new com.mirantis.mk.Common()
+    def salt = new com.mirantis.mk.Salt()
+    def command = 'cmd.run'
     stage('Elasticsearch upgrade') {
         try {
             salt.runSaltProcessStep(master, 'I@elasticsearch:server', command, ["systemctl stop elasticsearch"], null, true)
@@ -76,6 +81,7 @@
             def retries_wait = 20
             def retries = 15
             def elasticsearch_vip
+            def pillar = salt.getPillar(master, "I@elasticsearch:client", 'elasticsearch:client:server:host')
             if(!pillar['return'].isEmpty()) {
                 elasticsearch_vip = pillar['return'][0].values()[0]
             } else {
@@ -136,9 +142,10 @@
             if (salt.testTarget(pepperEnv, "I@prometheus:exporters:jmx")) {
                 upgrade(pepperEnv, "I@prometheus:exporters:jmx", "jmx-exporter", "jmx-exporter", "prometheus")
             }
-            if (STAGE_UPGRADE_ES_KIBANA.toBoolean() == true && !errorOccured) {
-                upgrade_es_kibana(pepperEnv)
-            }
+        }
+
+        if (STAGE_UPGRADE_ES_KIBANA.toBoolean() == true && !errorOccured) {
+            upgrade_es_kibana(pepperEnv)
         }
 
         if (STAGE_UPGRADE_DOCKER_COMPONENTS.toBoolean() == true && !errorOccured) {
@@ -146,9 +153,9 @@
             stage('Docker components upgrade') {
 
                 try {
-                    salt.runSaltProcessStep(pepperEnv, 'I@docker:swarm:role:master and I@prometheus:server', command, ["docker stack rm monitoring"], null, true)
+                    salt.runSaltProcessStep(pepperEnv, 'I@docker:swarm:role:master and I@prometheus:server', 'cmd.run', ["docker stack rm monitoring"], null, true)
                     salt.enforceState(pepperEnv, 'I@docker:swarm and I@prometheus:server', 'prometheus')
-                    salt.runSaltProcessStep(pepperEnv, 'I@docker:swarm:role:master and I@prometheus:server', command, ["docker stack rm dashboard"], null, true)
+                    salt.runSaltProcessStep(pepperEnv, 'I@docker:swarm:role:master and I@prometheus:server', 'cmd.run', ["docker stack rm dashboard"], null, true)
                     salt.enforceState(pepperEnv, 'I@docker:swarm:role:master and I@prometheus:server', 'docker')
                     salt.runSaltProcessStep(pepperEnv, '*', 'saltutil.sync_all', [], null, true)
                     salt.enforceState(pepperEnv, 'I@grafana:client', 'grafana.client')