Add support of unknown default VG and default root LV names (use find and awk instead)

This commit is contained in:
nemo 2019-09-08 15:13:30 +02:00
parent 04fb5ca175
commit fd9ad6bdf6

View file

@ -442,9 +442,16 @@ if [ "${VM_DISK_EXTEND}" -ne 0 ]; then
exit 1
fi
echo "INFO : Add new PV to VG default_vg... (vgextend default_vg /dev/vda3)"
DEFAULT_VG=$(vgs | awk '/vg/ {print $1}')
ssh ${SSH_OPT} ${SSH_HOST} "vgextend default_vg /dev/vda3" &> /dev/null
if [ $? -ne 0 ]; then
echo 'ERROR : problem during get the name of the default VG'
exit 1
fi
echo "INFO : Add new PV to VG ${DEFAULT_VG}... (vgextend ${DEFAULT_VG} /dev/vda3)"
ssh ${SSH_OPT} ${SSH_HOST} "vgextend ${DEFAULT_VG} /dev/vda3" &> /dev/null
if [ $? -ne 0 ]; then
echo 'ERROR : problem during add new PV in VG, please finish manually the deploy OR delete VM and IPAM information'
@ -453,7 +460,14 @@ if [ "${VM_DISK_EXTEND}" -ne 0 ]; then
echo "INFO : Resize LV on disk... (RESIZE VM LV)"
ssh ${SSH_OPT} ${SSH_HOST} "lvextend -l +100%FREE /dev/mapper/default_vg-root_1" &> /dev/null
DEFAULT_LV_ROOT=$(find /dev/mapper -name '*root*')
if [ $? -ne 0 ]; then
echo 'ERROR : problem during get the name of the default root LV'
exit 1
fi
ssh ${SSH_OPT} ${SSH_HOST} "lvextend -l +100%FREE ${DEFAULT_LV_ROOT}" &> /dev/null
if [ $? -ne 0 ]; then
echo 'ERROR : problem during resizing LV, please finish manually the deploy OR delete VM and IPAM information'
@ -462,7 +476,7 @@ if [ "${VM_DISK_EXTEND}" -ne 0 ]; then
echo "INFO : resize2fs the LV... (RESIZE VM LV FS)"
ssh ${SSH_OPT} ${SSH_HOST} "resize2fs /dev/mapper/default_vg-root_1" &> /dev/null
ssh ${SSH_OPT} ${SSH_HOST} "resize2fs ${DEFAULT_LV_ROOT}" &> /dev/null
if [ $? -ne 0 ]; then
echo 'ERROR : problem during resize2fs, please finish manually the deploy OR delete VM and IPAM information'