fix pipelines for adding and removal osd
to use them for migration to ceph-volume

Related-Prod: PROD-35675
Change-Id: If1beb17a359ba13000109308286cef3da801f032
diff --git a/ceph-add-osd-upmap.groovy b/ceph-add-osd-upmap.groovy
index 52ccf1e..07fc662 100644
--- a/ceph-add-osd-upmap.groovy
+++ b/ceph-add-osd-upmap.groovy
@@ -28,7 +28,7 @@
 def generatemapping(master,pgmap,map) {
     def pg_new
     def pg_old
-    for (pg in pgmap) {
+    for (pg in pgmap.get('pg_stats',[])) {
         pg_new = pg["up"].minus(pg["acting"])
         pg_old = pg["acting"].minus(pg["up"])
         for (i = 0; i < pg_new.size(); i++) {
@@ -50,15 +50,13 @@
                     common.errorMsg("Host not found")
                     throw new InterruptedException()
                 }
-                // I@docker:swarm and I@prometheus:server - mon* nodes
-                def nodes = salt.getMinions(pepperEnv, "I@ceph:common and not ( I@docker:swarm and I@prometheus:server ) and not " + HOST)
-                for ( node in nodes )
-                {
-                    def features = salt.cmdRun(pepperEnv, node, "ceph features --format json", checkResponse=true, batch=null, output=false).values()[0]
-                    features = new groovy.json.JsonSlurperClassic().parseText(features[0][node])
-                    if ( fetures['client']['group']['release'] != 'luminous' )
-                    {
-                        throw new Exception("client installed on " + node + " does not support upmap. Update all clients to luminous or newer before using this pipeline")
+                def cmn = salt.getFirstMinion(pepperEnv, "I@ceph:mon")
+                def features = salt.cmdRun(pepperEnv, cmn, "ceph features --format json", checkResponse=true, batch=null, output=false).values()[0]
+
+                features = new groovy.json.JsonSlurperClassic().parseText(features[0][cmn])
+                for ( group in features['client'] ) {
+                    if ( group['release'] != 'luminous' ) {
+                        throw new Exception("Some of installed clients does not support upmap. Update all clients to luminous or newer before using this pipeline")
                     }
                 }
             }
@@ -81,6 +79,7 @@
             }
 
             stage('Install Ceph OSD') {
+                salt.enforceState(pepperEnv, HOST, 'linux.storage')
                 orchestrate.installCephOsd(pepperEnv, HOST)
             }
 
@@ -103,7 +102,6 @@
                 salt.enforceState(pepperEnv, '*', 'linux.network.host')
             }
 
-            def mapping = []
 
             stage("update mappings") {
                 def pgmap
@@ -112,6 +110,7 @@
                     if (pgmap == '') {
                         return 1
                     } else {
+                        def mapping = []
                         pgmap = new groovy.json.JsonSlurperClassic().parseText(pgmap)
                         generatemapping(pepperEnv, pgmap, mapping)
                         mapping.each(this.&runCephCommand)