The usual IT babble
Posts tagged IBM
SVC: Migrate VDisks off a MDisk Group onto another
Oct 29th
Out of necessity, another SVC shell script was just born. If you ever need to migrate a whole MDisk group onto another, you quickly discover the limited application of the SVC GUI. Now, you could query the VDisks using your original MDisk Group and then copy and paste the VDisk’s name (or the VDisk ID) into a command line and simply reuse that svctask migratevdisk command over and over.
Luckily IBM blessed the SVC with an SSH interface. So again, we can write a (kinda) simple shell script which may look like this:
#!/bin/bash svc_cluster_ip=10.150.7.33 svc_priv_dsa=~/.ssh/id_dsa if [ -z $2 ] ; then echo echo " ${0##*/} [ original_mdiskgrp | target_mdiskgrp | (threads) ]" echo echo " mdiskgrp_old - The MDisk Group which currently contains" echo " the VDisks." echo " mdiskgrp_new - The MDisk Group you wish to migrate the" echo " VDisks migrated to." echo " threads - Number of processes to use for the migration." echo " By default, \`migratevdisk\` uses 2." echo exit 1; fi if [ ! -f $svc_priv_dsa ] ; then echo " ${0##*/} is missing the SSH DSA private key" echo " needed to access the SAN Volume controller." echo " Please specify the correct path!" fi mdiskgrp_old=$1 mdiskgrp_new=$2 threads=$3 : ${threads:=2} check_running_migrations() { # Get the number of already running migrations. The SVC is currently # able to run 32 migrations at the same time. running="$( ssh -i $svc_priv_dsa admin@$svc_cluster_ip svcinfo lsmigrate \ | grep progress | wc -l )" if [ $running -ge 32 ] ; then echo echo " The SVC is already running the maximum amount of migrations" echo " at this time. Please retry, once the running migrations" echo " finished." echo exit 1 fi } check_running_migrations if [ "$( ssh -i $svc_priv_dsa admin@$svc_cluster_ip svcinfo lsmdiskgrp \ $mdiskgrp_new &>/dev/null ; echo $? )" = 1 ] ; then echo "${0##*/}: The MDisk Group ($mdiskgrp_new) doesn't existent!" exit 1 fi echo "Legend:" echo echo -e " \033[0;32m*\033[0m VDisk migration started successfully" echo -e " \033[0;36m*\033[0m VDisk migration skipped (already running?)" echo -e " \033[0;31m*\033[0m VDisk migration failed to start (wrong name?)" echo echo "Starting the tasks to migrate VDisks of $mdiskgrp_old to $mdiskgrp_new" for vdisk in $( ssh -i $svc_priv_dsa admin@$svc_cluster_ip svcinfo \ lsvdisk -nohdr -delim : -filtervalue mdisk_grp_name=$mdiskgrp_old ); do vdisk_id="$( echo $vdisk | cut -d: -f1 )" vdisk_name="$( echo $vdisk | cut -d: -f2 )" # Check if there's already a migration running for this vdisk if [ "$( ssh -i $svc_priv_dsa admin@$svc_cluster_ip svcinfo lsmigrate \ | grep "migrate_source_vdisk_index $vdisk_id\$" )" != "" ] ; then echo -e " \033[0;36m*\033[0m VDisk $vdisk_name ($vdisk_id)" continue fi check_running_migrations ssh -i $svc_priv_dsa admin@$svc_cluster_ip svctask migratevdisk \ -mdiskgrp $mdiskgrp_new -threads $threads \ -vdisk $vdisk_name &>/dev/null response=$? [ $response -eq 0 ] && \ echo -e " \033[0;32m*\033[0m VDisk $vdisk_name ($vdisk_id)" \ || echo -e " \033[0;31m*\033[0m VDisk $vdisk_name ($vdisk_id)" running=$((running+1)) done echo
And the execution would look like this:
svc-mgmt ~ # svctask_migratemdiskgrp DS3400_146G_R1 DS4700_500G_R6 4 The SVC is already running the maximum amount of migrations at this time. Please retry, once the running migrations finished.
Or maybe:
svc-mgmt ~ # svctask_migratemdiskgrp DS3400_146G_R1 DS4700_500G_R6 4 Legend: * VDisk migration started successfully * VDisk migration skipped (already running?) * VDisk migration failed to start (wrong name?) Starting the tasks to migrate VDisks from DS3400_146G_R1 to DS4700_500G_R6 * VDisk V_ATLAS_C_01 (25) * VDisk V_AETHER_D_01 (13) * VDisk V_DEIMOS_ROOT
IBM SVC: Copy VDisk Host-Mapping from one host to another
Oct 11th
As I wrote a few days ago, I started a new job. One of my first (voluntary) tasks was writing a shell script which would copy a VDisk Host-Mapping from a given host to another. This is useful, if you do have a lot of ESX servers for example and a few roaming ones.
Now, if say, you need to do some ESX-Updates and you would like to add the roaming one to a given farm, you would be in a dark an deary place. You would be required to either click through the GUI a dozen times (in my case, it might have needed ~200 clicks) or type svcinfo lshostvdiskmap <examplehosthere> and svctask mkhostvdiskmap <newhosthere> -force (these are incomplete command references) a few times.
Both methods ain’t optimal nor fast. Since the SVCTools (Perl, jikes) don’t really came into consideration, and the SVC SSH interface really doesn’t provide any other method to do a simple `cut -d: -f3` (as a hint: if anyone knows a nice method to emulate cut with bash patterns — yeah, I ain’t kidding — please drop me a note!), I ended up writing a simple shell script which is gonna do all the tasks from any Linux system (in possession of the SSH DSA private keys for the SVC of course).
The script looks like this:
#!/bin/sh svc_cluster_ip=10.0.0.10 svc_priv_dsa=~/.ssh/id_dsa_svc if [ -n $2 ] ; then echo " copyvdiskhostmap.sh [ host_to | host_from ]" echo echo " host_to - Target host, for which we will create the VDisk map." echo " host_from - Source host, from which the VDisk map will be copied." echo exit 1; fi if [ ! -f $svc_priv_dsa ] ; then echo " copyvdiskhostmap.sh is missing the SSH DSA private key needed" echo " to access the SAN Volume controller." echo " Please specify the correct path!" fi host_to=$1 host_from=$2 for mapping in $( ssh -i $svc_priv_dsa admin@$svc_cluster_ip svcinfo \ lshostvdiskmap -nohdr -delim : $host_from ); do vdisk_scsi_id="$( echo $mapping | cut -d: -f3 )" vdisk_name="$( echo $mapping | cut -d: -f5 )" ssh -i $svc_priv_dsa admin@$svc_cluster_ip svcinfo lshost $host_to || \ echo "Failed, since the target host doesn't existent!" && break ssh -i $svc_priv_dsa admin@$svc_cluster_ip svctask mkvdiskhostmap -force \ -host $host_to -scsi $vdisk_scsi_id $vdisk_name done