updated ceph osd remove pipeline
Change-Id: I8db7b37bf7b9c4a658942966d50ca3db7070992e
diff --git a/ceph-enforce-weights.groovy b/ceph-enforce-weights.groovy
deleted file mode 100644
index 3c0db62..0000000
--- a/ceph-enforce-weights.groovy
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *
- * Enforce OSD weights from model
- *
- * Requred parameters:
- * SALT_MASTER_URL URL of Salt master
- * SALT_MASTER_CREDENTIALS Credentials to the Salt API
- *
- * ADMIN_HOST Host (minion id) with admin keyring
- *
- */
-
-common = new com.mirantis.mk.Common()
-salt = new com.mirantis.mk.Salt()
-def python = new com.mirantis.mk.Python()
-
-def pepperEnv = "pepperEnv"
-
-def runCephCommand(master, cmd) {
- return salt.cmdRun(master, ADMIN_HOST, cmd)
-}
-
-def grains
-
-node("python") {
-
- stage('Load cluster information') {
- python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
-
- // get list of disk from grains
- grains = salt.getGrain(pepperEnv, 'I@ceph:osd')['return'][0]
- common.prettyPrint(grains)
-
- }
-
- stage('Enforce weights on OSDs') {
-
- for (host in grains) {
- // parse grains
- def hostGrains = host.value
- common.prettyPrint(hostGrains)
-
- def hostname = hostGrains.host
- def salt_id = hostGrains.id
- def ceph_host_id = hostGrains.ceph_osd_host_id
-
- common.infoMsg("Setting weights on host ${hostname} (${salt_id}), ceph_id ${ceph_host_id}")
- for (disk in hostGrains.ceph_osd_disk) {
- def osd_id = ceph_host_id + disk.key
- print(osd_id)
- print(disk.value)
- print(disk.key)
- def cmd = "ceph osd crush set ${osd_id} ${disk.value.weight} host=${hostname}"
- print(runCephCommand(pepperEnv, cmd))
- }
- }
-
- }
-}
diff --git a/ceph-remove-osd.groovy b/ceph-remove-osd.groovy
index 0963131..0471f9f 100644
--- a/ceph-remove-osd.groovy
+++ b/ceph-remove-osd.groovy
@@ -38,18 +38,17 @@
}
}
- // get list of disk at the osd
- def pillar_disks = salt.getPillar(pepperEnv, HOST, 'ceph:osd:disk')['return'][0].values()[0]
- def hostname_id = salt.getPillar(pepperEnv, HOST, 'ceph:osd:host_id')['return'][0].values()[0]
def osd_ids = []
- print("host_id is ${hostname_id}")
print("osds:")
print(osds)
- for (i in pillar_disks) {
- def osd_id = (hostname_id + i.key).toInteger().toString()
- print("Evaluating ${osd_id}")
+ // get list of osd disks of the host
+ def ceph_disks = salt.getGrain(pepperEnv, HOST, 'ceph')['return'][0].values()[0].values()[0]['ceph_disk']
+ common.prettyPrint(ceph_disks)
+
+ for (i in ceph_disks) {
+ def osd_id = i.getKey().toString()
if (osd_id in osds || OSD == '*') {
osd_ids.add('osd.' + osd_id)
print("Will delete " + osd_id)
@@ -114,5 +113,4 @@
}
}
}
-
}