Fix multipath removal script
[mirror/dsa-wiki.git] / input / howto / decomission.mdwn
index da732e5..68ed36d 100644 (file)
@@ -8,7 +8,8 @@
 
  * Revoke puppet certificate
 
-   * on handel: puppet node clean $HOST
+   * on handel: puppet node clean $HOST.debian.org
+   * on handel: puppet node deactivate $HOST.debian.org
    * reinit samhain on handel
 
  * Remove from LDAP
    * run multipath -ll on the KVM host and find all disks on that multipath
 
 ```
-    finzi-srv (3600c0ff00027786c874edd5701000000) dm-52 HP,MSA 2040 SAN
-    size=75G features='2 queue_if_no_path retain_attached_hw_handler' hwhandler='0' wp=rw
-    |-+- policy='service-time 0' prio=50 status=active
-    | |- 1:0:2:4  sdeu 129:96  active ready running
-    | |- 1:0:3:4  sdhu 134:64  active ready running
-    | |- 2:0:0:4  sdaa 65:160  active ready running
-    | `- 2:0:2:4  sdfz 131:80  active ready running
-    `-+- policy='service-time 0' prio=10 status=enabled
-      |- 1:0:0:4  sdf  8:80    active ready running
-      |- 1:0:1:4  sdbu 68:128  active ready running
-      |- 2:0:1:4  sdcz 70:112  active ready running
-      `- 2:0:3:4  sdja 8:320   active ready running
-   
+echo -n "multipath device to remove: " &&
+export LC_ALL=C &&
+read path &&
+dm=$(sudo multipath -ll | grep "$path" | awk '{print $2}') &&
+cd /sys/devices/virtual/block/$dm/slaves &&
+devices=$(ls -1) &&
+blockdev --flushbufs /dev/$dm &&
+multipath -f $path &&
+for device in $(echo $devices); do blockdev --flushbufs /dev/$device; echo 1 > "/sys/block/$device/device/delete"; done
 ```
-   * for each disk in those multipath run
-
-     echo 1 > /sys/block/sdX/device/delete
-
-   * once done, remove that multpath-device from multipath
-
-     multipath -f finzi-srv
 
    * remove the paths in the MSA