Use right way to skip fuelmenu

Use virtualbox built-in keyboardputscancode instead of using
ssh to master node and kill fuelmenu.

Change-Id: Ie3a12b7ca54e4c606f4c88145cc3cbad5822480a
Closes-bug: #1501796
This commit is contained in:
Stanislav Makar 2015-08-26 17:27:26 +03:00
parent 7dc713ff28
commit ebabd4604b
3 changed files with 16 additions and 60 deletions

View File

@ -48,14 +48,15 @@ if [ ${headless} -eq 1 ]; then
enable_vrde $name ${RDPport}
fi
if [ "$skipfuelmenu" = "yes" ]; then
# " vmlinuz initrd=initrd.img biosdevname=0 ks=cdrom:/ks.cfg ip=10.20.0.2 gw=10.20.0.1 dns1=10.20.0.1 netmask=255.255.255.0 hostname=fuel.domain.tld showmenu=no" line is coded
boot_line=" 39 b9 2f af 32 b2 26 a6 17 97 31 b1 16 96 2c ac 39 b9 17 97 31 b1 17 97 14 94 13 93 20 a0 0d 8d 17 97 31 b1 17 97 14 94 13 93 20 a0 34 b4 17 97 32 b2 22 a2 39 b9 30 b0 17 97 18 98 1f 9f 20 a0 12 92 2f af 31 b1 1e 9e 32 b2 12 92 0d 8d 0b 8b 39 b9 25 a5 1f 9f 0d 8d 2e ae 20 a0 13 93 18 98 32 b2 2a 27 a7 aa 35 b5 25 a5 1f 9f 34 b4 2e ae 21 a1 22 a2 39 b9 17 97 19 99 0d 8d 02 82 0b 8b 34 b4 03 83 0b 8b 34 b4 0b 8b 34 b4 03 83 39 b9 22 a2 11 91 0d 8d 02 82 0b 8b 34 b4 03 83 0b 8b 34 b4 0b 8b 34 b4 02 82 39 b9 20 a0 31 b1 1f 9f 02 82 0d 8d 02 82 0b 8b 34 b4 03 83 0b 8b 34 b4 0b 8b 34 b4 02 82 39 b9 31 b1 12 92 14 94 32 b2 1e 9e 1f 9f 25 a5 0d 8d 03 83 06 86 06 86 34 b4 03 83 06 86 06 86 34 b4 03 83 06 86 06 86 34 b4 0b 8b 39 b9 23 a3 18 98 1f 9f 14 94 31 b1 1e 9e 32 b2 12 92 0d 8d 21 a1 16 96 12 92 26 a6 34 b4 20 a0 18 98 32 b2 1e 9e 17 97 31 b1 34 b4 14 94 26 a6 20 a0 39 b9 1f 9f 23 a3 18 98 11 91 32 b2 12 92 31 b1 16 96 0d 8d 31 b1 18 98 1c 9c"
fi
# Start virtual machine with the master node
echo
start_vm $name
if [ "$skipfuelmenu" = "yes" ]; then
wait_for_fuel_menu $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"
fi
# Wait until the machine gets installed and Puppet completes its run
wait_for_product_vm_to_install $vm_master_ip $vm_master_username $vm_master_password "$vm_master_prompt"

View File

@ -22,62 +22,6 @@ source ./functions/shell.sh
ssh_options='-oConnectTimeout=5 -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null -oRSAAuthentication=no -oPubkeyAuthentication=no'
wait_for_fuel_menu() {
ip=$1
username=$2
password=$3
prompt=$4
echo "Waiting for Fuel Menu so it can be skipped. Please do NOT abort the script..."
# Loop until master node gets successfully installed
maxdelay=3000
while ! skip_fuel_menu $ip $username $password "$prompt"; do
sleep 5
((waited += 5))
if (( waited >= maxdelay )); then
echo "Installation timed out! ($maxdelay seconds)" 1>&2
exit 1
fi
done
}
skip_fuel_menu() {
ip=$1
username=$2
password=$3
prompt=$4
# Log in into the VM, see if Fuel Setup is running or puppet already started
# Looks a bit ugly, but 'end of expect' has to be in the very beginning of the line
result=$(
execute expect << ENDOFEXPECT
spawn ssh $ssh_options $username@$ip
expect "connect to host" exit
expect "*?assword:*"
send "$password\r"
expect "$prompt"
send "pgrep 'fuelmenu|puppet';echo \"returns $?\"\r"
expect "$prompt"
ENDOFEXPECT
)
if [[ "$result" =~ "returns 0" ]]; then
echo "Skipping Fuel Setup..."
execute expect << ENDOFEXPECT
spawn ssh $ssh_options $username@$ip
expect "connect to host" exit
expect "*?assword:*"
send "$password\r"
expect "$prompt"
send "killall -w -SIGUSR1 fuelmenu\r"
expect "$prompt"
ENDOFEXPECT
return 0
else
return 1
fi
}
is_product_vm_operational() {
ip=$1
username=$2

View File

@ -207,6 +207,17 @@ start_vm() {
else
execute VBoxManage startvm $name
fi
if [ -n "$boot_line" ]; then
sleep 3
# Pressing/releasing escape key
execute VBoxManage controlvm ${name} keyboardputscancode 01 81
for letter in ${boot_line}; do
execute VBoxManage controlvm ${name} keyboardputscancode ${letter}
done
fi
}
mount_iso_to_vm() {