|
|
|
@ -29,7 +29,7 @@ if [ $1 ]; then
|
|
|
|
|
usage |
|
|
|
|
exit 1 |
|
|
|
|
else |
|
|
|
|
# Verification of the presence of VM conf file |
|
|
|
|
# Check the presence of VM conf file |
|
|
|
|
if [ -f "$1" ]; then |
|
|
|
|
VM_CONF_FILE=$1 |
|
|
|
|
. ${VM_CONF_FILE} |
|
|
|
@ -348,14 +348,9 @@ echo "INFO : Get the FE80 IPv6 of the new VM..."
|
|
|
|
|
VM_MAC=$(grep net0 /etc/pve/qemu-server/${VM_ID}.conf | cut -d '=' -f 2 | cut -d ',' -f 1) |
|
|
|
|
VM_FE80=$(ipv6calc --action prefixmac2ipv6 --in prefix+mac --out ipv6addr fe80:: $VM_MAC) |
|
|
|
|
|
|
|
|
|
VM_BRIDGE_DEV="vmbr1" |
|
|
|
|
|
|
|
|
|
# Define SSH host |
|
|
|
|
SSH_HOST="root@${VM_FE80}%${VM_BRIDGE_DEV}" |
|
|
|
|
|
|
|
|
|
echo "INFO : wait 2 minutes to be sure that ssh service is started" |
|
|
|
|
sleep 180 |
|
|
|
|
|
|
|
|
|
# Create network configuration file for new VM |
|
|
|
|
echo "INFO : Create network configuration file for new VM..." |
|
|
|
|
echo "# This file describes the network interfaces available on your system |
|
|
|
@ -373,11 +368,12 @@ allow-hotplug ens18
|
|
|
|
|
iface ens18 inet static |
|
|
|
|
address ${VM_IPV4_NEW}/${VM_IPV4_NEW_SUBNET_MASK} |
|
|
|
|
gateway ${VM_IPV4_NEW_SUBNET_GW} |
|
|
|
|
dns-nameservers 89.234.186.5 89.234.186.4 |
|
|
|
|
dns-nameservers ${DNS_NAMESERVERS_IPV4} |
|
|
|
|
|
|
|
|
|
iface ens18 inet6 static |
|
|
|
|
address ${RANGE_IPV6_NEW_WITHOUT_MASK}1/${RANGE_IPV6_NEW_MASK} |
|
|
|
|
gateway ${IPV6_GATEWAY}" > /tmp/interfaces_vm${VM_ID} |
|
|
|
|
gateway ${IPV6_GATEWAY} |
|
|
|
|
dns-nameservers ${DNS_NAMESERVERS_IPV6}" > /tmp/interfaces_vm${VM_ID} |
|
|
|
|
|
|
|
|
|
# Replace network configuration file on new VM |
|
|
|
|
echo "INFO : Replace network configuration file on new VM... (VM NETWORK CONF UPDATE)" |
|
|
|
@ -405,12 +401,12 @@ if [ $? -ne 0 ]; then
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# Regenerate SSH host keys for the VM and restart SSHD |
|
|
|
|
#echo "INFO : Regenerate SSH host keys for the VM and restart SSHD..." |
|
|
|
|
#ssh ${SSH_OPT} ${SSH_HOST} "/bin/rm -v /etc/ssh/ssh_host_* && dpkg-reconfigure openssh-server && systemctl restart ssh" &> /dev/null |
|
|
|
|
#if [ $? -ne 0 ]; then |
|
|
|
|
# echo 'ERROR : problem during regenerate SSH host keys for the VM, please finish manually the deploy OR delete VM and IPAM information' |
|
|
|
|
# exit 1 |
|
|
|
|
#fi |
|
|
|
|
echo "INFO : Regenerate SSH host keys for the VM and restart SSHD..." |
|
|
|
|
ssh ${SSH_OPT} ${SSH_HOST} "/bin/rm -v /etc/ssh/ssh_host_* && dpkg-reconfigure openssh-server && systemctl restart ssh" &> /dev/null |
|
|
|
|
if [ $? -ne 0 ]; then |
|
|
|
|
echo 'ERROR : problem during regenerate SSH host keys for the VM, please finish manually the deploy OR delete VM and IPAM information' |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# Get FingerPrint |
|
|
|
|
echo "INFO : Get SSH FingerPrint of the new VM..." |
|
|
|
@ -439,7 +435,6 @@ if [ "${VM_DISK_EXTEND}" -ne 0 ]; then
|
|
|
|
|
# Wait for system reboot |
|
|
|
|
sleep 20 |
|
|
|
|
echo "INFO : wait 3 minutes to be sure that ssh service is started" |
|
|
|
|
sleep 180 |
|
|
|
|
|
|
|
|
|
echo "INFO : Create new PV... (pvcreate /dev/vda3)" |
|
|
|
|
|
|
|
|
@ -455,7 +450,7 @@ sleep 180
|
|
|
|
|
if [ $? -ne 0 ]; then |
|
|
|
|
echo 'ERROR : problem during get the name of the default VG' |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
echo "INFO : Add new PV to VG ${DEFAULT_VG}... (vgextend ${DEFAULT_VG} /dev/vda3)" |
|
|
|
|
|
|
|
|
@ -468,12 +463,12 @@ sleep 180
|
|
|
|
|
|
|
|
|
|
echo "INFO : Resize LV on disk... (RESIZE VM LV)" |
|
|
|
|
|
|
|
|
|
DEFAULT_LV_ROOT=$(find /dev/mapper -name '*root*') |
|
|
|
|
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 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
ssh ${SSH_OPT} ${SSH_HOST} "lvextend -l +100%FREE ${DEFAULT_LV_ROOT}" &> /dev/null |
|
|
|
|
|
|
|
|
|