Seiten

Montag, 22. März 2021

Kleine ESX helper


Manschmal möchte man einen esxi host freigeben und vorher auch alle Datastorage unmapen


       

#!/bin/bash

echo "Willkommen zum VMWare esxi unmap Helfer"


read -er -p "Geben sie den esxi Host an: " -i "$default_host" host
read -er -p "User: " -i "$default_user" user
read -rs -p "Passwort: " passwd


#Create storagelist

for storage in $(esxcli -u $user  -s $host -p $passwd storage filesystem list | awk '($4 == "true") && ($5 == "VMFS-5"){print $2} ')
do
 echo "unmap $storage on $host"
 esxcli -u $user  -s $host -p $passwd storage vmfs unmap -l $storage
 
done


       
 

Wenn man eine 3par hat und die luns mit der falschen Policy laufen und man auch die default policy ändern will dann hilft der Helper es lässt sich auch für andere Storageanbieter anpassen


#!/bin/bash

echo "Willkommen zum VMWare esxi_pfad_helper Helfer"


for esx in [liste: host1 host2 ...]
do
 echo "auf Host $esx"
 echo "aendern der Police zu Roundrounbin wenn falsch eingestellt !"
 for i in $( ssh -x -l root $esx 'esxcli storage nmp device list | egrep -B 4 "Path Selection Policy: VMW_PSP_MRU|Path Selection Policy: VMW_PSP_FIXED" | egrep -B1 "Device Display Name: 3PARdata Fibre"| grep "^naa."; exit' )
 do 
  echo "3Par Device ohne Round Roubin: $i"
  ssh -x -l root $esx 'esxcli storage nmp device set --device $i --psp VMW_PSP_RR; exit '
 done
 echo "aendern der Default Path Selection Policy VM_SATP_ALUA zu VMW_PSP_RR"
 ssh -x -l root $esx `esxcli storage nmp satp set --default-psp=VMW_PSP_RR --satp=VMW_SATP_ALUA; exit`
done

 
 
       

#!/bin/bash

echo "Willkommen zum VMWare esxi pfad helper Helfer"

for esx in [liste host1 ... hostn]
 
 echo "auf Host $esx"
 ssh -x -l root $esx '
  hostname;
  echo "aendern der Police zu Roundrounbin wenn falsch eingestellt !"
  for i in $(esxcli storage nmp device list | egrep -B 4 "Path Selection Policy: VMW_PSP_MRU|Path Selection Policy: VMW_PSP_FIXED" | egrep -B1 "Device Display Name: 3PARdata Fibre"| grep "^naa.")
  do 
   echo "3Par Device ohne Round Roubin: $i"
   esxcli storage nmp device set --device $i --psp VMW_PSP_RR
  done
  
  echo "aender der Default Path Selection Policy VM_SATP_ALUA zu VMW_PSP_RR"
  esxcli storage nmp satp set --default-psp=VMW_PSP_RR --satp=VMW_SATP_ALUA
  esxcli storage nmp satp set --default-psp=VMW_PSP_RR --satp=VMW_SATP_DEFAULT_AA
  esxcli storage nmp satp set --default-psp=VMW_PSP_RR --satp=VMW_SATP_LOCAL
  exit;
 '
done

       
 
Schnell mal einen anderen loghost ausrollen statt der IP sollte auch FQDN funktionieren
       
#!/bin/bash
           for esx in [liste host1 ... hostn ] 
do
 echo "#### $esx ######"
 echo "#### set loghost ######"
 ip=ip_from_loghost
 ssh -l root $esx  ' esxcli system syslog config set --loghost='tcp://$ip:514'; esxcli system syslog config set --loghost='udp://$ip:514';  esxcli system syslog reload '
done

       
 
wenn man eine Disks grown will auf einen host
       
for vmdisk in [liste disk1 ...diskn]
do
 partion=$(vmkfstools -P "/vmfs/volumes/$vmdisk" | grep "naa"|sed 's/ //g')
 disk=$(vmkfstools -P "/vmfs/volumes/$vmdisk" | grep "naa"| cut -d":" -f1|sed 's/ //g')
 echo "partion: $partion disk: $disk"
 partedUtil get "/vmfs/devices/disks/$(echo $disk|sed 's/ //g')"
 partedUtil fixGpt "/vmfs/devices/disks/$(echo $disk|sed 's/ //g')"
 
 start=$(partedUtil get "/vmfs/devices/disks/$(echo $disk|sed 's/ //g')"| awk '/^1 /{print $2}')
 end=$(partedUtil getUsableSectors "/vmfs/devices/disks/$(echo $disk|sed 's/ //g')" | cut -d" " -f2 )
 echo "Start $start end: $end"
 
 echo " partedUtil resize \"/vmfs/devices/disks/$disk\" 1 $start $end "
 
 partedUtil resize "/vmfs/devices/disks/$(echo $disk|sed 's/ //g')" 1 $start $end
 
 partedUtil fixGpt "/vmfs/devices/disks/$(echo $disk|sed 's/ //g')"
 echo -e " vmkfstools --growfs \"/vmfs/devices/disks/$partion\" \"/vmfs/devices/disks/\$dpartion\" \n"
 vmkfstools --growfs "/vmfs/devices/disks/$(echo $partion|sed 's/ //g')" "/vmfs/devices/disks/$(echo $partion|sed 's/ //g')"

done


       
 

Keine Kommentare:

Kommentar veröffentlichen